mirror of
https://github.com/btcsuite/btcd.git
synced 2024-11-19 18:00:11 +01:00
Add Serialize method to PrivateKey.
ok @davecgh
This commit is contained in:
parent
77c02f36ee
commit
cea5e44f2d
10
privkey.go
10
privkey.go
@ -47,3 +47,13 @@ func (p *PrivateKey) Sign(hash []byte) (*Signature, error) {
|
||||
}
|
||||
return &Signature{R: r, S: s}, nil
|
||||
}
|
||||
|
||||
// PrivKeyBytesLen defines the length in bytes of a serialized private key.
|
||||
const PrivKeyBytesLen = 32
|
||||
|
||||
// Serialize returns the private key number d as a big-endian binary-encoded
|
||||
// number, padded to a length of 32 bytes.
|
||||
func (p *PrivateKey) Serialize() []byte {
|
||||
b := make([]byte, 0, PrivKeyBytesLen)
|
||||
return paddedAppend(PrivKeyBytesLen, b, p.ToECDSA().D.Bytes())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user