diff options
author | Felix Lange <fjl@users.noreply.github.com> | 2017-12-15 17:40:09 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-15 17:40:09 +0800 |
commit | c6069a627c42c21fc02d0770d39db9a9be45b180 (patch) | |
tree | 45b43eef0ead6f3bf83e0f0bec1c48b02eefc374 /crypto/signature_cgo.go | |
parent | 1f2176dedc369f31f77927c2743b64868bf26b3e (diff) | |
download | dexon-c6069a627c42c21fc02d0770d39db9a9be45b180.tar.gz dexon-c6069a627c42c21fc02d0770d39db9a9be45b180.tar.zst dexon-c6069a627c42c21fc02d0770d39db9a9be45b180.zip |
crypto, crypto/secp256k1: add CompressPubkey (#15626)
This adds the inverse to DecompressPubkey and improves a few minor
details in crypto/secp256k1.
Diffstat (limited to 'crypto/signature_cgo.go')
-rw-r--r-- | crypto/signature_cgo.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/crypto/signature_cgo.go b/crypto/signature_cgo.go index 381d8a1bb..340bfc221 100644 --- a/crypto/signature_cgo.go +++ b/crypto/signature_cgo.go @@ -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() |