Skip to content

Commit

Permalink
Merge pull request ethereum#2 from 0rac1e/symbiosis/master
Browse files Browse the repository at this point in the history
zksync fix V value in ValidateSignatureValues
  • Loading branch information
allush committed Apr 7, 2023
2 parents 0d8f2ba + 4def81b commit 504602b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 1 addition & 5 deletions core/types/transaction_marshalling.go
Expand Up @@ -148,11 +148,7 @@ func (t *Transaction) UnmarshalJSON(input []byte) error {
itx.S = (*big.Int)(dec.S)
withSignature := itx.V.Sign() != 0 || itx.R.Sign() != 0 || itx.S.Sign() != 0
if withSignature {
mayBeProtected := true
if byte(itx.V.Uint64()) < 27 {
mayBeProtected = false
}
if err := sanityCheckSignature(itx.V, itx.R, itx.S, mayBeProtected); err != nil {
if err := sanityCheckSignature(itx.V, itx.R, itx.S, true); err != nil {
return err
}
}
Expand Down
5 changes: 4 additions & 1 deletion crypto/crypto.go
Expand Up @@ -35,7 +35,7 @@ import (
"golang.org/x/crypto/sha3"
)

//SignatureLength indicates the byte length required to carry a signature with recovery id.
// SignatureLength indicates the byte length required to carry a signature with recovery id.
const SignatureLength = 64 + 1 // 64 bytes ECDSA signature + 1 byte recovery id

// RecoveryIDOffset points to the byte offset within the signature that contains the recovery id.
Expand Down Expand Up @@ -269,6 +269,9 @@ func ValidateSignatureValues(v byte, r, s *big.Int, homestead bool) bool {
return false
}
// Frontier: allow s to be in full N range
if v > 1 {
v = v + 27
}
return r.Cmp(secp256k1N) < 0 && s.Cmp(secp256k1N) < 0 && (v == 0 || v == 1)
}

Expand Down

0 comments on commit 504602b

Please sign in to comment.