Skip to content

Commit

Permalink
fix(ecdsa): fix failing test_sign when using pre_hashed option
Browse files Browse the repository at this point in the history
  • Loading branch information
bboilot-ledger authored and JulioLoayzaM committed Aug 1, 2024
1 parent 4f59283 commit 6871c6e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions crypto_condor/primitives/ECDSA.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,11 +851,13 @@ def _test_sign_nist(
logger.debug("Test vector error", exc_info=True)
continue

message = bytes.fromhex(test.message)
raw_message = bytes.fromhex(test.message)
if pre_hashed:
digest = hashes.Hash(hash_function.get_hash_instance())
digest.update(message)
digest.update(raw_message)
message = digest.finalize()
else:
message = raw_message

try:
signature = sign_function(key, message)
Expand Down Expand Up @@ -884,7 +886,7 @@ def _test_sign_nist(
)

data = SigData(info, key, message, signature)
if _verify(serialized_pub_key, hash_function, message, signature):
if _verify(serialized_pub_key, hash_function, raw_message, signature):
info.result = True
else:
info.error_msg = "Signature is not valid"
Expand Down

0 comments on commit 6871c6e

Please sign in to comment.