Browse Source

Fixed all imports in keys

pull/1782/head
Ethan Frey 8 years ago
parent
commit
91bd7efb7b
13 changed files with 24 additions and 25 deletions
  1. +2
    -2
      keys/cryptostore/enc_storage.go
  2. +1
    -1
      keys/cryptostore/encoder.go
  3. +1
    -1
      keys/cryptostore/encoder_test.go
  4. +2
    -2
      keys/cryptostore/generator.go
  5. +1
    -1
      keys/server/helpers.go
  6. +1
    -1
      keys/storage/filestorage/main.go
  7. +1
    -1
      keys/storage/filestorage/main_test.go
  8. +1
    -1
      keys/storage/memstorage/main_test.go
  9. +2
    -2
      keys/transactions.go
  10. +5
    -5
      keys/tx/multi.go
  11. +3
    -4
      keys/tx/one.go
  12. +3
    -3
      keys/tx/reader.go
  13. +1
    -1
      keys/tx/reader_test.go

+ 2
- 2
keys/cryptostore/enc_storage.go View File

@ -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,
}
}

+ 1
- 1
keys/cryptostore/encoder.go View File

@ -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")


+ 1
- 1
keys/cryptostore/encoder_test.go View File

@ -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)


+ 2
- 2
keys/cryptostore/generator.go View File

@ -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) {


+ 1
- 1
keys/server/helpers.go View File

@ -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"


+ 1
- 1
keys/storage/filestorage/main.go View File

@ -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
}


+ 1
- 1
keys/storage/filestorage/main_test.go View File

@ -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


+ 1
- 1
keys/storage/memstorage/main_test.go View File

@ -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


+ 2
- 2
keys/transactions.go View File

@ -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 {


+ 5
- 5
keys/tx/multi.go View File

@ -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
- 4
keys/tx/one.go View File

@ -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
}


+ 3
- 3
keys/tx/reader.go View File

@ -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)
}
/*


+ 1
- 1
keys/tx/reader_test.go View File

@ -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…
Cancel
Save