commit 9afef0a502e4ab7c52bc7dba303fb378b49165b1
parent 4be6015e618ae285400ae68189ad392abf91c4b9
Author: Jared Tobin <jared@jtobin.io>
Date: Sun, 20 Oct 2024 15:26:47 +0400
lib: qualify ecdsa
Diffstat:
3 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/bench/Main.hs b/bench/Main.hs
@@ -23,8 +23,8 @@ suite :: Benchmark
suite = envWithCleanup setup destroy $ \ ~(tex, fen, pub, sig) ->
bgroup "csecp256k1" [
bgroup "ecdsa" [
- bench "sign" . nfIO $ S.sign tex _SEC _HAS
- , bench "verify" . nfIO $ S.verify tex pub _HAS sig
+ bench "sign" . nfIO $ S.sign_ecdsa tex _SEC _HAS
+ , bench "verify" . nfIO $ S.verify_ecdsa tex pub _HAS sig
]
, bgroup "schnorr" [
bench "sign" . nfIO $ S.sign_schnorr tex _HAS _SEC fen
diff --git a/lib/Crypto/Curve/Secp256k1.hs b/lib/Crypto/Curve/Secp256k1.hs
@@ -27,9 +27,9 @@ module Crypto.Curve.Secp256k1 (
, wrcontext
, Sig
- , sign
+ , sign_ecdsa
+ , verify_ecdsa
, sign_schnorr
- , verify
, verify_schnorr
, ecdh
@@ -367,12 +367,12 @@ tweak_sec_mul (Context tex) key wee
--
-- >>> wrcontext entropy $ \tex -> sign tex sec msg
-- "<bitcoin-core/secp256k1 signature>"
-sign
+sign_ecdsa
:: Context
-> BS.ByteString -- ^ 32-byte secret key
-> BS.ByteString -- ^ 32-byte message hash
-> IO Sig
-sign (Context tex) key msg
+sign_ecdsa (Context tex) key msg
| BS.length key /= 32 || BS.length msg /= 32 = throwIO CSecp256k1Error
| otherwise = A.allocaBytes _SIG_BYTES $ \out ->
BS.useAsCString msg $ \(F.castPtr -> has) ->
@@ -392,13 +392,13 @@ sign (Context tex) key msg
-- True
-- >>> wcontext $ \tex -> verify tex pub msg bad_sig
-- False
-verify
+verify_ecdsa
:: Context
-> Pub
-> BS.ByteString -- ^ 32-byte message hash
-> Sig
-> IO Bool
-verify (Context tex) (Pub pub) msg (Sig sig)
+verify_ecdsa (Context tex) (Pub pub) msg (Sig sig)
| BS.length msg /= 32 = throwIO CSecp256k1Error
| otherwise = BS.useAsCString pub $ \(F.castPtr -> key) ->
BS.useAsCString sig $ \(F.castPtr -> sip) ->
diff --git a/test/Main.hs b/test/Main.hs
@@ -26,8 +26,8 @@ units = testGroup "unit tests" [
, parse_xonly_test
, serialize_xonly_test
, keypair_test
- , sign_test
- , verify_test
+ , sign_ecdsa_test
+ , verify_ecdsa_test
, sign_schnorr_test
, verify_schnorr_test
]
@@ -147,19 +147,19 @@ keypair_test =
assertEqual "success" sec _SEC
assertEqual "success" ser _PUB_COMPRESSED
-sign_test :: TestTree
-sign_test = testCase "sign (success)" $
+sign_ecdsa_test :: TestTree
+sign_ecdsa_test = testCase "sign_ecdsa (success)" $
wcontext $ \tex -> do
- sig <- sign tex _SEC _HAS
+ sig <- sign_ecdsa tex _SEC _HAS
der <- serialize_der tex sig
assertEqual "success" _DER der
-verify_test :: TestTree
-verify_test = testCase "verify (success)" $
+verify_ecdsa_test :: TestTree
+verify_ecdsa_test = testCase "verify_ecdsa (success)" $
wcontext $ \tex -> do
pub <- parse_pub tex _PUB_UNCOMPRESSED
sig <- parse_der tex _DER
- suc <- verify tex pub _HAS sig
+ suc <- verify_ecdsa tex pub _HAS sig
assertBool "success" suc
sign_schnorr_test :: TestTree