@@ -47,24 +47,24 @@ func SigToPub(hash, sig []byte) (*ecdsa.PublicKey, error) {
47
47
//
48
48
// This function is susceptible to chosen plaintext attacks that can leak
49
49
// information about the private key that is used for signing. Callers must
50
- // be aware that the given hash cannot be chosen by an adversery. Common
50
+ // be aware that the given digest cannot be chosen by an adversery. Common
51
51
// solution is to hash any input before calculating the signature.
52
52
//
53
53
// The produced signature is in the [R || S || V] format where V is 0 or 1.
54
- func Sign (hash []byte , prv * ecdsa.PrivateKey ) (sig []byte , err error ) {
55
- if len (hash ) != 32 {
56
- return nil , fmt .Errorf ("hash is required to be exactly 32 bytes (%d)" , len (hash ))
54
+ func Sign (digestHash []byte , prv * ecdsa.PrivateKey ) (sig []byte , err error ) {
55
+ if len (digestHash ) != DigestLength {
56
+ return nil , fmt .Errorf ("hash is required to be exactly %d bytes (%d)" , DigestLength , len (digestHash ))
57
57
}
58
58
seckey := math .PaddedBigBytes (prv .D , prv .Params ().BitSize / 8 )
59
59
defer zeroBytes (seckey )
60
- return secp256k1 .Sign (hash , seckey )
60
+ return secp256k1 .Sign (digestHash , seckey )
61
61
}
62
62
63
- // VerifySignature checks that the given public key created signature over hash .
63
+ // VerifySignature checks that the given public key created signature over digest .
64
64
// The public key should be in compressed (33 bytes) or uncompressed (65 bytes) format.
65
65
// The signature should have the 64 byte [R || S] format.
66
- func VerifySignature (pubkey , hash , signature []byte ) bool {
67
- return secp256k1 .VerifySignature (pubkey , hash , signature )
66
+ func VerifySignature (pubkey , digestHash , signature []byte ) bool {
67
+ return secp256k1 .VerifySignature (pubkey , digestHash , signature )
68
68
}
69
69
70
70
// DecompressPubkey parses a public key in the 33-byte compressed format.
0 commit comments