crypto, crypto/secp256k1: add CompressPubkey (#15626)

This adds the inverse to DecompressPubkey and improves a few minor
details in crypto/secp256k1.
This commit is contained in:
Felix Lange
2017-12-15 10:40:09 +01:00
committed by GitHub
parent 1f2176dedc
commit c6069a627c
6 changed files with 118 additions and 52 deletions

View File

@ -76,6 +76,11 @@ func DecompressPubkey(pubkey []byte) (*ecdsa.PublicKey, error) {
return &ecdsa.PublicKey{X: x, Y: y, Curve: S256()}, nil
}
// CompressPubkey encodes a public key to the 33-byte compressed format.
func CompressPubkey(pubkey *ecdsa.PublicKey) []byte {
return secp256k1.CompressPubkey(pubkey.X, pubkey.Y)
}
// S256 returns an instance of the secp256k1 curve.
func S256() elliptic.Curve {
return secp256k1.S256()