Skip to content

Commit

Permalink
[tests] add test case for ECRecover
Browse files Browse the repository at this point in the history
  • Loading branch information
Vindaar committed Dec 31, 2024
1 parent dcfc599 commit 664d985
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions constantine/signatures/ecdsa.nim
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ proc recoverPubkeyImpl_vartime*[Name: static Algebra; Sig](
recovered.ccopy(Q.getAffine(), SecretBool validSig) # Copy `Q` if valid
# 6. try next `i` in `x1 = r + i·M`
x1 += M

proc recoverPubkey*[Pubkey; Sig](
recovered: var Pubkey,
signature: Sig,
Expand Down
6 changes: 5 additions & 1 deletion tests/t_ethereum_evm_precompiles.nim
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ template runPrecompileTests(filename: string, funcname: untyped, outsize: int, n
else:
let status = funcname(r, inputbytes)
if status != cttEVM_Success:
doAssert test.ExpectedError.len > 0, "[Test Failure]\n" &
# `ecRecover.json` has failing test vectors where no `ExpectedError` exists, but the
# `Expected` output is simply empty.
doAssert test.ExpectedError.len > 0 or test.Expected.len == 0, "[Test Failure]\n" &
" " & test.Name & "\n" &
" " & funcname.astToStr & "\n" &
" " & "Nim proc returned failure, but test expected to pass.\n" &
Expand Down Expand Up @@ -163,3 +165,5 @@ runPrecompileTests("eip-2537/map_fp2_to_G2_bls.json", eth_evm_bls12381_map_fp2_t
runPrecompileTests("eip-2537/fail-map_fp2_to_G2_bls.json", eth_evm_bls12381_map_fp2_to_g2, 256)

runPrecompileTests("eip-4844/pointEvaluation.json", eth_evm_kzg_point_evaluation, 64, true)

runPrecompileTests("ecRecover.json", eth_evm_ecrecover, 32)

0 comments on commit 664d985

Please sign in to comment.