Browse Source

ReadSignature*

pull/1782/head
Jae Kwon 9 years ago
parent
commit
c121163635
1 changed files with 18 additions and 0 deletions
  1. +18
    -0
      signature.go

+ 18
- 0
signature.go View File

@ -40,6 +40,15 @@ func (sig SignatureEd25519) IsZero() bool { return len(sig) == 0 }
func (sig SignatureEd25519) String() string { return fmt.Sprintf("/%X.../", Fingerprint(sig[:])) }
func ReadSignatureEd25519(bz []byte) (SignatureEd25519, error) {
sig := struct{ Signature }{}
err := wire.ReadBinaryBytes(bz, &sig)
if err != nil {
return SignatureEd25519{}, err
}
return sig.Signature.(SignatureEd25519), nil
}
//-------------------------------------
// Implements Signature
@ -52,3 +61,12 @@ func (sig SignatureSecp256k1) Bytes() []byte {
func (sig SignatureSecp256k1) IsZero() bool { return len(sig) == 0 }
func (sig SignatureSecp256k1) String() string { return fmt.Sprintf("/%X.../", Fingerprint(sig[:])) }
func ReadSignatureSecp256k1(bz []byte) (SignatureSecp256k1, error) {
sig := struct{ Signature }{}
err := wire.ReadBinaryBytes(bz, &sig)
if err != nil {
return nil, err
}
return sig.Signature.(SignatureSecp256k1), nil
}

Loading…
Cancel
Save