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

@ -102,6 +102,11 @@ func DecompressPubkey(pubkey []byte) (*ecdsa.PublicKey, error) {
return key.ToECDSA(), nil
}
// CompressPubkey encodes a public key to the 33-byte compressed format.
func CompressPubkey(pubkey *ecdsa.PublicKey) []byte {
return (*btcec.PublicKey)(pubkey).SerializeCompressed()
}
// S256 returns an instance of the secp256k1 curve.
func S256() elliptic.Curve {
return btcec.S256()