MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / Sign

Method Sign

crypto/asymmetric/signature.go:77–94  ·  view source on GitHub ↗

Sign generates an ECDSA signature for the provided hash (which should be the result of hashing a larger message) using the private key. Produced signature is deterministic (same message and same key yield the same signature) and canonical in accordance with RFC6979 and BIP0062.

(hash []byte)

Source from the content-addressed store, hash-verified

75// a larger message) using the private key. Produced signature is deterministic (same message and
76// same key yield the same signature) and canonical in accordance with RFC6979 and BIP0062.
77func (private *PrivateKey) Sign(hash []byte) (*Signature, error) {
78 if len(hash) != 32 {
79 return nil, errors.New("only hash can be signed")
80 }
81 if BypassSignature {
82 return bypassS, nil
83 }
84 seckey := utils.PaddedBigBytes(private.D, private.Params().BitSize/8)
85 defer zeroBytes(seckey)
86 sb, e := secp256k1.Sign(hash, seckey)
87 s := &Signature{
88 R: new(big.Int).SetBytes(sb[:32]),
89 S: new(big.Int).SetBytes(sb[32:64]),
90 }
91 //s, e := (*ec.PrivateKey)(private).Sign(hash)
92
93 return (*Signature)(s), e
94}
95
96// Verify calls ecdsa.Verify to verify the signature of hash using the public key. It returns true
97// if the signature is valid, false otherwise.

Callers

nothing calls this directly

Calls 6

PaddedBigBytesFunction · 0.92
SignFunction · 0.92
zeroBytesFunction · 0.85
SetBytesMethod · 0.80
NewMethod · 0.65
ParamsMethod · 0.45

Tested by

no test coverage detected