You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

62 lines
1.3 KiB

package account
import (
"errors"
"fmt"
"reflect"
"github.com/tendermint/go-ed25519"
. "github.com/tendermint/tendermint/binary"
. "github.com/tendermint/tendermint/common"
)
// Signature is a part of Txs and consensus Votes.
type Signature interface {
}
// Types of Signature implementations
const (
SignatureTypeEd25519 = byte(0x01)
)
//-------------------------------------
// for binary.readReflect
func SignatureDecoder(r Unreader, n *int64, err *error) interface{} {
switch t := PeekByte(r, n, err); t {
case SignatureTypeEd25519:
return ReadBinary(SignatureEd25519{}, r, n, err)
default:
*err = Errorf("Unknown Signature type %X", t)
return nil
}
}
var _ = RegisterType(&TypeInfo{
Type: reflect.TypeOf((*Signature)(nil)).Elem(),
Decoder: SignatureDecoder,
})
//-------------------------------------
// Implements Signature
type SignatureEd25519 struct {
Bytes []byte
}
func (sig SignatureEd25519) TypeByte() byte { return SignatureTypeEd25519 }
func (sig SignatureEd25519) ValidateBasic() error {
if len(sig.Bytes) != ed25519.SignatureSize {
return errors.New("Invalid SignatureEd25519 signature size")
}
return nil
}
func (sig SignatureEd25519) IsZero() bool {
return len(sig.Bytes) == 0
}
func (sig SignatureEd25519) String() string {
return fmt.Sprintf("%X", Fingerprint(sig.Bytes))
}