Skip to content

Commit 3e22a64

Browse files
committed
feat(rapidsnark-gpu): Add rapidsnark-gpu package
1 parent e999f1b commit 3e22a64

File tree

3 files changed

+71
-1
lines changed

3 files changed

+71
-1
lines changed

flake.nix

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@
3131
};
3232

3333
outputs =
34-
inputs@{ flake-parts, nixos-modules, ... }:
34+
inputs@{
35+
flake-parts,
36+
nixos-modules,
37+
nixpkgs,
38+
...
39+
}:
3540
flake-parts.lib.mkFlake { inherit inputs; } {
3641
systems = [
3742
"x86_64-linux"
@@ -48,9 +53,14 @@
4853
final,
4954
self',
5055
config,
56+
system,
5157
...
5258
}:
5359
{
60+
_module.args.pkgs = import nixpkgs {
61+
inherit system;
62+
config.allowUnfree = true;
63+
};
5464
devShells.default = import ./shells/all.nix {
5565
pkgs = final;
5666
inherit self';

packages/all-packages.nix

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@
6868
rapidsnark = callPackage ./rapidsnark/default.nix {
6969
inherit ffiasm zqfield-bn254;
7070
};
71+
rapidsnark-gpu = callPackage ./rapidsnark-gpu/default.nix {
72+
inherit ffiasm zqfield-bn254;
73+
};
7174

7275
# Elrond / MultiversX
7376
# copied from https://github.com/NixOS/nixpkgs/blob/8df7949791250b580220eb266e72e77211bedad9/pkgs/development/python-modules/cryptography/default.nix
@@ -223,6 +226,7 @@
223226
ffiasm
224227
ffiasm-src
225228
rapidsnark
229+
rapidsnark-gpu
226230
;
227231

228232
inherit cardano graphql;
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
lib,
3+
cudaPackages,
4+
stdenv,
5+
ffiasm,
6+
zqfield-bn254,
7+
nlohmann_json,
8+
gmp,
9+
libsodium,
10+
cmake,
11+
fetchFromGitHub,
12+
pkg-config,
13+
}:
14+
let
15+
ffiasm-c = "${ffiasm}/lib/node_modules/ffiasm/c";
16+
in
17+
stdenv.mkDerivation rec {
18+
pname = "rapidsnark-gpu";
19+
version = "2023-04-08";
20+
21+
src = fetchFromGitHub {
22+
owner = "Orbiter-Finance";
23+
repo = "rapidsnark";
24+
rev = "77016322808ac58a3acd25a6235510b55172f967";
25+
hash = "sha256-8vy+iXkSINFregve+rej1rXyXdWxm0n1wvYfoy/0idk=";
26+
};
27+
28+
nativeBuildInputs = [ pkg-config ];
29+
buildInputs = [
30+
nlohmann_json
31+
gmp
32+
libsodium
33+
cudaPackages.cudatoolkit
34+
] ++ ffiasm.passthru.openmp;
35+
36+
buildPhase = ''
37+
mkdir -p $out/bin
38+
c++ \
39+
-I{${ffiasm-c},${zqfield-bn254}/lib} \
40+
./src/{main_prover,binfile_utils,zkey_utils,wtns_utils,logger}.cpp \
41+
${ffiasm-c}/{alt_bn128,misc,naf,splitparstr}.cpp \
42+
${zqfield-bn254}/lib/{fq,fr}.{cpp,o} \
43+
$(pkg-config --cflags --libs libsodium gmp nlohmann_json) \
44+
-std=c++17 -pthread -O3 -fopenmp \
45+
-o $out/bin/prover
46+
'';
47+
48+
installPhase = ''
49+
# Already done in buildPhase
50+
'';
51+
52+
meta = {
53+
homepage = "https://github.com/iden3/rapidsnark";
54+
platforms = with lib.platforms; linux ++ darwin;
55+
};
56+
}

0 commit comments

Comments
 (0)