secp256k1

Pure Haskell Schnorr, ECDSA on the elliptic curve secp256k1 (docs.ppad.tech/secp256k1).
git clone git://git.ppad.tech/secp256k1.git
Log | Files | Refs | README | LICENSE

commit 335c6e52236327caca4d2edc68276823c8ec2d89
parent 140a16d3279c906101cee05e3f681754a787b3db
Author: Jared Tobin <jared@jtobin.io>
Date:   Fri,  8 Nov 2024 15:53:29 +0400

bench: precompute

Diffstat:
Mbench/Main.hs | 4++++
Mlib/Crypto/Curve/Secp256k1.hs | 7+++++++
2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/bench/Main.hs b/bench/Main.hs @@ -21,6 +21,7 @@ main = defaultMain [ parse_point , add , mul + , precompute , mul_wnaf , derive_pub , schnorr @@ -75,6 +76,9 @@ mul = env setup $ \x -> setup = pure . S.parse_int256 $ B16.decodeLenient "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed" +precompute :: Benchmark +precompute = bench "precompute" $ nfIO (pure S.precompute) + mul_wnaf :: Benchmark mul_wnaf = env setup $ \ ~(tex, x) -> bgroup "mul_wnaf" [ diff --git a/lib/Crypto/Curve/Secp256k1.hs b/lib/Crypto/Curve/Secp256k1.hs @@ -604,6 +604,13 @@ instance Show Context where -- | Create a secp256k1 context by precomputing multiples of the curve's -- generator point. +-- +-- This should be used once to create a 'Context' to be reused +-- repeatedly afterwards. +-- +-- >>> let !tex = precompute +-- >>> sign_ecdsa' tex sec msg +-- >>> sign_schnorr' tex sec msg aux precompute :: Context precompute = _precompute 8