···11-{ stdenv, fetchFromGitHub, autoconf, automake, libtool, ... }:
11+{ stdenv, fetchFromGitHub, autoreconfHook, jdk
22+33+# Enable ECDSA pubkey recovery module
44+, enableRecovery ? true
55+66+# Enable ECDH shared secret computation (disabled by default because it is
77+# experimental)
88+, enableECDH ? false
99+1010+# Enable libsecp256k1_jni (disabled by default because it requires a jdk,
1111+# which is a large dependency)
1212+, enableJNI ? false
1313+1414+}:
1515+1616+let inherit (stdenv.lib) optionals; in
217318stdenv.mkDerivation rec {
419 name = "secp256k1-${version}";
52066- # I can't find any version numbers, so we're just using the date
77- # of the last commit.
88- version = "2016-05-30";
2121+ # I can't find any version numbers, so we're just using the date of the
2222+ # last commit.
2323+ version = "2016-11-27";
9241025 src = fetchFromGitHub {
1126 owner = "bitcoin-core";
1227 repo = "secp256k1";
1313- rev = "b3be8521e694eaf45dd29baea035055183c42fe2";
1414- sha256 = "1pgsy72w87yxbiqn96hnm8alsfx3rj7d9jlzdsypyf6i1rf6w4bq";
2828+ rev = "2928420c1b8e1feee8c20dff4e3cc41a0de2fc22";
2929+ sha256 = "1djsr2vrhh88353czlwb8bwlyabf008w1f7xg0fs3q33rf42w5gm";
1530 };
16311717- buildInputs = [ autoconf automake libtool ];
3232+ buildInputs = optionals enableJNI [ jdk ];
18331919- configureFlags = [ "--enable-module-recovery" ];
3434+ nativeBuildInputs = [ autoreconfHook ];
20352121- preConfigure = "./autogen.sh";
3636+ configureFlags =
3737+ optionals enableECDH [ "--enable-module-ecdh" "--enable-experimental" ] ++
3838+ optionals enableRecovery [ "--enable-module-recovery" ] ++
3939+ optionals enableJNI [ "--enable-jni" ];
22402341 meta = with stdenv.lib; {
2442 description = "Optimized C library for EC operations on curve secp256k1";
2543 longDescription = ''
2626- Optimized C library for EC operations on curve secp256k1.
2727- Part of Bitcoin Core. This library is a work in progress
2828- and is being used to research best practices. Use at your
2929- own risk.
4444+ Optimized C library for EC operations on curve secp256k1. Part of
4545+ Bitcoin Core. This library is a work in progress and is being used
4646+ to research best practices. Use at your own risk.
3047 '';
3148 homepage = https://github.com/bitcoin-core/secp256k1;
3249 license = with licenses; [ mit ];