diff --git a/keys/cryptostore/enc_storage.go b/keys/cryptostore/enc_storage.go index 70e212138..daeb220b5 100644 --- a/keys/cryptostore/enc_storage.go +++ b/keys/cryptostore/enc_storage.go @@ -24,7 +24,7 @@ func (es encryptedStorage) Put(name, pass string, key crypto.PrivKey) error { func (es encryptedStorage) Get(name, pass string) (crypto.PrivKey, keys.Info, error) { secret, info, err := es.store.Get(name) if err != nil { - return nil, info, err + return crypto.PrivKey{}, info, err } key, err := es.coder.Decrypt(secret, pass) return key, info, err @@ -44,6 +44,6 @@ func info(name string, key crypto.PrivKey) keys.Info { return keys.Info{ Name: name, Address: pub.Address(), - PubKey: crypto.PubKeyS{pub}, + PubKey: pub, } } diff --git a/keys/cryptostore/encoder.go b/keys/cryptostore/encoder.go index 03bc1e4e8..12792813c 100644 --- a/keys/cryptostore/encoder.go +++ b/keys/cryptostore/encoder.go @@ -37,7 +37,7 @@ func (e secretbox) Decrypt(data []byte, pass string) (crypto.PrivKey, error) { s := secret(pass) private, err := crypto.DecryptSymmetric(data, s) if err != nil { - return nil, errors.Wrap(err, "Invalid Passphrase") + return crypto.PrivKey{}, errors.Wrap(err, "Invalid Passphrase") } key, err := crypto.PrivKeyFromBytes(private) return key, errors.Wrap(err, "Invalid Passphrase") diff --git a/keys/cryptostore/encoder_test.go b/keys/cryptostore/encoder_test.go index 0535737d7..e5ea21111 100644 --- a/keys/cryptostore/encoder_test.go +++ b/keys/cryptostore/encoder_test.go @@ -50,7 +50,7 @@ func TestSecretBox(t *testing.T) { // decoding with a different pass is an error pk, err := enc.Decrypt(b, "decode") require.NotNil(err) - require.Nil(pk) + require.True(pk.Empty()) // but decoding with the same passphrase gets us our key pk, err = enc.Decrypt(b, pass) diff --git a/keys/cryptostore/generator.go b/keys/cryptostore/generator.go index cf877f20b..6bbdb6441 100644 --- a/keys/cryptostore/generator.go +++ b/keys/cryptostore/generator.go @@ -25,11 +25,11 @@ func (f GenFunc) Generate() crypto.PrivKey { } func genEd25519() crypto.PrivKey { - return crypto.GenPrivKeyEd25519() + return crypto.GenPrivKeyEd25519().Wrap() } func genSecp256() crypto.PrivKey { - return crypto.GenPrivKeySecp256k1() + return crypto.GenPrivKeySecp256k1().Wrap() } func getGenerator(algo string) (Generator, error) { diff --git a/keys/server/helpers.go b/keys/server/helpers.go index 954922060..710e4f392 100644 --- a/keys/server/helpers.go +++ b/keys/server/helpers.go @@ -12,7 +12,7 @@ import ( "io/ioutil" "net/http" - data "github.com/tendermint/go-data" + data "github.com/tendermint/go-wire/data" "github.com/tendermint/go-crypto/keys/server/types" "github.com/pkg/errors" diff --git a/keys/storage/filestorage/main.go b/keys/storage/filestorage/main.go index 1add482e2..696b200fc 100644 --- a/keys/storage/filestorage/main.go +++ b/keys/storage/filestorage/main.go @@ -135,7 +135,7 @@ func readInfo(path string) (info keys.Info, err error) { return } pk, err := crypto.PubKeyFromBytes(data) - info.PubKey = crypto.PubKeyS{pk} + info.PubKey = pk return } diff --git a/keys/storage/filestorage/main_test.go b/keys/storage/filestorage/main_test.go index c569eb6f9..28c950c2c 100644 --- a/keys/storage/filestorage/main_test.go +++ b/keys/storage/filestorage/main_test.go @@ -25,7 +25,7 @@ func TestBasicCRUD(t *testing.T) { pubkey := crypto.GenPrivKeyEd25519().PubKey() info := keys.Info{ Name: name, - PubKey: crypto.PubKeyS{pubkey}, + PubKey: pubkey.Wrap(), } // No data: Get and Delete return nothing diff --git a/keys/storage/memstorage/main_test.go b/keys/storage/memstorage/main_test.go index 8bc7e355f..feccb387f 100644 --- a/keys/storage/memstorage/main_test.go +++ b/keys/storage/memstorage/main_test.go @@ -17,7 +17,7 @@ func TestBasicCRUD(t *testing.T) { pubkey := crypto.GenPrivKeyEd25519().PubKey() info := keys.Info{ Name: name, - PubKey: crypto.PubKeyS{pubkey}, + PubKey: pubkey, } // No data: Get and Delete return nothing diff --git a/keys/transactions.go b/keys/transactions.go index 91dc0e273..aafb77873 100644 --- a/keys/transactions.go +++ b/keys/transactions.go @@ -4,14 +4,14 @@ import ( "sort" crypto "github.com/tendermint/go-crypto" - data "github.com/tendermint/go-data" + data "github.com/tendermint/go-wire/data" ) // Info is the public information about a key type Info struct { Name string `json:"name"` Address data.Bytes `json:"address"` - PubKey crypto.PubKeyS `json:"pubkey"` + PubKey crypto.PubKey `json:"pubkey"` } func (i *Info) Format() Info { diff --git a/keys/tx/multi.go b/keys/tx/multi.go index eac86b010..f069fb273 100644 --- a/keys/tx/multi.go +++ b/keys/tx/multi.go @@ -3,7 +3,7 @@ package tx import ( "github.com/pkg/errors" crypto "github.com/tendermint/go-crypto" - data "github.com/tendermint/go-data" + data "github.com/tendermint/go-wire/data" ) // MultiSig lets us wrap arbitrary data with a go-crypto signature @@ -16,8 +16,8 @@ type MultiSig struct { } type Signed struct { - Sig crypto.SignatureS - Pubkey crypto.PubKeyS + Sig crypto.Signature + Pubkey crypto.PubKey } var _ SigInner = &MultiSig{} @@ -36,12 +36,12 @@ func (s *MultiSig) SignBytes() []byte { // Depending on the Signable, one may be able to call this multiple times for multisig // Returns error if called with invalid data or too many times func (s *MultiSig) Sign(pubkey crypto.PubKey, sig crypto.Signature) error { - if pubkey == nil || sig == nil { + if pubkey.Empty() || sig.Empty() { return errors.New("Signature or Key missing") } // set the value once we are happy - x := Signed{crypto.SignatureS{sig}, crypto.PubKeyS{pubkey}} + x := Signed{sig, pubkey} s.Sigs = append(s.Sigs, x) return nil } diff --git a/keys/tx/one.go b/keys/tx/one.go index 0ad61dd50..af468cc2c 100644 --- a/keys/tx/one.go +++ b/keys/tx/one.go @@ -3,7 +3,7 @@ package tx import ( "github.com/pkg/errors" crypto "github.com/tendermint/go-crypto" - data "github.com/tendermint/go-data" + data "github.com/tendermint/go-wire/data" ) // OneSig lets us wrap arbitrary data with a go-crypto signature @@ -31,7 +31,7 @@ func (s *OneSig) SignBytes() []byte { // Depending on the Signable, one may be able to call this multiple times for multisig // Returns error if called with invalid data or too many times func (s *OneSig) Sign(pubkey crypto.PubKey, sig crypto.Signature) error { - if pubkey == nil || sig == nil { + if pubkey.Empty() || sig.Empty() { return errors.New("Signature or Key missing") } if !s.Sig.Empty() { @@ -39,8 +39,7 @@ func (s *OneSig) Sign(pubkey crypto.PubKey, sig crypto.Signature) error { } // set the value once we are happy - s.Pubkey = crypto.PubKeyS{pubkey} - s.Sig = crypto.SignatureS{sig} + s.Signed = Signed{sig, pubkey} return nil } diff --git a/keys/tx/reader.go b/keys/tx/reader.go index 16a403719..265e88b46 100644 --- a/keys/tx/reader.go +++ b/keys/tx/reader.go @@ -2,8 +2,8 @@ package tx import ( crypto "github.com/tendermint/go-crypto" - data "github.com/tendermint/go-data" keys "github.com/tendermint/go-crypto/keys" + data "github.com/tendermint/go-wire/data" ) const ( @@ -18,8 +18,8 @@ var TxMapper data.Mapper func init() { TxMapper = data.NewMapper(Sig{}). - RegisterInterface(&OneSig{}, nameOneSig, typeOneSig). - RegisterInterface(&MultiSig{}, nameMultiSig, typeMultiSig) + RegisterImplementation(&OneSig{}, nameOneSig, typeOneSig). + RegisterImplementation(&MultiSig{}, nameMultiSig, typeMultiSig) } /* diff --git a/keys/tx/reader_test.go b/keys/tx/reader_test.go index 4b365604d..c50481f14 100644 --- a/keys/tx/reader_test.go +++ b/keys/tx/reader_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" crypto "github.com/tendermint/go-crypto" - data "github.com/tendermint/go-data" + data "github.com/tendermint/go-wire/data" "github.com/tendermint/go-crypto/keys/cryptostore" "github.com/tendermint/go-crypto/keys/storage/memstorage" )