fix ecrecover bad V, GST +1

This commit is contained in:
andri lim 2019-03-18 19:28:42 +07:00
parent aed0db2d03
commit 7198ce2d05
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
3 changed files with 9 additions and 6 deletions

View File

@ -853,7 +853,7 @@ OK: 0/96 Fail: 0/96 Skip: 96/96
+ CALLCODEEcrecoverR_prefixed0.json OK
+ CALLCODEEcrecoverS_prefixed0.json OK
+ CALLCODEEcrecoverV_prefixed0.json OK
CALLCODEEcrecoverV_prefixedf0.json Skip
+ CALLCODEEcrecoverV_prefixedf0.json OK
+ CALLCODEIdentitiy_0.json OK
+ CALLCODEIdentitiy_1.json OK
+ CALLCODEIdentity_1_nonzeroValue.json OK
@ -933,7 +933,7 @@ OK: 0/96 Fail: 0/96 Skip: 96/96
modexp_0_0_0_25000.json Skip
modexp_0_0_0_35000.json Skip
```
OK: 88/94 Fail: 0/94 Skip: 6/94
OK: 89/94 Fail: 0/94 Skip: 5/94
## stQuadraticComplexityTest
```diff
Call1MB1024Calldepth.json Skip
@ -2520,4 +2520,4 @@ OK: 0/133 Fail: 0/133 Skip: 133/133
OK: 0/130 Fail: 0/130 Skip: 130/130
---TOTAL---
OK: 1424/2334 Fail: 0/2334 Skip: 910/2334
OK: 1425/2334 Fail: 0/2334 Skip: 909/2334

View File

@ -27,8 +27,12 @@ proc getSignature*(computation: BaseComputation): (array[32, byte], Signature) =
# Copy message data to buffer
# Note that we need to rearrange to R, S, V
bytes[0..63] = data[64..127]
let v = data[63] # TODO: Endian
if v.int notin 27..28:
var VOK = true
let v = data[63]
for x in 32..<63:
if data[x] != 0: VOK = false
VOK = VOK and v.int in 27..28
if not VOK:
raise newException(ValidationError, "Invalid V in getSignature")
bytes[64] = v - 27

View File

@ -13,7 +13,6 @@
# being mostly used for short-term regression prevention.
func allowedFailingGeneralStateTest*(folder, name: string): bool =
let allowedFailingGeneralStateTests = @[
"CALLCODEEcrecoverV_prefixedf0.json",
"randomStatetest14.json",
"randomStatetest85.json",
"tx_e1c174e2.json",