keys/words

This commit is contained in:
Ethan Buchman
2017-12-30 16:46:58 -05:00
parent 1f8e66fdb3
commit f3f49c2362
12 changed files with 19 additions and 17 deletions
+5 -4
View File
@@ -8,6 +8,7 @@ import (
crypto "github.com/tendermint/go-crypto"
dbm "github.com/tendermint/tmlibs/db"
"github.com/tendermint/go-crypto/keys/words"
"github.com/tendermint/go-crypto/nano"
)
@@ -19,10 +20,10 @@ import (
// a full-featured key manager
type dbKeybase struct {
db dbm.DB
codec Codec
codec words.Codec
}
func New(db dbm.DB, codec Codec) dbKeybase {
func New(db dbm.DB, codec words.Codec) dbKeybase {
return dbKeybase{
db: db,
codec: codec,
@@ -214,7 +215,7 @@ func generate(algo string, secret []byte) (crypto.PrivKey, error) {
case crypto.NameSecp256k1:
return crypto.GenPrivKeySecp256k1FromSecret(secret).Wrap(), nil
case nano.NameLedgerEd25519:
return nano.NewPrivKeyLedgerEd25519Ed25519()
return nano.NewPrivKeyLedgerEd25519()
default:
err := errors.Errorf("Cannot generate keys for algorithm: %s", algo)
return crypto.PrivKey{}, err
@@ -228,7 +229,7 @@ func generateByType(typ byte, secret []byte) (crypto.PrivKey, error) {
case crypto.TypeSecp256k1:
return crypto.GenPrivKeySecp256k1FromSecret(secret).Wrap(), nil
case nano.TypeLedgerEd25519:
return nano.NewPrivKeyLedgerEd25519Ed25519()
return nano.NewPrivKeyLedgerEd25519()
default:
err := errors.Errorf("Cannot generate keys for algorithm: %X", typ)
return crypto.PrivKey{}, err
+8 -7
View File
@@ -13,6 +13,7 @@ import (
crypto "github.com/tendermint/go-crypto"
"github.com/tendermint/go-crypto/keys"
"github.com/tendermint/go-crypto/keys/words"
"github.com/tendermint/go-crypto/nano"
)
@@ -23,7 +24,7 @@ func TestKeyManagement(t *testing.T) {
// make the storage with reasonable defaults
cstore := keys.New(
dbm.NewMemDB(),
keys.MustLoadCodec("english"),
words.MustLoadCodec("english"),
)
algo := crypto.NameEd25519
@@ -91,7 +92,7 @@ func TestSignVerify(t *testing.T) {
// make the storage with reasonable defaults
cstore := keys.New(
dbm.NewMemDB(),
keys.MustLoadCodec("english"),
words.MustLoadCodec("english"),
)
algo := crypto.NameSecp256k1
@@ -165,7 +166,7 @@ func TestSignWithLedger(t *testing.T) {
// make the storage with reasonable defaults
cstore := keys.New(
dbm.NewMemDB(),
keys.MustLoadCodec("english"),
words.MustLoadCodec("english"),
)
n := "nano-s"
p := "hard2hack"
@@ -219,7 +220,7 @@ func TestImportUnencrypted(t *testing.T) {
// make the storage with reasonable defaults
cstore := keys.New(
dbm.NewMemDB(),
keys.MustLoadCodec("english"),
words.MustLoadCodec("english"),
)
key := crypto.GenPrivKeyEd25519FromSecret(cmn.RandBytes(16)).Wrap()
@@ -245,7 +246,7 @@ func TestAdvancedKeyManagement(t *testing.T) {
// make the storage with reasonable defaults
cstore := keys.New(
dbm.NewMemDB(),
keys.MustLoadCodec("english"),
words.MustLoadCodec("english"),
)
algo := crypto.NameSecp256k1
@@ -288,7 +289,7 @@ func TestSeedPhrase(t *testing.T) {
// make the storage with reasonable defaults
cstore := keys.New(
dbm.NewMemDB(),
keys.MustLoadCodec("english"),
words.MustLoadCodec("english"),
)
algo := crypto.NameEd25519
@@ -319,7 +320,7 @@ func ExampleNew() {
// Select the encryption and storage for your cryptostore
cstore := keys.New(
dbm.NewMemDB(),
keys.MustLoadCodec("english"),
words.MustLoadCodec("english"),
)
ed := crypto.NameEd25519
sec := crypto.NameSecp256k1
+1 -1
View File
@@ -1,4 +1,4 @@
package keys
package words
import (
"encoding/binary"
+1 -1
View File
@@ -1,4 +1,4 @@
package keys
package words
import (
"testing"
@@ -1,4 +1,4 @@
package keys
package words
import (
"math/big"
@@ -6,7 +6,7 @@ import (
"github.com/pkg/errors"
"github.com/tendermint/go-crypto/keys/wordlist"
"github.com/tendermint/go-crypto/keys/words/wordlist"
)
const BankSize = 2048
@@ -1,4 +1,4 @@
package keys
package words
import (
"testing"
@@ -1,4 +1,4 @@
package keys
package words
import (
"testing"