csecp256k1

Haskell FFI bindings to bitcoin-core/secp256k1 (docs.ppad.tech/csecp256k1).
git clone git://git.ppad.tech/csecp256k1.git
Log | Files | Refs | README | LICENSE

commit 1020092680d8b1aa60f81433333d4c5c0a185086
parent 0d5916fe6754c86380ed81de58a40fc22c015257
Author: Jared Tobin <jared@jtobin.io>
Date:   Thu,  7 Nov 2024 15:50:52 +0400

test: wycheproof passing

Diffstat:
Mtest/Wycheproof.hs | 15+--------------
1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/test/Wycheproof.hs b/test/Wycheproof.hs @@ -13,25 +13,12 @@ import Crypto.Curve.Secp256k1 import qualified Crypto.Hash.SHA256 as SHA256 import Data.Aeson ((.:)) import qualified Data.Aeson as A -import qualified Data.Attoparsec.ByteString as AT -import qualified Data.Bits as B -import qualified Data.ByteString as BS import qualified Data.ByteString.Base16 as B16 import qualified Data.Text as T import qualified Data.Text.Encoding as TE -import qualified GHC.Num.Integer as I import Test.Tasty (TestTree, testGroup) import Test.Tasty.HUnit (assertBool, testCase) -fi :: (Integral a, Num b) => a -> b -fi = fromIntegral -{-# INLINE fi #-} - --- big-endian bytestring decoding -roll :: BS.ByteString -> Integer -roll = BS.foldl' unstep 0 where - unstep a (fi -> b) = (a `I.integerShiftL` 8) `I.integerOr` b - execute_group :: Context -> EcdsaTestGroup -> IO TestTree execute_group tex EcdsaTestGroup {..} = do let raw = B16.decodeLenient (TE.encodeUtf8 pk_uncompressed) @@ -44,7 +31,7 @@ execute_group tex EcdsaTestGroup {..} = do execute :: Context -> Pub -> EcdsaVerifyTest -> TestTree execute tex pub EcdsaVerifyTest {..} = testCase report $ do - let msg = B16.decodeLenient (TE.encodeUtf8 t_msg) + let msg = SHA256.hash (B16.decodeLenient (TE.encodeUtf8 t_msg)) sig = B16.decodeLenient (TE.encodeUtf8 t_sig) syg <- try (parse_der tex sig) :: IO (Either Secp256k1Exception Sig) case syg of