keys: make public key's IsInfinity() public
It's gonna be used in interops for key validity check.
This commit is contained in:
parent
c5a4cfaebe
commit
7ab58ff8cb
1 changed files with 4 additions and 4 deletions
|
@ -61,7 +61,7 @@ func NewPublicKeyFromString(s string) (*PublicKey, error) {
|
||||||
|
|
||||||
// Bytes returns the byte array representation of the public key.
|
// Bytes returns the byte array representation of the public key.
|
||||||
func (p *PublicKey) Bytes() []byte {
|
func (p *PublicKey) Bytes() []byte {
|
||||||
if p.isInfinity() {
|
if p.IsInfinity() {
|
||||||
return []byte{0x00}
|
return []byte{0x00}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,14 +225,14 @@ func (p *PublicKey) Verify(signature []byte, hash []byte) bool {
|
||||||
return ecdsa.Verify(publicKey, hash, rBytes, sBytes)
|
return ecdsa.Verify(publicKey, hash, rBytes, sBytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// isInfinity checks if point P is infinity on EllipticCurve ec.
|
// IsInfinity checks if the key is infinite (null, basically).
|
||||||
func (p *PublicKey) isInfinity() bool {
|
func (p *PublicKey) IsInfinity() bool {
|
||||||
return p.X == nil && p.Y == nil
|
return p.X == nil && p.Y == nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// String implements the Stringer interface.
|
// String implements the Stringer interface.
|
||||||
func (p *PublicKey) String() string {
|
func (p *PublicKey) String() string {
|
||||||
if p.isInfinity() {
|
if p.IsInfinity() {
|
||||||
return "00"
|
return "00"
|
||||||
}
|
}
|
||||||
bx := hex.EncodeToString(p.X.Bytes())
|
bx := hex.EncodeToString(p.X.Bytes())
|
||||||
|
|
Loading…
Reference in a new issue