Add Serialize method to PrivateKey.
ok @davecgh
This commit is contained in:
parent
77c02f36ee
commit
cea5e44f2d
1 changed files with 10 additions and 0 deletions
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 a new issue