Skip to content

Commit

Permalink
Add a redundant check for future proofing changes to secp256k1 library
Browse files Browse the repository at this point in the history
  • Loading branch information
lehins committed Aug 8, 2022
1 parent 6571b52 commit 8b624d6
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,14 @@ instance DSIGNAlgorithm EcdsaSecp256k1DSIGN where
alloca $ \(lenPtr :: Ptr CSize) -> do
poke lenPtr len
withForeignPtr secpCtxPtr $ \ctx -> do
void $ secpEcPubkeySerialize ctx dstp lenPtr psp secpEcCompressed
ret <- secpEcPubkeySerialize ctx dstp lenPtr psp secpEcCompressed
writtenLen <- peek lenPtr
unless (writtenLen == len)
(error "rawSerializeVerKeyDSIGN: Did not write correct length for VerKeyDSIGN EcdsaSecp256k1DSIGN")
-- This should never happen, since `secpEcPubkeySerialize` in the current
-- version of `secp256k1` library always returns 1:
unless (ret == 1)
(error "rawSerializeVerKeyDSIGN: Failed for unknown reason")
rawSerialiseSignKeyDSIGN (SignKeyEcdsaSecp256k1 psb) = psbToByteString psb
{-# NOINLINE rawDeserialiseSigDSIGN #-}
rawDeserialiseSigDSIGN bs =
Expand Down

0 comments on commit 8b624d6

Please sign in to comment.