Skip to content

Commit 901bcb7

Browse files
committed
feat(rapidsnark-gpu): Add rapidsnark-gpu package
1 parent 5fd7b68 commit 901bcb7

File tree

3 files changed

+69
-6
lines changed

3 files changed

+69
-6
lines changed

flake.nix

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,30 @@
3636
};
3737
};
3838

39-
outputs = inputs @ {flake-parts, ...}:
39+
outputs = inputs @ {
40+
flake-parts,
41+
nixpkgs,
42+
...
43+
}:
4044
flake-parts.lib.mkFlake {inherit inputs;} {
4145
systems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
4246
imports = [./packages];
4347
perSystem = {
44-
final,
48+
pkgs,
4549
self',
50+
system,
4651
...
4752
}: {
53+
_module.args = {
54+
pkgs = import nixpkgs {
55+
inherit system;
56+
config.allowUnfree = true;
57+
};
58+
};
4859
devShells.default = import ./shells/all.nix {
49-
pkgs = final;
50-
inherit self';
60+
inherit pkgs self';
5161
};
52-
devShells.ci = import ./shells/ci.nix {pkgs = final;};
62+
devShells.ci = import ./shells/ci.nix {inherit pkgs;};
5363
};
5464
};
5565
}

packages/all-packages.nix

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959
rapidsnark = callPackage ./rapidsnark/default.nix {
6060
inherit ffiasm zqfield-bn254;
6161
};
62+
rapidsnark-gpu = callPackage ./rapidsnark-gpu/default.nix {
63+
inherit ffiasm zqfield-bn254;
64+
};
6265

6366
# Elrond / MultiversX
6467
# copied from https://github.com/NixOS/nixpkgs/blob/8df7949791250b580220eb266e72e77211bedad9/pkgs/development/python-modules/cryptography/default.nix
@@ -157,7 +160,7 @@
157160
cdt = callPackage ./cdt/default.nix {};
158161
}
159162
// lib.optionalAttrs hostPlatform.isx86 rec {
160-
inherit zqfield-bn254 ffiasm ffiasm-src rapidsnark;
163+
inherit zqfield-bn254 ffiasm ffiasm-src rapidsnark rapidsnark-gpu;
161164

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

0 commit comments

Comments
 (0)