@ -12,11 +12,11 @@ import (
var cdc = amino . NewCodec ( )
var cdc = amino . NewCodec ( )
// rout eTable is used to map public key concrete types back
// to their amino rout es. This should eventually be handled
// nam eTable is used to map public key concrete types back
// to their registered amino nam es. This should eventually be handled
// by amino. Example usage:
// by amino. Example usage:
// routeTable[reflect.TypeOf(ed25519.PubKeyEd25519{})] = ed25519.PubKeyAminoRout e
var rout eTable = make ( map [ reflect . Type ] string , 3 )
// nameTable[reflect.TypeOf(ed25519.PubKeyEd25519{})] = ed25519.PubKeyAminoNam e
var nam eTable = make ( map [ reflect . Type ] string , 3 )
func init ( ) {
func init ( ) {
// NOTE: It's important that there be no conflicts here,
// NOTE: It's important that there be no conflicts here,
@ -29,16 +29,16 @@ func init() {
// TODO: Have amino provide a way to go from concrete struct to route directly.
// TODO: Have amino provide a way to go from concrete struct to route directly.
// Its currently a private API
// Its currently a private API
rout eTable[ reflect . TypeOf ( ed25519 . PubKeyEd25519 { } ) ] = ed25519 . PubKeyAminoRout e
rout eTable[ reflect . TypeOf ( secp256k1 . PubKeySecp256k1 { } ) ] = secp256k1 . PubKeyAminoRout e
rout eTable[ reflect . TypeOf ( & multisig . PubKeyMultisigThreshold { } ) ] = multisig . PubKeyMultisigThresholdAminoRoute
nam eTable[ reflect . TypeOf ( ed25519 . PubKeyEd25519 { } ) ] = ed25519 . PubKeyAminoNam e
nam eTable[ reflect . TypeOf ( secp256k1 . PubKeySecp256k1 { } ) ] = secp256k1 . PubKeyAminoNam e
nam eTable[ reflect . TypeOf ( multisig . PubKeyMultisigThreshold { } ) ] = multisig . PubKeyMultisigThresholdAminoRoute
}
}
// PubkeyAminoRout e returns the amino route of a pubkey
// PubkeyAminoNam e returns the amino route of a pubkey
// cdc is currently passed in, as eventually this will not be using
// cdc is currently passed in, as eventually this will not be using
// a package level codec.
// a package level codec.
func PubkeyAminoRout e ( cdc * amino . Codec , key crypto . PubKey ) ( string , bool ) {
route , found := rout eTable[ reflect . TypeOf ( key ) ]
func PubkeyAminoNam e ( cdc * amino . Codec , key crypto . PubKey ) ( string , bool ) {
route , found := nam eTable[ reflect . TypeOf ( key ) ]
return route , found
return route , found
}
}
@ -47,17 +47,17 @@ func RegisterAmino(cdc *amino.Codec) {
// These are all written here instead of
// These are all written here instead of
cdc . RegisterInterface ( ( * crypto . PubKey ) ( nil ) , nil )
cdc . RegisterInterface ( ( * crypto . PubKey ) ( nil ) , nil )
cdc . RegisterConcrete ( ed25519 . PubKeyEd25519 { } ,
cdc . RegisterConcrete ( ed25519 . PubKeyEd25519 { } ,
ed25519 . PubKeyAminoRout e , nil )
ed25519 . PubKeyAminoNam e , nil )
cdc . RegisterConcrete ( secp256k1 . PubKeySecp256k1 { } ,
cdc . RegisterConcrete ( secp256k1 . PubKeySecp256k1 { } ,
secp256k1 . PubKeyAminoRout e , nil )
secp256k1 . PubKeyAminoNam e , nil )
cdc . RegisterConcrete ( multisig . PubKeyMultisigThreshold { } ,
cdc . RegisterConcrete ( multisig . PubKeyMultisigThreshold { } ,
multisig . PubKeyMultisigThresholdAminoRoute , nil )
multisig . PubKeyMultisigThresholdAminoRoute , nil )
cdc . RegisterInterface ( ( * crypto . PrivKey ) ( nil ) , nil )
cdc . RegisterInterface ( ( * crypto . PrivKey ) ( nil ) , nil )
cdc . RegisterConcrete ( ed25519 . PrivKeyEd25519 { } ,
cdc . RegisterConcrete ( ed25519 . PrivKeyEd25519 { } ,
ed25519 . PrivKeyAminoRout e , nil )
ed25519 . PrivKeyAminoNam e , nil )
cdc . RegisterConcrete ( secp256k1 . PrivKeySecp256k1 { } ,
cdc . RegisterConcrete ( secp256k1 . PrivKeySecp256k1 { } ,
secp256k1 . PrivKeyAminoRout e , nil )
secp256k1 . PrivKeyAminoNam e , nil )
}
}
func PrivKeyFromBytes ( privKeyBytes [ ] byte ) ( privKey crypto . PrivKey , err error ) {
func PrivKeyFromBytes ( privKeyBytes [ ] byte ) ( privKey crypto . PrivKey , err error ) {