From 7ab58ff8cbd1023e6fc25a1a1d03f7d98e75194b Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Thu, 10 Oct 2019 18:40:16 +0300 Subject: [PATCH] keys: make public key's IsInfinity() public It's gonna be used in interops for key validity check. --- pkg/crypto/keys/publickey.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/crypto/keys/publickey.go b/pkg/crypto/keys/publickey.go index e12b9e327..b8f039de9 100644 --- a/pkg/crypto/keys/publickey.go +++ b/pkg/crypto/keys/publickey.go @@ -61,7 +61,7 @@ func NewPublicKeyFromString(s string) (*PublicKey, error) { // Bytes returns the byte array representation of the public key. func (p *PublicKey) Bytes() []byte { - if p.isInfinity() { + if p.IsInfinity() { return []byte{0x00} } @@ -225,14 +225,14 @@ func (p *PublicKey) Verify(signature []byte, hash []byte) bool { return ecdsa.Verify(publicKey, hash, rBytes, sBytes) } -// isInfinity checks if point P is infinity on EllipticCurve ec. -func (p *PublicKey) isInfinity() bool { +// IsInfinity checks if the key is infinite (null, basically). +func (p *PublicKey) IsInfinity() bool { return p.X == nil && p.Y == nil } // String implements the Stringer interface. func (p *PublicKey) String() string { - if p.isInfinity() { + if p.IsInfinity() { return "00" } bx := hex.EncodeToString(p.X.Bytes())