aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/signature_nocgo.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@users.noreply.github.com>2017-12-15 17:40:09 +0800
committerGitHub <noreply@github.com>2017-12-15 17:40:09 +0800
commitc6069a627c42c21fc02d0770d39db9a9be45b180 (patch)
tree45b43eef0ead6f3bf83e0f0bec1c48b02eefc374 /crypto/signature_nocgo.go
parent1f2176dedc369f31f77927c2743b64868bf26b3e (diff)
downloaddexon-c6069a627c42c21fc02d0770d39db9a9be45b180.tar
dexon-c6069a627c42c21fc02d0770d39db9a9be45b180.tar.gz
dexon-c6069a627c42c21fc02d0770d39db9a9be45b180.tar.bz2
dexon-c6069a627c42c21fc02d0770d39db9a9be45b180.tar.lz
dexon-c6069a627c42c21fc02d0770d39db9a9be45b180.tar.xz
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_nocgo.go')
-rw-r--r--crypto/signature_nocgo.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/crypto/signature_nocgo.go b/crypto/signature_nocgo.go
index 17fd613b2..78b99c02b 100644
--- a/crypto/signature_nocgo.go
+++ b/crypto/signature_nocgo.go
@@ -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()