keys: make public key's IsInfinity() public

It's gonna be used in interops for key validity check.
This commit is contained in:
Roman Khimov 2019-10-10 18:40:16 +03:00
parent c5a4cfaebe
commit 7ab58ff8cb

View file

@ -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())