diff --git a/signature.go b/signature.go index e4921ccf7..40f269f34 100644 --- a/signature.go +++ b/signature.go @@ -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 +}