2021-01-11 07:54:33 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, autoreconfHook, jdk
|
2016-09-18 19:29:32 +01:00
|
|
|
|
|
|
|
# Enable ECDSA pubkey recovery module
|
|
|
|
, enableRecovery ? true
|
|
|
|
|
|
|
|
# Enable ECDH shared secret computation (disabled by default because it is
|
|
|
|
# experimental)
|
|
|
|
, enableECDH ? false
|
|
|
|
|
|
|
|
# Enable libsecp256k1_jni (disabled by default because it requires a jdk,
|
|
|
|
# which is a large dependency)
|
|
|
|
, enableJNI ? false
|
|
|
|
|
|
|
|
}:
|
|
|
|
|
2021-01-15 09:19:50 +00:00
|
|
|
let inherit (lib) optionals; in
|
2016-06-04 18:55:15 +01:00
|
|
|
|
2019-08-13 22:52:01 +01:00
|
|
|
stdenv.mkDerivation {
|
2019-08-15 13:41:18 +01:00
|
|
|
pname = "secp256k1";
|
2016-06-04 18:55:15 +01:00
|
|
|
|
2016-09-18 19:29:32 +01:00
|
|
|
# I can't find any version numbers, so we're just using the date of the
|
|
|
|
# last commit.
|
2020-08-19 13:42:25 +01:00
|
|
|
version = "2020-08-16";
|
2016-06-04 18:55:15 +01:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "bitcoin-core";
|
|
|
|
repo = "secp256k1";
|
2020-08-19 13:42:25 +01:00
|
|
|
rev = "670cdd3f8be25f81472b2d16dcd228b0d24a5c45";
|
|
|
|
sha256 = "0ak2hrr0wznl5d9s905qwn5yds7k22i28d2jp957l4a8yf8cqv3s";
|
2016-06-04 18:55:15 +01:00
|
|
|
};
|
|
|
|
|
2016-09-18 19:29:32 +01:00
|
|
|
buildInputs = optionals enableJNI [ jdk ];
|
2016-06-04 18:55:15 +01:00
|
|
|
|
2016-09-18 19:29:32 +01:00
|
|
|
nativeBuildInputs = [ autoreconfHook ];
|
2016-06-04 18:55:15 +01:00
|
|
|
|
2016-09-18 19:29:32 +01:00
|
|
|
configureFlags =
|
2020-08-19 13:42:25 +01:00
|
|
|
[ "--enable-benchmark=no" "--enable-tests=yes" "--enable-exhaustive-tests=no" ] ++
|
2016-09-18 19:29:32 +01:00
|
|
|
optionals enableECDH [ "--enable-module-ecdh" "--enable-experimental" ] ++
|
|
|
|
optionals enableRecovery [ "--enable-module-recovery" ] ++
|
|
|
|
optionals enableJNI [ "--enable-jni" ];
|
2016-06-04 18:55:15 +01:00
|
|
|
|
2020-08-19 13:42:25 +01:00
|
|
|
doCheck = true;
|
|
|
|
checkPhase = "./tests";
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2016-06-04 18:55:15 +01:00
|
|
|
description = "Optimized C library for EC operations on curve secp256k1";
|
|
|
|
longDescription = ''
|
2016-09-18 19:29:32 +01:00
|
|
|
Optimized C library for EC operations on curve secp256k1. Part of
|
|
|
|
Bitcoin Core. This library is a work in progress and is being used
|
|
|
|
to research best practices. Use at your own risk.
|
2016-06-04 18:55:15 +01:00
|
|
|
'';
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "https://github.com/bitcoin-core/secp256k1";
|
2016-06-04 18:55:15 +01:00
|
|
|
license = with licenses; [ mit ];
|
|
|
|
maintainers = with maintainers; [ chris-martin ];
|
2016-08-02 18:50:55 +01:00
|
|
|
platforms = with platforms; unix;
|
2016-06-04 18:55:15 +01:00
|
|
|
};
|
|
|
|
}
|