@@ -47,24 +47,24 @@ func SigToPub(hash, sig []byte) (*ecdsa.PublicKey, error) {
4747//
4848// This function is susceptible to chosen plaintext attacks that can leak
4949// 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
5151// solution is to hash any input before calculating the signature.
5252//
5353// 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 ))
5757 }
5858 seckey := math .PaddedBigBytes (prv .D , prv .Params ().BitSize / 8 )
5959 defer zeroBytes (seckey )
60- return secp256k1 .Sign (hash , seckey )
60+ return secp256k1 .Sign (digestHash , seckey )
6161}
6262
63- // VerifySignature checks that the given public key created signature over hash .
63+ // VerifySignature checks that the given public key created signature over digest .
6464// The public key should be in compressed (33 bytes) or uncompressed (65 bytes) format.
6565// 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 )
6868}
6969
7070// DecompressPubkey parses a public key in the 33-byte compressed format.
0 commit comments