@@ -1,32 +1,49 @@
1−{ stdenv, fetchFromGitHub, autoconf, automake, libtool, ... }:
1+{ stdenv, fetchFromGitHub, autoreconfHook, jdk
2+
3+# Enable ECDSA pubkey recovery module
4+, enableRecovery ? true
5+
6+# Enable ECDH shared secret computation (disabled by default because it is
7+# experimental)
8+, enableECDH ? false
9+
10+# Enable libsecp256k1_jni (disabled by default because it requires a jdk,
11+# which is a large dependency)
12+, enableJNI ? false
13+
14+}:
15+
16+let inherit (stdenv.lib) optionals; in
217
318stdenv.mkDerivation rec {
419 name = "secp256k1-${version}";
520
6− # I can't find any version numbers, so we're just using the date
7− # of the last commit.
8− version = "2016-05-30";
21+ # I can't find any version numbers, so we're just using the date of the
22+ # last commit.
23+ version = "2016-11-27";
924
1025 src = fetchFromGitHub {
1126 owner = "bitcoin-core";
1227 repo = "secp256k1";
13− rev = "b3be8521e694eaf45dd29baea035055183c42fe2";
14− sha256 = "1pgsy72w87yxbiqn96hnm8alsfx3rj7d9jlzdsypyf6i1rf6w4bq";
28+ rev = "2928420c1b8e1feee8c20dff4e3cc41a0de2fc22";
29+ sha256 = "1djsr2vrhh88353czlwb8bwlyabf008w1f7xg0fs3q33rf42w5gm";
1530 };
1631
17− buildInputs = [ autoconf automake libtool ];
32+ buildInputs = optionals enableJNI [ jdk ];
1833
19− configureFlags = [ "--enable-module-recovery" ];
34+ nativeBuildInputs = [ autoreconfHook ];
2035
21− preConfigure = "./autogen.sh";
36+ configureFlags =
37+ optionals enableECDH [ "--enable-module-ecdh" "--enable-experimental" ] ++
38+ optionals enableRecovery [ "--enable-module-recovery" ] ++
39+ optionals enableJNI [ "--enable-jni" ];
2240
2341 meta = with stdenv.lib; {
2442 description = "Optimized C library for EC operations on curve secp256k1";
2543 longDescription = ''
26− Optimized C library for EC operations on curve secp256k1.
27− Part of Bitcoin Core. This library is a work in progress
28− and is being used to research best practices. Use at your
29− own risk.
44+ Optimized C library for EC operations on curve secp256k1. Part of
45+ Bitcoin Core. This library is a work in progress and is being used
46+ to research best practices. Use at your own risk.
3047 '';
3148 homepage = https://github.com/bitcoin-core/secp256k1;
3249 license = with licenses; [ mit ];