1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 cmake,
6 gmp,
7 openssl,
8 pkg-config,
9 enableStatic ? stdenv.hostPlatform.isStatic,
10}:
11
12stdenv.mkDerivation rec {
13 pname = "libff";
14 version = "0.2.1";
15
16 src = fetchFromGitHub {
17 owner = "scipr-lab";
18 repo = "libff";
19 rev = "v${version}";
20 sha256 = "0dczi829497vqlmn6n4fgi89bc2h9f13gx30av5z2h6ikik7crgn";
21 fetchSubmodules = true;
22 };
23
24 cmakeFlags = [
25 "-DWITH_PROCPS=Off"
26 ]
27 ++ lib.optionals stdenv.hostPlatform.isAarch64 [
28 "-DCURVE=ALT_BN128"
29 "-DUSE_ASM=OFF"
30 ];
31
32 postPatch = lib.optionalString (!enableStatic) ''
33 substituteInPlace libff/CMakeLists.txt --replace "STATIC" "SHARED"
34 '';
35
36 nativeBuildInputs = [
37 cmake
38 pkg-config
39 ];
40 buildInputs = [
41 gmp
42 openssl
43 ];
44
45 meta = with lib; {
46 description = "C++ library for Finite Fields and Elliptic Curves";
47 changelog = "https://github.com/scipr-lab/libff/blob/develop/CHANGELOG.md";
48 homepage = "https://github.com/scipr-lab/libff";
49 license = licenses.mit;
50 platforms = platforms.unix;
51 maintainers = with maintainers; [ arturcygan ];
52 };
53}