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

Function PrivKeyFromBytes

crypto/asymmetric/keypair.go:133–146  ·  view source on GitHub ↗

PrivKeyFromBytes returns a private and public key for `curve' based on the private key passed as an argument as a byte slice.

(pk []byte)

Source from the content-addressed store, hash-verified

131// PrivKeyFromBytes returns a private and public key for `curve' based on the private key passed
132// as an argument as a byte slice.
133func PrivKeyFromBytes(pk []byte) (*PrivateKey, *PublicKey) {
134 x, y := ec.S256().ScalarBaseMult(pk)
135
136 priv := &ecdsa.PrivateKey{
137 PublicKey: ecdsa.PublicKey{
138 Curve: ec.S256(),
139 X: x,
140 Y: y,
141 },
142 D: new(big.Int).SetBytes(pk),
143 }
144
145 return (*PrivateKey)(priv), (*PublicKey)(&priv.PublicKey)
146}
147
148// Serialize returns the private key number d as a big-endian binary-encoded number, padded to a
149// length of 32 bytes.

Callers 6

getCommKeysFunction · 0.92
DecodePrivateKeyFunction · 0.92
TestSaveLoadPrivateKeyFunction · 0.92
TestLoadPrivateKeyFunction · 0.92
TestSignFunction · 0.85
TestPrivateKey_SerializeFunction · 0.85

Calls 2

ScalarBaseMultMethod · 0.80
SetBytesMethod · 0.80

Tested by 5

getCommKeysFunction · 0.74
TestSaveLoadPrivateKeyFunction · 0.74
TestLoadPrivateKeyFunction · 0.74
TestSignFunction · 0.68
TestPrivateKey_SerializeFunction · 0.68