From 70d818ec45a9e13a98eb4994e61124945b5772c2 Mon Sep 17 00:00:00 2001 From: ziggie Date: Tue, 10 Dec 2024 13:53:24 +0100 Subject: [PATCH] btcec: add deep copy method for public keys --- btcec/pubkey.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/btcec/pubkey.go b/btcec/pubkey.go index 2c3a5ccbef..aaa27c1b09 100644 --- a/btcec/pubkey.go +++ b/btcec/pubkey.go @@ -52,6 +52,13 @@ func NewPublicKey(x, y *FieldVal) *PublicKey { return secp.NewPublicKey(x, y) } +// CopyPublicKey returns a deep copy of the public key. +func CopyPublicKey(p *PublicKey) *PublicKey { + pk := secp.JacobianPoint{} + p.AsJacobian(&pk) + return secp.NewPublicKey(&pk.X, &pk.Y) +} + // SerializedKey is a type for representing a public key in its compressed // serialized form. //