Skip to content

Commit

Permalink
Merge pull request #225 from 0xPolygonHermez/fix-fnecdivtwo-value
Browse files Browse the repository at this point in the history
fix FNEC_DIV_TWO constant and update test
  • Loading branch information
krlosMata committed Jan 11, 2023
2 parents bf6b6c5 + 68c10f1 commit 14c5ca7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion main/ecrecover/constEc.zkasm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CONSTL %FPEC = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2Fn
CONSTL %FPEC_MINUS_ONE = %FPEC - 1
CONSTL %FNEC_DIV_TWO = 57896044618658097711785492504343953926418782139537452191302581570759080747169n
CONSTL %FNEC_DIV_TWO = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0n
CONSTL %FPEC_C2_256 = 0x1000003D1n
CONSTL %FPEC_NON_SQRT = (1n << 256n) - 1n

Expand Down
15 changes: 13 additions & 2 deletions test/ecrecover.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -329,15 +329,26 @@ repeat_ecrecover_test:
:CALL(ecrecover_tx)
0x0000000000000000000000000000000000000000n :ASSERT

; #34 s == field/2 + 1. Valid
; #34 s == field/2 + 1. Valid (precompiled)

0x456e9aea5e197a1f1af7a3e85a3212fa4049a3ba34c2289b4c860fc0b0c64ef3n => A
0x9242685bf161793cc25603c231bc2f568eb630ea16aa137d2664ac8038825608n => B
0x7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a1n => C
0x1cn => D
:CALL(ecrecover_tx)
:CALL(ecrecover_precompiled)
0x4ef445CADd8bEe8A02bc79b30A97e6Fe3AE3B7a3n :ASSERT

; #34' s == field/2 + 1. Invalid (tx)

0x456e9aea5e197a1f1af7a3e85a3212fa4049a3ba34c2289b4c860fc0b0c64ef3n => A
0x9242685bf161793cc25603c231bc2f568eb630ea16aa137d2664ac8038825608n => B
0x7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a1n => C
0x1cn => D
:CALL(ecrecover_tx)
0n :ASSERT
B => A
4n :ASSERT

; #35 s == field/2. Valid

0x456e9aea5e197a1f1af7a3e85a3212fa4049a3ba34c2289b4c860fc0b0c64ef3n => A
Expand Down

0 comments on commit 14c5ca7

Please sign in to comment.