mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-26 19:42:23 +00:00
keys: change Signature() and Address() to not return errors
As they never can return any real one.
This commit is contained in:
parent
483b875f4a
commit
5836ae6873
3 changed files with 8 additions and 15 deletions
|
@ -125,7 +125,7 @@ func (p *PrivateKey) Address() (string, error) {
|
|||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return pk.Address()
|
||||
return pk.Address(), nil
|
||||
}
|
||||
|
||||
// Signature creates the signature using the private key.
|
||||
|
@ -134,7 +134,7 @@ func (p *PrivateKey) Signature() ([]byte, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return pk.Signature()
|
||||
return pk.Signature(), nil
|
||||
}
|
||||
|
||||
// Sign signs arbitrary length data using the private key.
|
||||
|
|
|
@ -168,32 +168,25 @@ func (p *PublicKey) EncodeBinary(w io.Writer) error {
|
|||
return binary.Write(w, binary.LittleEndian, p.Bytes())
|
||||
}
|
||||
|
||||
func (p *PublicKey) Signature() ([]byte, error) {
|
||||
func (p *PublicKey) Signature() []byte {
|
||||
b := p.Bytes()
|
||||
b = append([]byte{0x21}, b...)
|
||||
b = append(b, 0xAC)
|
||||
|
||||
sig := hash.Hash160(b)
|
||||
|
||||
return sig.Bytes(), nil
|
||||
return sig.Bytes()
|
||||
}
|
||||
|
||||
func (p *PublicKey) Address() (string, error) {
|
||||
var (
|
||||
err error
|
||||
b []byte
|
||||
)
|
||||
if b, err = p.Signature(); err != nil {
|
||||
return "", err
|
||||
}
|
||||
func (p *PublicKey) Address() string {
|
||||
var b []byte = p.Signature()
|
||||
|
||||
b = append([]byte{0x17}, b...)
|
||||
|
||||
csum := hash.Checksum(b)
|
||||
b = append(b, csum...)
|
||||
|
||||
address := crypto.Base58Encode(b)
|
||||
return address, nil
|
||||
return address
|
||||
}
|
||||
|
||||
// Verify returns true if the signature is valid and corresponds
|
||||
|
|
|
@ -42,7 +42,7 @@ func TestDecodeFromString(t *testing.T) {
|
|||
func TestPubkeyToAddress(t *testing.T) {
|
||||
pubKey, err := NewPublicKeyFromString("031ee4e73a17d8f76dc02532e2620bcb12425b33c0c9f9694cc2caa8226b68cad4")
|
||||
assert.Nil(t, err)
|
||||
actual, _ := pubKey.Address()
|
||||
actual := pubKey.Address()
|
||||
expected := "AUpGsNCHzSimeMRVPQfhwrVdiUp8Q2N2Qx"
|
||||
assert.Equal(t, expected, actual)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue