mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-12 12:51:22 +00:00
Fixed all imports in keys
This commit is contained in:
@ -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) {
|
func (es encryptedStorage) Get(name, pass string) (crypto.PrivKey, keys.Info, error) {
|
||||||
secret, info, err := es.store.Get(name)
|
secret, info, err := es.store.Get(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, info, err
|
return crypto.PrivKey{}, info, err
|
||||||
}
|
}
|
||||||
key, err := es.coder.Decrypt(secret, pass)
|
key, err := es.coder.Decrypt(secret, pass)
|
||||||
return key, info, err
|
return key, info, err
|
||||||
@ -44,6 +44,6 @@ func info(name string, key crypto.PrivKey) keys.Info {
|
|||||||
return keys.Info{
|
return keys.Info{
|
||||||
Name: name,
|
Name: name,
|
||||||
Address: pub.Address(),
|
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)
|
s := secret(pass)
|
||||||
private, err := crypto.DecryptSymmetric(data, s)
|
private, err := crypto.DecryptSymmetric(data, s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "Invalid Passphrase")
|
return crypto.PrivKey{}, errors.Wrap(err, "Invalid Passphrase")
|
||||||
}
|
}
|
||||||
key, err := crypto.PrivKeyFromBytes(private)
|
key, err := crypto.PrivKeyFromBytes(private)
|
||||||
return key, errors.Wrap(err, "Invalid Passphrase")
|
return key, errors.Wrap(err, "Invalid Passphrase")
|
||||||
|
@ -50,7 +50,7 @@ func TestSecretBox(t *testing.T) {
|
|||||||
// decoding with a different pass is an error
|
// decoding with a different pass is an error
|
||||||
pk, err := enc.Decrypt(b, "decode")
|
pk, err := enc.Decrypt(b, "decode")
|
||||||
require.NotNil(err)
|
require.NotNil(err)
|
||||||
require.Nil(pk)
|
require.True(pk.Empty())
|
||||||
|
|
||||||
// but decoding with the same passphrase gets us our key
|
// but decoding with the same passphrase gets us our key
|
||||||
pk, err = enc.Decrypt(b, pass)
|
pk, err = enc.Decrypt(b, pass)
|
||||||
|
@ -25,11 +25,11 @@ func (f GenFunc) Generate() crypto.PrivKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func genEd25519() crypto.PrivKey {
|
func genEd25519() crypto.PrivKey {
|
||||||
return crypto.GenPrivKeyEd25519()
|
return crypto.GenPrivKeyEd25519().Wrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
func genSecp256() crypto.PrivKey {
|
func genSecp256() crypto.PrivKey {
|
||||||
return crypto.GenPrivKeySecp256k1()
|
return crypto.GenPrivKeySecp256k1().Wrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
func getGenerator(algo string) (Generator, error) {
|
func getGenerator(algo string) (Generator, error) {
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"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/tendermint/go-crypto/keys/server/types"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
@ -135,7 +135,7 @@ func readInfo(path string) (info keys.Info, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
pk, err := crypto.PubKeyFromBytes(data)
|
pk, err := crypto.PubKeyFromBytes(data)
|
||||||
info.PubKey = crypto.PubKeyS{pk}
|
info.PubKey = pk
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ func TestBasicCRUD(t *testing.T) {
|
|||||||
pubkey := crypto.GenPrivKeyEd25519().PubKey()
|
pubkey := crypto.GenPrivKeyEd25519().PubKey()
|
||||||
info := keys.Info{
|
info := keys.Info{
|
||||||
Name: name,
|
Name: name,
|
||||||
PubKey: crypto.PubKeyS{pubkey},
|
PubKey: pubkey.Wrap(),
|
||||||
}
|
}
|
||||||
|
|
||||||
// No data: Get and Delete return nothing
|
// No data: Get and Delete return nothing
|
||||||
|
@ -17,7 +17,7 @@ func TestBasicCRUD(t *testing.T) {
|
|||||||
pubkey := crypto.GenPrivKeyEd25519().PubKey()
|
pubkey := crypto.GenPrivKeyEd25519().PubKey()
|
||||||
info := keys.Info{
|
info := keys.Info{
|
||||||
Name: name,
|
Name: name,
|
||||||
PubKey: crypto.PubKeyS{pubkey},
|
PubKey: pubkey,
|
||||||
}
|
}
|
||||||
|
|
||||||
// No data: Get and Delete return nothing
|
// No data: Get and Delete return nothing
|
||||||
|
@ -4,14 +4,14 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
crypto "github.com/tendermint/go-crypto"
|
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
|
// Info is the public information about a key
|
||||||
type Info struct {
|
type Info struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Address data.Bytes `json:"address"`
|
Address data.Bytes `json:"address"`
|
||||||
PubKey crypto.PubKeyS `json:"pubkey"`
|
PubKey crypto.PubKey `json:"pubkey"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Info) Format() Info {
|
func (i *Info) Format() Info {
|
||||||
|
@ -3,7 +3,7 @@ package tx
|
|||||||
import (
|
import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
crypto "github.com/tendermint/go-crypto"
|
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
|
// MultiSig lets us wrap arbitrary data with a go-crypto signature
|
||||||
@ -16,8 +16,8 @@ type MultiSig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Signed struct {
|
type Signed struct {
|
||||||
Sig crypto.SignatureS
|
Sig crypto.Signature
|
||||||
Pubkey crypto.PubKeyS
|
Pubkey crypto.PubKey
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ SigInner = &MultiSig{}
|
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
|
// 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
|
// Returns error if called with invalid data or too many times
|
||||||
func (s *MultiSig) Sign(pubkey crypto.PubKey, sig crypto.Signature) error {
|
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")
|
return errors.New("Signature or Key missing")
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the value once we are happy
|
// 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)
|
s.Sigs = append(s.Sigs, x)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package tx
|
|||||||
import (
|
import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
crypto "github.com/tendermint/go-crypto"
|
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
|
// 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
|
// 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
|
// Returns error if called with invalid data or too many times
|
||||||
func (s *OneSig) Sign(pubkey crypto.PubKey, sig crypto.Signature) error {
|
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")
|
return errors.New("Signature or Key missing")
|
||||||
}
|
}
|
||||||
if !s.Sig.Empty() {
|
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
|
// set the value once we are happy
|
||||||
s.Pubkey = crypto.PubKeyS{pubkey}
|
s.Signed = Signed{sig, pubkey}
|
||||||
s.Sig = crypto.SignatureS{sig}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@ package tx
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
crypto "github.com/tendermint/go-crypto"
|
crypto "github.com/tendermint/go-crypto"
|
||||||
data "github.com/tendermint/go-data"
|
|
||||||
keys "github.com/tendermint/go-crypto/keys"
|
keys "github.com/tendermint/go-crypto/keys"
|
||||||
|
data "github.com/tendermint/go-wire/data"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -18,8 +18,8 @@ var TxMapper data.Mapper
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
TxMapper = data.NewMapper(Sig{}).
|
TxMapper = data.NewMapper(Sig{}).
|
||||||
RegisterInterface(&OneSig{}, nameOneSig, typeOneSig).
|
RegisterImplementation(&OneSig{}, nameOneSig, typeOneSig).
|
||||||
RegisterInterface(&MultiSig{}, nameMultiSig, typeMultiSig)
|
RegisterImplementation(&MultiSig{}, nameMultiSig, typeMultiSig)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
crypto "github.com/tendermint/go-crypto"
|
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/cryptostore"
|
||||||
"github.com/tendermint/go-crypto/keys/storage/memstorage"
|
"github.com/tendermint/go-crypto/keys/storage/memstorage"
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user