crypto: add SignatureLength constant and use it everywhere (#19996)

Original change by @jpeletier
This commit is contained in:
Felix Lange
2019-08-22 15:14:06 +02:00
committed by GitHub
parent b90cdbaa79
commit 54b271a86d
11 changed files with 46 additions and 33 deletions

View File

@ -34,6 +34,15 @@ import (
"golang.org/x/crypto/sha3"
)
//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.
const RecoveryIDOffset = 64
// DigestLength sets the signature digest exact length
const DigestLength = 32
var (
secp256k1N, _ = new(big.Int).SetString("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141", 16)
secp256k1halfN = new(big.Int).Div(secp256k1N, big.NewInt(2))