diff options
author | Felix Lange <fjl@twurst.com> | 2019-08-22 21:14:06 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-22 21:14:06 +0800 |
commit | 54b271a86dd748f3b0bcebeaf678dc34e0d6177a (patch) | |
tree | 0a24f87f9dde9144b956a6adc54ba72c18f5ccd3 /core | |
parent | b90cdbaa79cfe438aab0f1389d35980f3d38ec84 (diff) | |
download | go-tangerine-54b271a86dd748f3b0bcebeaf678dc34e0d6177a.tar go-tangerine-54b271a86dd748f3b0bcebeaf678dc34e0d6177a.tar.gz go-tangerine-54b271a86dd748f3b0bcebeaf678dc34e0d6177a.tar.bz2 go-tangerine-54b271a86dd748f3b0bcebeaf678dc34e0d6177a.tar.lz go-tangerine-54b271a86dd748f3b0bcebeaf678dc34e0d6177a.tar.xz go-tangerine-54b271a86dd748f3b0bcebeaf678dc34e0d6177a.tar.zst go-tangerine-54b271a86dd748f3b0bcebeaf678dc34e0d6177a.zip |
crypto: add SignatureLength constant and use it everywhere (#19996)
Original change by @jpeletier
Diffstat (limited to 'core')
-rw-r--r-- | core/genesis.go | 3 | ||||
-rw-r--r-- | core/types/transaction_signing.go | 6 |
2 files changed, 5 insertions, 4 deletions
diff --git a/core/genesis.go b/core/genesis.go index 87bab2520..5d6311b32 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -31,6 +31,7 @@ import ( "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" @@ -377,7 +378,7 @@ func DeveloperGenesisBlock(period uint64, faucet common.Address) *Genesis { // Assemble and return the genesis with the precompiles and faucet pre-funded return &Genesis{ Config: &config, - ExtraData: append(append(make([]byte, 32), faucet[:]...), make([]byte, 65)...), + ExtraData: append(append(make([]byte, 32), faucet[:]...), make([]byte, crypto.SignatureLength)...), GasLimit: 6283185, Difficulty: big.NewInt(1), Alloc: map[common.Address]GenesisAccount{ diff --git a/core/types/transaction_signing.go b/core/types/transaction_signing.go index 63132048e..842fedbd0 100644 --- a/core/types/transaction_signing.go +++ b/core/types/transaction_signing.go @@ -193,8 +193,8 @@ func (s FrontierSigner) Equal(s2 Signer) bool { // SignatureValues returns signature values. This signature // needs to be in the [R || S || V] format where V is 0 or 1. func (fs FrontierSigner) SignatureValues(tx *Transaction, sig []byte) (r, s, v *big.Int, err error) { - if len(sig) != 65 { - panic(fmt.Sprintf("wrong size for signature: got %d, want 65", len(sig))) + if len(sig) != crypto.SignatureLength { + panic(fmt.Sprintf("wrong size for signature: got %d, want %d", len(sig), crypto.SignatureLength)) } r = new(big.Int).SetBytes(sig[:32]) s = new(big.Int).SetBytes(sig[32:64]) @@ -229,7 +229,7 @@ func recoverPlain(sighash common.Hash, R, S, Vb *big.Int, homestead bool) (commo } // encode the signature in uncompressed format r, s := R.Bytes(), S.Bytes() - sig := make([]byte, 65) + sig := make([]byte, crypto.SignatureLength) copy(sig[32-len(r):32], r) copy(sig[64-len(s):64], s) sig[64] = V |