Fixed all imports in keys
This commit is contained in:
parent
0bfae964e1
commit
91bd7efb7b
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue