aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/crypto.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2016-02-19 21:41:57 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2016-02-19 21:41:57 +0800
commitf8d98f7fcd08bd2eff36d5366ac2a14b52255d57 (patch)
tree99111d4f80ee4c436c99813ef8ffe7a7b16ee8ce /crypto/crypto.go
parentc305005d831eccf9d65c7b55f817390d2334e666 (diff)
parent5b283663b40dbc06c56cc481ef90f4365ab85724 (diff)
downloadgo-tangerine-f8d98f7fcd08bd2eff36d5366ac2a14b52255d57.tar
go-tangerine-f8d98f7fcd08bd2eff36d5366ac2a14b52255d57.tar.gz
go-tangerine-f8d98f7fcd08bd2eff36d5366ac2a14b52255d57.tar.bz2
go-tangerine-f8d98f7fcd08bd2eff36d5366ac2a14b52255d57.tar.lz
go-tangerine-f8d98f7fcd08bd2eff36d5366ac2a14b52255d57.tar.xz
go-tangerine-f8d98f7fcd08bd2eff36d5366ac2a14b52255d57.tar.zst
go-tangerine-f8d98f7fcd08bd2eff36d5366ac2a14b52255d57.zip
Merge pull request #2116 from obscuren/homestead
core, core/vm: consensus changes necessary for the homestead release
Diffstat (limited to 'crypto/crypto.go')
-rw-r--r--crypto/crypto.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/crypto/crypto.go b/crypto/crypto.go
index 7d7623753..850be4da6 100644
--- a/crypto/crypto.go
+++ b/crypto/crypto.go
@@ -163,12 +163,21 @@ func GenerateKey() (*ecdsa.PrivateKey, error) {
return ecdsa.GenerateKey(secp256k1.S256(), rand.Reader)
}
-func ValidateSignatureValues(v byte, r, s *big.Int) bool {
+func ValidateSignatureValues(v byte, r, s *big.Int, homestead bool) bool {
if r.Cmp(common.Big1) < 0 || s.Cmp(common.Big1) < 0 {
return false
}
vint := uint32(v)
- if r.Cmp(secp256k1.N) < 0 && s.Cmp(secp256k1.N) < 0 && (vint == 27 || vint == 28) {
+ // reject upper range of s values (ECDSA malleability)
+ // see discussion in secp256k1/libsecp256k1/include/secp256k1.h
+ if homestead && s.Cmp(secp256k1.HalfN) > 0 {
+ return false
+ }
+ // Frontier: allow s to be in full N range
+ if s.Cmp(secp256k1.N) >= 0 {
+ return false
+ }
+ if r.Cmp(secp256k1.N) < 0 && (vint == 27 || vint == 28) {
return true
} else {
return false