diff --git a/encode_test.go b/encode_test.go index 8f2eebba..977cc64c 100644 --- a/encode_test.go +++ b/encode_test.go @@ -56,13 +56,13 @@ func TestKeyEncodings(t *testing.T) { }{ { privKey: PrivKeyS{GenPrivKeyEd25519()}, - keyType: PrivKeyTypeEd25519, - keyName: PrivKeyNameEd25519, + keyType: TypeEd25519, + keyName: NameEd25519, }, { privKey: PrivKeyS{GenPrivKeySecp256k1()}, - keyType: PrivKeyTypeSecp256k1, - keyName: PrivKeyNameSecp256k1, + keyType: TypeSecp256k1, + keyName: NameSecp256k1, }, } diff --git a/priv_key.go b/priv_key.go index 81edfb3f..54fa36a3 100644 --- a/priv_key.go +++ b/priv_key.go @@ -19,12 +19,12 @@ type PrivKey interface { Equals(PrivKey) bool } -// Types of PrivKey implementations +// Types of implementations const ( - PrivKeyTypeEd25519 = byte(0x01) - PrivKeyTypeSecp256k1 = byte(0x02) - PrivKeyNameEd25519 = "ed25519" - PrivKeyNameSecp256k1 = "secp256k1" + TypeEd25519 = byte(0x01) + TypeSecp256k1 = byte(0x02) + NameEd25519 = "ed25519" + NameSecp256k1 = "secp256k1" ) var privKeyMapper data.Mapper @@ -32,8 +32,8 @@ var privKeyMapper data.Mapper // register both private key types with go-data (and thus go-wire) func init() { privKeyMapper = data.NewMapper(PrivKeyS{}). - RegisterInterface(PrivKeyEd25519{}, PrivKeyNameEd25519, PrivKeyTypeEd25519). - RegisterInterface(PrivKeySecp256k1{}, PrivKeyNameSecp256k1, PrivKeyTypeSecp256k1) + RegisterInterface(PrivKeyEd25519{}, NameEd25519, TypeEd25519). + RegisterInterface(PrivKeySecp256k1{}, NameSecp256k1, TypeSecp256k1) } // PrivKeyS add json serialization to PrivKey diff --git a/pub_key.go b/pub_key.go index 77ce74a9..9067a036 100644 --- a/pub_key.go +++ b/pub_key.go @@ -21,21 +21,13 @@ type PubKey interface { Equals(PubKey) bool } -// Types of PubKey implementations -const ( - PubKeyTypeEd25519 = byte(0x01) - PubKeyTypeSecp256k1 = byte(0x02) - PubKeyNameEd25519 = "ed25519" - PubKeyNameSecp256k1 = "secp256k1" -) - var pubKeyMapper data.Mapper // register both public key types with go-data (and thus go-wire) func init() { pubKeyMapper = data.NewMapper(PubKeyS{}). - RegisterInterface(PubKeyEd25519{}, PubKeyNameEd25519, PubKeyTypeEd25519). - RegisterInterface(PubKeySecp256k1{}, PubKeyNameSecp256k1, PubKeyTypeSecp256k1) + RegisterInterface(PubKeyEd25519{}, NameEd25519, TypeEd25519). + RegisterInterface(PubKeySecp256k1{}, NameSecp256k1, TypeSecp256k1) } // PubKeyS add json serialization to PubKey @@ -76,7 +68,7 @@ func (pubKey PubKeyEd25519) Address() []byte { PanicCrisis(*err) } // append type byte - encodedPubkey := append([]byte{PubKeyTypeEd25519}, w.Bytes()...) + encodedPubkey := append([]byte{TypeEd25519}, w.Bytes()...) hasher := ripemd160.New() hasher.Write(encodedPubkey) // does not error return hasher.Sum(nil) @@ -153,7 +145,7 @@ func (pubKey PubKeySecp256k1) Address() []byte { PanicCrisis(*err) } // append type byte - encodedPubkey := append([]byte{PubKeyTypeSecp256k1}, w.Bytes()...) + encodedPubkey := append([]byte{TypeSecp256k1}, w.Bytes()...) hasher := ripemd160.New() hasher.Write(encodedPubkey) // does not error return hasher.Sum(nil) diff --git a/signature.go b/signature.go index 07635887..b5fc36bf 100644 --- a/signature.go +++ b/signature.go @@ -17,21 +17,13 @@ type Signature interface { Equals(Signature) bool } -// Types of Signature implementations -const ( - SignatureTypeEd25519 = byte(0x01) - SignatureTypeSecp256k1 = byte(0x02) - SignatureNameEd25519 = "ed25519" - SignatureNameSecp256k1 = "secp256k1" -) - var sigMapper data.Mapper // register both public key types with go-data (and thus go-wire) func init() { sigMapper = data.NewMapper(SignatureS{}). - RegisterInterface(SignatureEd25519{}, SignatureNameEd25519, SignatureTypeEd25519). - RegisterInterface(SignatureSecp256k1{}, SignatureNameSecp256k1, SignatureTypeSecp256k1) + RegisterInterface(SignatureEd25519{}, NameEd25519, TypeEd25519). + RegisterInterface(SignatureSecp256k1{}, NameSecp256k1, TypeSecp256k1) } // SignatureS add json serialization to Signature diff --git a/signature_test.go b/signature_test.go index e0e30b78..f6c8c37b 100644 --- a/signature_test.go +++ b/signature_test.go @@ -56,14 +56,14 @@ func TestSignatureEncodings(t *testing.T) { { privKey: PrivKeyS{GenPrivKeyEd25519()}, sigSize: ed25519.SignatureSize, - sigType: SignatureTypeEd25519, - sigName: SignatureNameEd25519, + sigType: TypeEd25519, + sigName: NameEd25519, }, { privKey: PrivKeyS{GenPrivKeySecp256k1()}, sigSize: 0, // unknown - sigType: SignatureTypeSecp256k1, - sigName: SignatureNameSecp256k1, + sigType: TypeSecp256k1, + sigName: NameSecp256k1, }, }