crypto: Refactor to move files out of the top level directorypull/2022/head
@ -1,37 +0,0 @@ | |||
package crypto | |||
import ( | |||
amino "github.com/tendermint/go-amino" | |||
) | |||
var cdc = amino.NewCodec() | |||
func init() { | |||
// NOTE: It's important that there be no conflicts here, | |||
// as that would change the canonical representations, | |||
// and therefore change the address. | |||
// TODO: Add feature to go-amino to ensure that there | |||
// are no conflicts. | |||
RegisterAmino(cdc) | |||
} | |||
// RegisterAmino registers all crypto related types in the given (amino) codec. | |||
func RegisterAmino(cdc *amino.Codec) { | |||
cdc.RegisterInterface((*PubKey)(nil), nil) | |||
cdc.RegisterConcrete(PubKeyEd25519{}, | |||
"tendermint/PubKeyEd25519", nil) | |||
cdc.RegisterConcrete(PubKeySecp256k1{}, | |||
"tendermint/PubKeySecp256k1", nil) | |||
cdc.RegisterInterface((*PrivKey)(nil), nil) | |||
cdc.RegisterConcrete(PrivKeyEd25519{}, | |||
"tendermint/PrivKeyEd25519", nil) | |||
cdc.RegisterConcrete(PrivKeySecp256k1{}, | |||
"tendermint/PrivKeySecp256k1", nil) | |||
cdc.RegisterInterface((*Signature)(nil), nil) | |||
cdc.RegisterConcrete(SignatureEd25519{}, | |||
"tendermint/SignatureEd25519", nil) | |||
cdc.RegisterConcrete(SignatureSecp256k1{}, | |||
"tendermint/SignatureSecp256k1", nil) | |||
} |
@ -0,0 +1,36 @@ | |||
package crypto | |||
import ( | |||
cmn "github.com/tendermint/tendermint/libs/common" | |||
) | |||
type PrivKey interface { | |||
Bytes() []byte | |||
Sign(msg []byte) (Signature, error) | |||
PubKey() PubKey | |||
Equals(PrivKey) bool | |||
} | |||
// An address is a []byte, but hex-encoded even in JSON. | |||
// []byte leaves us the option to change the address length. | |||
// Use an alias so Unmarshal methods (with ptr receivers) are available too. | |||
type Address = cmn.HexBytes | |||
type PubKey interface { | |||
Address() Address | |||
Bytes() []byte | |||
VerifyBytes(msg []byte, sig Signature) bool | |||
Equals(PubKey) bool | |||
} | |||
type Signature interface { | |||
Bytes() []byte | |||
IsZero() bool | |||
Equals(Signature) bool | |||
} | |||
type Symmetric interface { | |||
Keygen() []byte | |||
Encrypt(plaintext []byte, secret []byte) (ciphertext []byte) | |||
Decrypt(ciphertext []byte, secret []byte) (plaintext []byte, err error) | |||
} |
@ -0,0 +1,253 @@ | |||
package ed25519 | |||
import ( | |||
"bytes" | |||
"crypto/subtle" | |||
"fmt" | |||
"github.com/tendermint/ed25519" | |||
"github.com/tendermint/ed25519/extra25519" | |||
amino "github.com/tendermint/go-amino" | |||
"github.com/tendermint/tendermint/crypto" | |||
"github.com/tendermint/tendermint/crypto/tmhash" | |||
cmn "github.com/tendermint/tendermint/libs/common" | |||
) | |||
//------------------------------------- | |||
var _ crypto.PrivKey = PrivKeyEd25519{} | |||
const ( | |||
Ed25519PrivKeyAminoRoute = "tendermint/PrivKeyEd25519" | |||
Ed25519PubKeyAminoRoute = "tendermint/PubKeyEd25519" | |||
Ed25519SignatureAminoRoute = "tendermint/SignatureEd25519" | |||
) | |||
var cdc = amino.NewCodec() | |||
func init() { | |||
// NOTE: It's important that there be no conflicts here, | |||
// as that would change the canonical representations, | |||
// and therefore change the address. | |||
// TODO: Add feature to go-amino to ensure that there | |||
// are no conflicts. | |||
cdc.RegisterInterface((*crypto.PubKey)(nil), nil) | |||
cdc.RegisterConcrete(PubKeyEd25519{}, | |||
Ed25519PubKeyAminoRoute, nil) | |||
cdc.RegisterInterface((*crypto.PrivKey)(nil), nil) | |||
cdc.RegisterConcrete(PrivKeyEd25519{}, | |||
Ed25519PrivKeyAminoRoute, nil) | |||
cdc.RegisterInterface((*crypto.Signature)(nil), nil) | |||
cdc.RegisterConcrete(SignatureEd25519{}, | |||
Ed25519SignatureAminoRoute, nil) | |||
} | |||
// PrivKeyEd25519 implements crypto.PrivKey. | |||
type PrivKeyEd25519 [64]byte | |||
// Bytes marshals the privkey using amino encoding. | |||
func (privKey PrivKeyEd25519) Bytes() []byte { | |||
return cdc.MustMarshalBinaryBare(privKey) | |||
} | |||
// Sign produces a signature on the provided message. | |||
func (privKey PrivKeyEd25519) Sign(msg []byte) (crypto.Signature, error) { | |||
privKeyBytes := [64]byte(privKey) | |||
signatureBytes := ed25519.Sign(&privKeyBytes, msg) | |||
return SignatureEd25519(*signatureBytes), nil | |||
} | |||
// PubKey gets the corresponding public key from the private key. | |||
func (privKey PrivKeyEd25519) PubKey() crypto.PubKey { | |||
privKeyBytes := [64]byte(privKey) | |||
initialized := false | |||
// If the latter 32 bytes of the privkey are all zero, compute the pubkey | |||
// otherwise privkey is initialized and we can use the cached value inside | |||
// of the private key. | |||
for _, v := range privKeyBytes[32:] { | |||
if v != 0 { | |||
initialized = true | |||
break | |||
} | |||
} | |||
if initialized { | |||
var pubkeyBytes [PubKeyEd25519Size]byte | |||
copy(pubkeyBytes[:], privKeyBytes[32:]) | |||
return PubKeyEd25519(pubkeyBytes) | |||
} | |||
pubBytes := *ed25519.MakePublicKey(&privKeyBytes) | |||
return PubKeyEd25519(pubBytes) | |||
} | |||
// Equals - you probably don't need to use this. | |||
// Runs in constant time based on length of the keys. | |||
func (privKey PrivKeyEd25519) Equals(other crypto.PrivKey) bool { | |||
if otherEd, ok := other.(PrivKeyEd25519); ok { | |||
return subtle.ConstantTimeCompare(privKey[:], otherEd[:]) == 1 | |||
} else { | |||
return false | |||
} | |||
} | |||
// ToCurve25519 takes a private key and returns its representation on | |||
// Curve25519. Curve25519 is birationally equivalent to Edwards25519, | |||
// which Ed25519 uses internally. This method is intended for use in | |||
// an X25519 Diffie Hellman key exchange. | |||
func (privKey PrivKeyEd25519) ToCurve25519() *[PubKeyEd25519Size]byte { | |||
keyCurve25519 := new([32]byte) | |||
privKeyBytes := [64]byte(privKey) | |||
extra25519.PrivateKeyToCurve25519(keyCurve25519, &privKeyBytes) | |||
return keyCurve25519 | |||
} | |||
// Generate deterministically derives a new priv-key bytes from key. | |||
// The privkey is generated as Sha256(amino_encode({privkey, index})) | |||
// Note that we append the public key to the private key, the same way | |||
// that golang/x/crypto/ed25519 does. See | |||
// https://github.com/tendermint/ed25519/blob/master/ed25519.go#L39 for | |||
// further details. | |||
func (privKey PrivKeyEd25519) Generate(index int) PrivKeyEd25519 { | |||
bz := cdc.MustMarshalBinaryBare(struct { | |||
PrivKey [64]byte | |||
Index int | |||
}{privKey, index}) | |||
newBytes := crypto.Sha256(bz) | |||
newKey := new([64]byte) | |||
copy(newKey[:32], newBytes) | |||
// ed25519.MakePublicKey(newKey) alters the last 32 bytes of newKey. | |||
// It places the pubkey in the last 32 bytes of newKey, and returns the | |||
// public key. | |||
ed25519.MakePublicKey(newKey) | |||
return PrivKeyEd25519(*newKey) | |||
} | |||
// GenPrivKey generates a new ed25519 private key. | |||
// It uses OS randomness in conjunction with the current global random seed | |||
// in tendermint/libs/common to generate the private key. | |||
func GenPrivKey() PrivKeyEd25519 { | |||
privKey := new([64]byte) | |||
copy(privKey[:32], crypto.CRandBytes(32)) | |||
// ed25519.MakePublicKey(privKey) alters the last 32 bytes of privKey. | |||
// It places the pubkey in the last 32 bytes of privKey, and returns the | |||
// public key. | |||
ed25519.MakePublicKey(privKey) | |||
return PrivKeyEd25519(*privKey) | |||
} | |||
// GenPrivKeyFromSecret hashes the secret with SHA2, and uses | |||
// that 32 byte output to create the private key. | |||
// NOTE: secret should be the output of a KDF like bcrypt, | |||
// if it's derived from user input. | |||
func GenPrivKeyFromSecret(secret []byte) PrivKeyEd25519 { | |||
privKey32 := crypto.Sha256(secret) // Not Ripemd160 because we want 32 bytes. | |||
privKey := new([64]byte) | |||
copy(privKey[:32], privKey32) | |||
// ed25519.MakePublicKey(privKey) alters the last 32 bytes of privKey. | |||
// It places the pubkey in the last 32 bytes of privKey, and returns the | |||
// public key. | |||
ed25519.MakePublicKey(privKey) | |||
return PrivKeyEd25519(*privKey) | |||
} | |||
//------------------------------------- | |||
var _ crypto.PubKey = PubKeyEd25519{} | |||
// PubKeyEd25519Size is the number of bytes in an Ed25519 signature. | |||
const PubKeyEd25519Size = 32 | |||
// PubKeyEd25519 implements crypto.PubKey for the Ed25519 signature scheme. | |||
type PubKeyEd25519 [PubKeyEd25519Size]byte | |||
// Address is the SHA256-20 of the raw pubkey bytes. | |||
func (pubKey PubKeyEd25519) Address() crypto.Address { | |||
return crypto.Address(tmhash.Sum(pubKey[:])) | |||
} | |||
// Bytes marshals the PubKey using amino encoding. | |||
func (pubKey PubKeyEd25519) Bytes() []byte { | |||
bz, err := cdc.MarshalBinaryBare(pubKey) | |||
if err != nil { | |||
panic(err) | |||
} | |||
return bz | |||
} | |||
func (pubKey PubKeyEd25519) VerifyBytes(msg []byte, sig_ crypto.Signature) bool { | |||
// make sure we use the same algorithm to sign | |||
sig, ok := sig_.(SignatureEd25519) | |||
if !ok { | |||
return false | |||
} | |||
pubKeyBytes := [PubKeyEd25519Size]byte(pubKey) | |||
sigBytes := [SignatureEd25519Size]byte(sig) | |||
return ed25519.Verify(&pubKeyBytes, msg, &sigBytes) | |||
} | |||
// ToCurve25519 takes a public key and returns its representation on | |||
// Curve25519. Curve25519 is birationally equivalent to Edwards25519, | |||
// which Ed25519 uses internally. This method is intended for use in | |||
// an X25519 Diffie Hellman key exchange. | |||
// | |||
// If there is an error, then this function returns nil. | |||
func (pubKey PubKeyEd25519) ToCurve25519() *[PubKeyEd25519Size]byte { | |||
keyCurve25519, pubKeyBytes := new([PubKeyEd25519Size]byte), [PubKeyEd25519Size]byte(pubKey) | |||
ok := extra25519.PublicKeyToCurve25519(keyCurve25519, &pubKeyBytes) | |||
if !ok { | |||
return nil | |||
} | |||
return keyCurve25519 | |||
} | |||
func (pubKey PubKeyEd25519) String() string { | |||
return fmt.Sprintf("PubKeyEd25519{%X}", pubKey[:]) | |||
} | |||
// nolint: golint | |||
func (pubKey PubKeyEd25519) Equals(other crypto.PubKey) bool { | |||
if otherEd, ok := other.(PubKeyEd25519); ok { | |||
return bytes.Equal(pubKey[:], otherEd[:]) | |||
} else { | |||
return false | |||
} | |||
} | |||
//------------------------------------- | |||
var _ crypto.Signature = SignatureEd25519{} | |||
// Size of an Edwards25519 signature. Namely the size of a compressed | |||
// Edwards25519 point, and a field element. Both of which are 32 bytes. | |||
const SignatureEd25519Size = 64 | |||
// SignatureEd25519 implements crypto.Signature | |||
type SignatureEd25519 [SignatureEd25519Size]byte | |||
func (sig SignatureEd25519) Bytes() []byte { | |||
bz, err := cdc.MarshalBinaryBare(sig) | |||
if err != nil { | |||
panic(err) | |||
} | |||
return bz | |||
} | |||
func (sig SignatureEd25519) IsZero() bool { return len(sig) == 0 } | |||
func (sig SignatureEd25519) String() string { return fmt.Sprintf("/%X.../", cmn.Fingerprint(sig[:])) } | |||
func (sig SignatureEd25519) Equals(other crypto.Signature) bool { | |||
if otherEd, ok := other.(SignatureEd25519); ok { | |||
return subtle.ConstantTimeCompare(sig[:], otherEd[:]) == 1 | |||
} else { | |||
return false | |||
} | |||
} | |||
func SignatureEd25519FromBytes(data []byte) crypto.Signature { | |||
var sig SignatureEd25519 | |||
copy(sig[:], data) | |||
return sig | |||
} |
@ -0,0 +1,41 @@ | |||
package ed25519_test | |||
import ( | |||
"testing" | |||
"github.com/stretchr/testify/assert" | |||
"github.com/stretchr/testify/require" | |||
"github.com/tendermint/tendermint/crypto" | |||
"github.com/tendermint/tendermint/crypto/ed25519" | |||
) | |||
func TestGeneratePrivKey(t *testing.T) { | |||
testPriv := ed25519.GenPrivKey() | |||
testGenerate := testPriv.Generate(1) | |||
signBytes := []byte("something to sign") | |||
pub := testGenerate.PubKey() | |||
sig, err := testGenerate.Sign(signBytes) | |||
assert.NoError(t, err) | |||
assert.True(t, pub.VerifyBytes(signBytes, sig)) | |||
} | |||
func TestSignAndValidateEd25519(t *testing.T) { | |||
privKey := ed25519.GenPrivKey() | |||
pubKey := privKey.PubKey() | |||
msg := crypto.CRandBytes(128) | |||
sig, err := privKey.Sign(msg) | |||
require.Nil(t, err) | |||
// Test the signature | |||
assert.True(t, pubKey.VerifyBytes(msg, sig)) | |||
// Mutate the signature, just one bit. | |||
// TODO: Replace this with a much better fuzzer, tendermint/ed25519/issues/10 | |||
sigEd := sig.(ed25519.SignatureEd25519) | |||
sigEd[7] ^= byte(0x01) | |||
sig = sigEd | |||
assert.False(t, pubKey.VerifyBytes(msg, sig)) | |||
} |
@ -0,0 +1,56 @@ | |||
package crypto | |||
import ( | |||
amino "github.com/tendermint/go-amino" | |||
"github.com/tendermint/tendermint/crypto" | |||
"github.com/tendermint/tendermint/crypto/ed25519" | |||
"github.com/tendermint/tendermint/crypto/secp256k1" | |||
) | |||
var cdc = amino.NewCodec() | |||
func init() { | |||
// NOTE: It's important that there be no conflicts here, | |||
// as that would change the canonical representations, | |||
// and therefore change the address. | |||
// TODO: Add feature to go-amino to ensure that there | |||
// are no conflicts. | |||
RegisterAmino(cdc) | |||
} | |||
// RegisterAmino registers all crypto related types in the given (amino) codec. | |||
func RegisterAmino(cdc *amino.Codec) { | |||
// These are all written here instead of | |||
cdc.RegisterInterface((*crypto.PubKey)(nil), nil) | |||
cdc.RegisterConcrete(ed25519.PubKeyEd25519{}, | |||
"tendermint/PubKeyEd25519", nil) | |||
cdc.RegisterConcrete(secp256k1.PubKeySecp256k1{}, | |||
"tendermint/PubKeySecp256k1", nil) | |||
cdc.RegisterInterface((*crypto.PrivKey)(nil), nil) | |||
cdc.RegisterConcrete(ed25519.PrivKeyEd25519{}, | |||
"tendermint/PrivKeyEd25519", nil) | |||
cdc.RegisterConcrete(secp256k1.PrivKeySecp256k1{}, | |||
"tendermint/PrivKeySecp256k1", nil) | |||
cdc.RegisterInterface((*crypto.Signature)(nil), nil) | |||
cdc.RegisterConcrete(ed25519.SignatureEd25519{}, | |||
"tendermint/SignatureEd25519", nil) | |||
cdc.RegisterConcrete(secp256k1.SignatureSecp256k1{}, | |||
"tendermint/SignatureSecp256k1", nil) | |||
} | |||
func PrivKeyFromBytes(privKeyBytes []byte) (privKey crypto.PrivKey, err error) { | |||
err = cdc.UnmarshalBinaryBare(privKeyBytes, &privKey) | |||
return | |||
} | |||
func PubKeyFromBytes(pubKeyBytes []byte) (pubKey crypto.PubKey, err error) { | |||
err = cdc.UnmarshalBinaryBare(pubKeyBytes, &pubKey) | |||
return | |||
} | |||
func SignatureFromBytes(pubKeyBytes []byte) (pubKey crypto.Signature, err error) { | |||
err = cdc.UnmarshalBinaryBare(pubKeyBytes, &pubKey) | |||
return | |||
} |
@ -1,164 +0,0 @@ | |||
package crypto | |||
import ( | |||
"crypto/subtle" | |||
secp256k1 "github.com/btcsuite/btcd/btcec" | |||
"github.com/tendermint/ed25519" | |||
"github.com/tendermint/ed25519/extra25519" | |||
) | |||
func PrivKeyFromBytes(privKeyBytes []byte) (privKey PrivKey, err error) { | |||
err = cdc.UnmarshalBinaryBare(privKeyBytes, &privKey) | |||
return | |||
} | |||
//---------------------------------------- | |||
type PrivKey interface { | |||
Bytes() []byte | |||
Sign(msg []byte) (Signature, error) | |||
PubKey() PubKey | |||
Equals(PrivKey) bool | |||
} | |||
//------------------------------------- | |||
var _ PrivKey = PrivKeyEd25519{} | |||
// Implements PrivKey | |||
type PrivKeyEd25519 [64]byte | |||
func (privKey PrivKeyEd25519) Bytes() []byte { | |||
return cdc.MustMarshalBinaryBare(privKey) | |||
} | |||
func (privKey PrivKeyEd25519) Sign(msg []byte) (Signature, error) { | |||
privKeyBytes := [64]byte(privKey) | |||
signatureBytes := ed25519.Sign(&privKeyBytes, msg) | |||
return SignatureEd25519(*signatureBytes), nil | |||
} | |||
func (privKey PrivKeyEd25519) PubKey() PubKey { | |||
privKeyBytes := [64]byte(privKey) | |||
pubBytes := *ed25519.MakePublicKey(&privKeyBytes) | |||
return PubKeyEd25519(pubBytes) | |||
} | |||
// Equals - you probably don't need to use this. | |||
// Runs in constant time based on length of the keys. | |||
func (privKey PrivKeyEd25519) Equals(other PrivKey) bool { | |||
if otherEd, ok := other.(PrivKeyEd25519); ok { | |||
return subtle.ConstantTimeCompare(privKey[:], otherEd[:]) == 1 | |||
} else { | |||
return false | |||
} | |||
} | |||
func (privKey PrivKeyEd25519) ToCurve25519() *[32]byte { | |||
keyCurve25519 := new([32]byte) | |||
privKeyBytes := [64]byte(privKey) | |||
extra25519.PrivateKeyToCurve25519(keyCurve25519, &privKeyBytes) | |||
return keyCurve25519 | |||
} | |||
// Deterministically generates new priv-key bytes from key. | |||
func (privKey PrivKeyEd25519) Generate(index int) PrivKeyEd25519 { | |||
bz, err := cdc.MarshalBinaryBare(struct { | |||
PrivKey [64]byte | |||
Index int | |||
}{privKey, index}) | |||
if err != nil { | |||
panic(err) | |||
} | |||
newBytes := Sha256(bz) | |||
newKey := new([64]byte) | |||
copy(newKey[:32], newBytes) | |||
ed25519.MakePublicKey(newKey) | |||
return PrivKeyEd25519(*newKey) | |||
} | |||
func GenPrivKeyEd25519() PrivKeyEd25519 { | |||
privKeyBytes := new([64]byte) | |||
copy(privKeyBytes[:32], CRandBytes(32)) | |||
ed25519.MakePublicKey(privKeyBytes) | |||
return PrivKeyEd25519(*privKeyBytes) | |||
} | |||
// NOTE: secret should be the output of a KDF like bcrypt, | |||
// if it's derived from user input. | |||
func GenPrivKeyEd25519FromSecret(secret []byte) PrivKeyEd25519 { | |||
privKey32 := Sha256(secret) // Not Ripemd160 because we want 32 bytes. | |||
privKeyBytes := new([64]byte) | |||
copy(privKeyBytes[:32], privKey32) | |||
ed25519.MakePublicKey(privKeyBytes) | |||
return PrivKeyEd25519(*privKeyBytes) | |||
} | |||
//------------------------------------- | |||
var _ PrivKey = PrivKeySecp256k1{} | |||
// Implements PrivKey | |||
type PrivKeySecp256k1 [32]byte | |||
func (privKey PrivKeySecp256k1) Bytes() []byte { | |||
return cdc.MustMarshalBinaryBare(privKey) | |||
} | |||
func (privKey PrivKeySecp256k1) Sign(msg []byte) (Signature, error) { | |||
priv__, _ := secp256k1.PrivKeyFromBytes(secp256k1.S256(), privKey[:]) | |||
sig__, err := priv__.Sign(Sha256(msg)) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return SignatureSecp256k1(sig__.Serialize()), nil | |||
} | |||
func (privKey PrivKeySecp256k1) PubKey() PubKey { | |||
_, pub__ := secp256k1.PrivKeyFromBytes(secp256k1.S256(), privKey[:]) | |||
var pub PubKeySecp256k1 | |||
copy(pub[:], pub__.SerializeCompressed()) | |||
return pub | |||
} | |||
// Equals - you probably don't need to use this. | |||
// Runs in constant time based on length of the keys. | |||
func (privKey PrivKeySecp256k1) Equals(other PrivKey) bool { | |||
if otherSecp, ok := other.(PrivKeySecp256k1); ok { | |||
return subtle.ConstantTimeCompare(privKey[:], otherSecp[:]) == 1 | |||
} else { | |||
return false | |||
} | |||
} | |||
/* | |||
// Deterministically generates new priv-key bytes from key. | |||
func (key PrivKeySecp256k1) Generate(index int) PrivKeySecp256k1 { | |||
newBytes := cdc.BinarySha256(struct { | |||
PrivKey [64]byte | |||
Index int | |||
}{key, index}) | |||
var newKey [64]byte | |||
copy(newKey[:], newBytes) | |||
return PrivKeySecp256k1(newKey) | |||
} | |||
*/ | |||
func GenPrivKeySecp256k1() PrivKeySecp256k1 { | |||
privKeyBytes := [32]byte{} | |||
copy(privKeyBytes[:], CRandBytes(32)) | |||
priv, _ := secp256k1.PrivKeyFromBytes(secp256k1.S256(), privKeyBytes[:]) | |||
copy(privKeyBytes[:], priv.Serialize()) | |||
return PrivKeySecp256k1(privKeyBytes) | |||
} | |||
// NOTE: secret should be the output of a KDF like bcrypt, | |||
// if it's derived from user input. | |||
func GenPrivKeySecp256k1FromSecret(secret []byte) PrivKeySecp256k1 { | |||
privKey32 := Sha256(secret) // Not Ripemd160 because we want 32 bytes. | |||
priv, _ := secp256k1.PrivKeyFromBytes(secp256k1.S256(), privKey32) | |||
privKeyBytes := [32]byte{} | |||
copy(privKeyBytes[:], priv.Serialize()) | |||
return PrivKeySecp256k1(privKeyBytes) | |||
} |
@ -1,60 +0,0 @@ | |||
package crypto_test | |||
import ( | |||
"testing" | |||
"github.com/stretchr/testify/assert" | |||
"github.com/tendermint/tendermint/crypto" | |||
) | |||
func TestGeneratePrivKey(t *testing.T) { | |||
testPriv := crypto.GenPrivKeyEd25519() | |||
testGenerate := testPriv.Generate(1) | |||
signBytes := []byte("something to sign") | |||
pub := testGenerate.PubKey() | |||
sig, err := testGenerate.Sign(signBytes) | |||
assert.NoError(t, err) | |||
assert.True(t, pub.VerifyBytes(signBytes, sig)) | |||
} | |||
/* | |||
type BadKey struct { | |||
PrivKeyEd25519 | |||
} | |||
func TestReadPrivKey(t *testing.T) { | |||
assert, require := assert.New(t), require.New(t) | |||
// garbage in, garbage out | |||
garbage := []byte("hjgewugfbiewgofwgewr") | |||
XXX This test wants to register BadKey globally to crypto, | |||
but we don't want to support that. | |||
_, err := PrivKeyFromBytes(garbage) | |||
require.Error(err) | |||
edKey := GenPrivKeyEd25519() | |||
badKey := BadKey{edKey} | |||
cases := []struct { | |||
key PrivKey | |||
valid bool | |||
}{ | |||
{edKey, true}, | |||
{badKey, false}, | |||
} | |||
for i, tc := range cases { | |||
data := tc.key.Bytes() | |||
fmt.Println(">>>", data) | |||
key, err := PrivKeyFromBytes(data) | |||
fmt.Printf("!!! %#v\n", key, err) | |||
if tc.valid { | |||
assert.NoError(err, "%d", i) | |||
assert.Equal(tc.key, key, "%d", i) | |||
} else { | |||
assert.Error(err, "%d: %#v", i, key) | |||
} | |||
} | |||
} | |||
*/ |
@ -1,153 +0,0 @@ | |||
package crypto | |||
import ( | |||
"bytes" | |||
"crypto/sha256" | |||
"fmt" | |||
"golang.org/x/crypto/ripemd160" | |||
secp256k1 "github.com/btcsuite/btcd/btcec" | |||
"github.com/tendermint/ed25519" | |||
"github.com/tendermint/ed25519/extra25519" | |||
cmn "github.com/tendermint/tendermint/libs/common" | |||
"github.com/tendermint/tendermint/crypto/tmhash" | |||
) | |||
// An address is a []byte, but hex-encoded even in JSON. | |||
// []byte leaves us the option to change the address length. | |||
// Use an alias so Unmarshal methods (with ptr receivers) are available too. | |||
type Address = cmn.HexBytes | |||
func PubKeyFromBytes(pubKeyBytes []byte) (pubKey PubKey, err error) { | |||
err = cdc.UnmarshalBinaryBare(pubKeyBytes, &pubKey) | |||
return | |||
} | |||
//---------------------------------------- | |||
type PubKey interface { | |||
Address() Address | |||
Bytes() []byte | |||
VerifyBytes(msg []byte, sig Signature) bool | |||
Equals(PubKey) bool | |||
} | |||
//------------------------------------- | |||
var _ PubKey = PubKeyEd25519{} | |||
const PubKeyEd25519Size = 32 | |||
// Implements PubKeyInner | |||
type PubKeyEd25519 [PubKeyEd25519Size]byte | |||
// Address is the SHA256-20 of the raw pubkey bytes. | |||
func (pubKey PubKeyEd25519) Address() Address { | |||
return Address(tmhash.Sum(pubKey[:])) | |||
} | |||
func (pubKey PubKeyEd25519) Bytes() []byte { | |||
bz, err := cdc.MarshalBinaryBare(pubKey) | |||
if err != nil { | |||
panic(err) | |||
} | |||
return bz | |||
} | |||
func (pubKey PubKeyEd25519) VerifyBytes(msg []byte, sig_ Signature) bool { | |||
// make sure we use the same algorithm to sign | |||
sig, ok := sig_.(SignatureEd25519) | |||
if !ok { | |||
return false | |||
} | |||
pubKeyBytes := [PubKeyEd25519Size]byte(pubKey) | |||
sigBytes := [SignatureEd25519Size]byte(sig) | |||
return ed25519.Verify(&pubKeyBytes, msg, &sigBytes) | |||
} | |||
// For use with golang/crypto/nacl/box | |||
// If error, returns nil. | |||
func (pubKey PubKeyEd25519) ToCurve25519() *[PubKeyEd25519Size]byte { | |||
keyCurve25519, pubKeyBytes := new([PubKeyEd25519Size]byte), [PubKeyEd25519Size]byte(pubKey) | |||
ok := extra25519.PublicKeyToCurve25519(keyCurve25519, &pubKeyBytes) | |||
if !ok { | |||
return nil | |||
} | |||
return keyCurve25519 | |||
} | |||
func (pubKey PubKeyEd25519) String() string { | |||
return fmt.Sprintf("PubKeyEd25519{%X}", pubKey[:]) | |||
} | |||
func (pubKey PubKeyEd25519) Equals(other PubKey) bool { | |||
if otherEd, ok := other.(PubKeyEd25519); ok { | |||
return bytes.Equal(pubKey[:], otherEd[:]) | |||
} else { | |||
return false | |||
} | |||
} | |||
//------------------------------------- | |||
var _ PubKey = PubKeySecp256k1{} | |||
const PubKeySecp256k1Size = 33 | |||
// Implements PubKey. | |||
// Compressed pubkey (just the x-cord), | |||
// prefixed with 0x02 or 0x03, depending on the y-cord. | |||
type PubKeySecp256k1 [PubKeySecp256k1Size]byte | |||
// Implements Bitcoin style addresses: RIPEMD160(SHA256(pubkey)) | |||
func (pubKey PubKeySecp256k1) Address() Address { | |||
hasherSHA256 := sha256.New() | |||
hasherSHA256.Write(pubKey[:]) // does not error | |||
sha := hasherSHA256.Sum(nil) | |||
hasherRIPEMD160 := ripemd160.New() | |||
hasherRIPEMD160.Write(sha) // does not error | |||
return Address(hasherRIPEMD160.Sum(nil)) | |||
} | |||
func (pubKey PubKeySecp256k1) Bytes() []byte { | |||
bz, err := cdc.MarshalBinaryBare(pubKey) | |||
if err != nil { | |||
panic(err) | |||
} | |||
return bz | |||
} | |||
func (pubKey PubKeySecp256k1) VerifyBytes(msg []byte, sig_ Signature) bool { | |||
// and assert same algorithm to sign and verify | |||
sig, ok := sig_.(SignatureSecp256k1) | |||
if !ok { | |||
return false | |||
} | |||
pub__, err := secp256k1.ParsePubKey(pubKey[:], secp256k1.S256()) | |||
if err != nil { | |||
return false | |||
} | |||
sig__, err := secp256k1.ParseDERSignature(sig[:], secp256k1.S256()) | |||
if err != nil { | |||
return false | |||
} | |||
return sig__.Verify(Sha256(msg), pub__) | |||
} | |||
func (pubKey PubKeySecp256k1) String() string { | |||
return fmt.Sprintf("PubKeySecp256k1{%X}", pubKey[:]) | |||
} | |||
func (pubKey PubKeySecp256k1) Equals(other PubKey) bool { | |||
if otherSecp, ok := other.(PubKeySecp256k1); ok { | |||
return bytes.Equal(pubKey[:], otherSecp[:]) | |||
} else { | |||
return false | |||
} | |||
} |
@ -0,0 +1,205 @@ | |||
package secp256k1 | |||
import ( | |||
"bytes" | |||
"crypto/sha256" | |||
"crypto/subtle" | |||
"fmt" | |||
secp256k1 "github.com/btcsuite/btcd/btcec" | |||
amino "github.com/tendermint/go-amino" | |||
"github.com/tendermint/tendermint/crypto" | |||
"github.com/tendermint/tendermint/libs/common" | |||
"golang.org/x/crypto/ripemd160" | |||
) | |||
//------------------------------------- | |||
const ( | |||
Secp256k1PrivKeyAminoRoute = "tendermint/PrivKeySecp256k1" | |||
Secp256k1PubKeyAminoRoute = "tendermint/PubKeySecp256k1" | |||
Secp256k1SignatureAminoRoute = "tendermint/SignatureSecp256k1" | |||
) | |||
var cdc = amino.NewCodec() | |||
func init() { | |||
// NOTE: It's important that there be no conflicts here, | |||
// as that would change the canonical representations, | |||
// and therefore change the address. | |||
// TODO: Add feature to go-amino to ensure that there | |||
// are no conflicts. | |||
cdc.RegisterInterface((*crypto.PubKey)(nil), nil) | |||
cdc.RegisterConcrete(PubKeySecp256k1{}, | |||
Secp256k1PubKeyAminoRoute, nil) | |||
cdc.RegisterInterface((*crypto.PrivKey)(nil), nil) | |||
cdc.RegisterConcrete(PrivKeySecp256k1{}, | |||
Secp256k1PrivKeyAminoRoute, nil) | |||
cdc.RegisterInterface((*crypto.Signature)(nil), nil) | |||
cdc.RegisterConcrete(SignatureSecp256k1{}, | |||
Secp256k1SignatureAminoRoute, nil) | |||
} | |||
//------------------------------------- | |||
var _ crypto.PrivKey = PrivKeySecp256k1{} | |||
// Implements PrivKey | |||
type PrivKeySecp256k1 [32]byte | |||
func (privKey PrivKeySecp256k1) Bytes() []byte { | |||
return cdc.MustMarshalBinaryBare(privKey) | |||
} | |||
func (privKey PrivKeySecp256k1) Sign(msg []byte) (crypto.Signature, error) { | |||
priv__, _ := secp256k1.PrivKeyFromBytes(secp256k1.S256(), privKey[:]) | |||
sig__, err := priv__.Sign(crypto.Sha256(msg)) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return SignatureSecp256k1(sig__.Serialize()), nil | |||
} | |||
func (privKey PrivKeySecp256k1) PubKey() crypto.PubKey { | |||
_, pub__ := secp256k1.PrivKeyFromBytes(secp256k1.S256(), privKey[:]) | |||
var pub PubKeySecp256k1 | |||
copy(pub[:], pub__.SerializeCompressed()) | |||
return pub | |||
} | |||
// Equals - you probably don't need to use this. | |||
// Runs in constant time based on length of the keys. | |||
func (privKey PrivKeySecp256k1) Equals(other crypto.PrivKey) bool { | |||
if otherSecp, ok := other.(PrivKeySecp256k1); ok { | |||
return subtle.ConstantTimeCompare(privKey[:], otherSecp[:]) == 1 | |||
} else { | |||
return false | |||
} | |||
} | |||
/* | |||
// Deterministically generates new priv-key bytes from key. | |||
func (key PrivKeySecp256k1) Generate(index int) PrivKeySecp256k1 { | |||
newBytes := cdc.BinarySha256(struct { | |||
PrivKey [64]byte | |||
Index int | |||
}{key, index}) | |||
var newKey [64]byte | |||
copy(newKey[:], newBytes) | |||
return PrivKeySecp256k1(newKey) | |||
} | |||
*/ | |||
func GenPrivKey() PrivKeySecp256k1 { | |||
privKeyBytes := [32]byte{} | |||
copy(privKeyBytes[:], crypto.CRandBytes(32)) | |||
priv, _ := secp256k1.PrivKeyFromBytes(secp256k1.S256(), privKeyBytes[:]) | |||
copy(privKeyBytes[:], priv.Serialize()) | |||
return PrivKeySecp256k1(privKeyBytes) | |||
} | |||
// NOTE: secret should be the output of a KDF like bcrypt, | |||
// if it's derived from user input. | |||
func GenPrivKeyFromSecret(secret []byte) PrivKeySecp256k1 { | |||
privKey32 := crypto.Sha256(secret) // Not Ripemd160 because we want 32 bytes. | |||
priv, _ := secp256k1.PrivKeyFromBytes(secp256k1.S256(), privKey32) | |||
privKeyBytes := [32]byte{} | |||
copy(privKeyBytes[:], priv.Serialize()) | |||
return PrivKeySecp256k1(privKeyBytes) | |||
} | |||
//------------------------------------- | |||
var _ crypto.PubKey = PubKeySecp256k1{} | |||
const PubKeySecp256k1Size = 33 | |||
// Implements crypto.PubKey. | |||
// Compressed pubkey (just the x-cord), | |||
// prefixed with 0x02 or 0x03, depending on the y-cord. | |||
type PubKeySecp256k1 [PubKeySecp256k1Size]byte | |||
// Implements Bitcoin style addresses: RIPEMD160(SHA256(pubkey)) | |||
func (pubKey PubKeySecp256k1) Address() crypto.Address { | |||
hasherSHA256 := sha256.New() | |||
hasherSHA256.Write(pubKey[:]) // does not error | |||
sha := hasherSHA256.Sum(nil) | |||
hasherRIPEMD160 := ripemd160.New() | |||
hasherRIPEMD160.Write(sha) // does not error | |||
return crypto.Address(hasherRIPEMD160.Sum(nil)) | |||
} | |||
func (pubKey PubKeySecp256k1) Bytes() []byte { | |||
bz, err := cdc.MarshalBinaryBare(pubKey) | |||
if err != nil { | |||
panic(err) | |||
} | |||
return bz | |||
} | |||
func (pubKey PubKeySecp256k1) VerifyBytes(msg []byte, sig_ crypto.Signature) bool { | |||
// and assert same algorithm to sign and verify | |||
sig, ok := sig_.(SignatureSecp256k1) | |||
if !ok { | |||
return false | |||
} | |||
pub__, err := secp256k1.ParsePubKey(pubKey[:], secp256k1.S256()) | |||
if err != nil { | |||
return false | |||
} | |||
sig__, err := secp256k1.ParseDERSignature(sig[:], secp256k1.S256()) | |||
if err != nil { | |||
return false | |||
} | |||
return sig__.Verify(crypto.Sha256(msg), pub__) | |||
} | |||
func (pubKey PubKeySecp256k1) String() string { | |||
return fmt.Sprintf("PubKeySecp256k1{%X}", pubKey[:]) | |||
} | |||
func (pubKey PubKeySecp256k1) Equals(other crypto.PubKey) bool { | |||
if otherSecp, ok := other.(PubKeySecp256k1); ok { | |||
return bytes.Equal(pubKey[:], otherSecp[:]) | |||
} else { | |||
return false | |||
} | |||
} | |||
//------------------------------------- | |||
var _ crypto.Signature = SignatureSecp256k1{} | |||
// Implements crypto.Signature | |||
type SignatureSecp256k1 []byte | |||
func (sig SignatureSecp256k1) Bytes() []byte { | |||
bz, err := cdc.MarshalBinaryBare(sig) | |||
if err != nil { | |||
panic(err) | |||
} | |||
return bz | |||
} | |||
func (sig SignatureSecp256k1) IsZero() bool { return len(sig) == 0 } | |||
func (sig SignatureSecp256k1) String() string { | |||
return fmt.Sprintf("/%X.../", common.Fingerprint(sig[:])) | |||
} | |||
func (sig SignatureSecp256k1) Equals(other crypto.Signature) bool { | |||
if otherSecp, ok := other.(SignatureSecp256k1); ok { | |||
return subtle.ConstantTimeCompare(sig[:], otherSecp[:]) == 1 | |||
} else { | |||
return false | |||
} | |||
} | |||
func SignatureSecp256k1FromBytes(data []byte) crypto.Signature { | |||
sig := make(SignatureSecp256k1, len(data)) | |||
copy(sig[:], data) | |||
return sig | |||
} |
@ -1,90 +0,0 @@ | |||
package crypto | |||
import ( | |||
"fmt" | |||
"crypto/subtle" | |||
. "github.com/tendermint/tendermint/libs/common" | |||
) | |||
func SignatureFromBytes(pubKeyBytes []byte) (pubKey Signature, err error) { | |||
err = cdc.UnmarshalBinaryBare(pubKeyBytes, &pubKey) | |||
return | |||
} | |||
//---------------------------------------- | |||
type Signature interface { | |||
Bytes() []byte | |||
IsZero() bool | |||
Equals(Signature) bool | |||
} | |||
//------------------------------------- | |||
var _ Signature = SignatureEd25519{} | |||
const SignatureEd25519Size = 64 | |||
// Implements Signature | |||
type SignatureEd25519 [SignatureEd25519Size]byte | |||
func (sig SignatureEd25519) Bytes() []byte { | |||
bz, err := cdc.MarshalBinaryBare(sig) | |||
if err != nil { | |||
panic(err) | |||
} | |||
return bz | |||
} | |||
func (sig SignatureEd25519) IsZero() bool { return len(sig) == 0 } | |||
func (sig SignatureEd25519) String() string { return fmt.Sprintf("/%X.../", Fingerprint(sig[:])) } | |||
func (sig SignatureEd25519) Equals(other Signature) bool { | |||
if otherEd, ok := other.(SignatureEd25519); ok { | |||
return subtle.ConstantTimeCompare(sig[:], otherEd[:]) == 1 | |||
} else { | |||
return false | |||
} | |||
} | |||
func SignatureEd25519FromBytes(data []byte) Signature { | |||
var sig SignatureEd25519 | |||
copy(sig[:], data) | |||
return sig | |||
} | |||
//------------------------------------- | |||
var _ Signature = SignatureSecp256k1{} | |||
// Implements Signature | |||
type SignatureSecp256k1 []byte | |||
func (sig SignatureSecp256k1) Bytes() []byte { | |||
bz, err := cdc.MarshalBinaryBare(sig) | |||
if err != nil { | |||
panic(err) | |||
} | |||
return bz | |||
} | |||
func (sig SignatureSecp256k1) IsZero() bool { return len(sig) == 0 } | |||
func (sig SignatureSecp256k1) String() string { return fmt.Sprintf("/%X.../", Fingerprint(sig[:])) } | |||
func (sig SignatureSecp256k1) Equals(other Signature) bool { | |||
if otherSecp, ok := other.(SignatureSecp256k1); ok { | |||
return subtle.ConstantTimeCompare(sig[:], otherSecp[:]) == 1 | |||
} else { | |||
return false | |||
} | |||
} | |||
func SignatureSecp256k1FromBytes(data []byte) Signature { | |||
sig := make(SignatureSecp256k1, len(data)) | |||
copy(sig[:], data) | |||
return sig | |||
} |
@ -1,46 +0,0 @@ | |||
package crypto | |||
import ( | |||
"testing" | |||
"github.com/stretchr/testify/assert" | |||
"github.com/stretchr/testify/require" | |||
) | |||
func TestSignAndValidateEd25519(t *testing.T) { | |||
privKey := GenPrivKeyEd25519() | |||
pubKey := privKey.PubKey() | |||
msg := CRandBytes(128) | |||
sig, err := privKey.Sign(msg) | |||
require.Nil(t, err) | |||
// Test the signature | |||
assert.True(t, pubKey.VerifyBytes(msg, sig)) | |||
// Mutate the signature, just one bit. | |||
sigEd := sig.(SignatureEd25519) | |||
sigEd[7] ^= byte(0x01) | |||
sig = sigEd | |||
assert.False(t, pubKey.VerifyBytes(msg, sig)) | |||
} | |||
func TestSignAndValidateSecp256k1(t *testing.T) { | |||
privKey := GenPrivKeySecp256k1() | |||
pubKey := privKey.PubKey() | |||
msg := CRandBytes(128) | |||
sig, err := privKey.Sign(msg) | |||
require.Nil(t, err) | |||
assert.True(t, pubKey.VerifyBytes(msg, sig)) | |||
// Mutate the signature, just one bit. | |||
sigEd := sig.(SignatureSecp256k1) | |||
sigEd[3] ^= byte(0x01) | |||
sig = sigEd | |||
assert.False(t, pubKey.VerifyBytes(msg, sig)) | |||
} |
@ -1,326 +0,0 @@ | |||
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. | |||
[[projects]] | |||
branch = "master" | |||
name = "github.com/beorn7/perks" | |||
packages = ["quantile"] | |||
revision = "3a771d992973f24aa725d07868b467d1ddfceafb" | |||
[[projects]] | |||
branch = "master" | |||
name = "github.com/btcsuite/btcd" | |||
packages = ["btcec"] | |||
revision = "fdfc19097e7ac6b57035062056f5b7b4638b8898" | |||
[[projects]] | |||
name = "github.com/davecgh/go-spew" | |||
packages = ["spew"] | |||
revision = "346938d642f2ec3594ed81d874461961cd0faa76" | |||
version = "v1.1.0" | |||
[[projects]] | |||
name = "github.com/ebuchman/fail-test" | |||
packages = ["."] | |||
revision = "95f809107225be108efcf10a3509e4ea6ceef3c4" | |||
[[projects]] | |||
name = "github.com/go-kit/kit" | |||
packages = [ | |||
"log", | |||
"log/level", | |||
"log/term", | |||
"metrics", | |||
"metrics/discard", | |||
"metrics/internal/lv", | |||
"metrics/prometheus" | |||
] | |||
revision = "4dc7be5d2d12881735283bcab7352178e190fc71" | |||
version = "v0.6.0" | |||
[[projects]] | |||
name = "github.com/go-logfmt/logfmt" | |||
packages = ["."] | |||
revision = "390ab7935ee28ec6b286364bba9b4dd6410cb3d5" | |||
version = "v0.3.0" | |||
[[projects]] | |||
name = "github.com/go-stack/stack" | |||
packages = ["."] | |||
revision = "259ab82a6cad3992b4e21ff5cac294ccb06474bc" | |||
version = "v1.7.0" | |||
[[projects]] | |||
name = "github.com/gogo/protobuf" | |||
packages = [ | |||
"gogoproto", | |||
"jsonpb", | |||
"proto", | |||
"protoc-gen-gogo/descriptor", | |||
"sortkeys", | |||
"types" | |||
] | |||
revision = "1adfc126b41513cc696b209667c8656ea7aac67c" | |||
version = "v1.0.0" | |||
[[projects]] | |||
name = "github.com/golang/protobuf" | |||
packages = [ | |||
"proto", | |||
"ptypes", | |||
"ptypes/any", | |||
"ptypes/duration", | |||
"ptypes/timestamp" | |||
] | |||
revision = "925541529c1fa6821df4e44ce2723319eb2be768" | |||
version = "v1.0.0" | |||
[[projects]] | |||
branch = "master" | |||
name = "github.com/golang/snappy" | |||
packages = ["."] | |||
revision = "2e65f85255dbc3072edf28d6b5b8efc472979f5a" | |||
[[projects]] | |||
name = "github.com/gorilla/websocket" | |||
packages = ["."] | |||
revision = "ea4d1f681babbce9545c9c5f3d5194a789c89f5b" | |||
version = "v1.2.0" | |||
[[projects]] | |||
branch = "master" | |||
name = "github.com/jmhodges/levigo" | |||
packages = ["."] | |||
revision = "c42d9e0ca023e2198120196f842701bb4c55d7b9" | |||
[[projects]] | |||
branch = "master" | |||
name = "github.com/kr/logfmt" | |||
packages = ["."] | |||
revision = "b84e30acd515aadc4b783ad4ff83aff3299bdfe0" | |||
[[projects]] | |||
name = "github.com/matttproud/golang_protobuf_extensions" | |||
packages = ["pbutil"] | |||
revision = "c12348ce28de40eed0136aa2b644d0ee0650e56c" | |||
version = "v1.0.1" | |||
[[projects]] | |||
name = "github.com/pkg/errors" | |||
packages = ["."] | |||
revision = "645ef00459ed84a119197bfb8d8205042c6df63d" | |||
version = "v0.8.0" | |||
[[projects]] | |||
name = "github.com/pmezard/go-difflib" | |||
packages = ["difflib"] | |||
revision = "792786c7400a136282c1664665ae0a8db921c6c2" | |||
version = "v1.0.0" | |||
[[projects]] | |||
name = "github.com/prometheus/client_golang" | |||
packages = ["prometheus"] | |||
revision = "ae27198cdd90bf12cd134ad79d1366a6cf49f632" | |||
[[projects]] | |||
branch = "master" | |||
name = "github.com/prometheus/client_model" | |||
packages = ["go"] | |||
revision = "99fa1f4be8e564e8a6b613da7fa6f46c9edafc6c" | |||
[[projects]] | |||
branch = "master" | |||
name = "github.com/prometheus/common" | |||
packages = [ | |||
"expfmt", | |||
"internal/bitbucket.org/ww/goautoneg", | |||
"model" | |||
] | |||
revision = "7600349dcfe1abd18d72d3a1770870d9800a7801" | |||
[[projects]] | |||
branch = "master" | |||
name = "github.com/prometheus/procfs" | |||
packages = [ | |||
".", | |||
"internal/util", | |||
"nfs", | |||
"xfs" | |||
] | |||
revision = "ae68e2d4c00fed4943b5f6698d504a5fe083da8a" | |||
[[projects]] | |||
branch = "master" | |||
name = "github.com/rcrowley/go-metrics" | |||
packages = ["."] | |||
revision = "e2704e165165ec55d062f5919b4b29494e9fa790" | |||
[[projects]] | |||
name = "github.com/stretchr/testify" | |||
packages = [ | |||
"assert", | |||
"require" | |||
] | |||
revision = "f35b8ab0b5a2cef36673838d662e249dd9c94686" | |||
version = "v1.2.2" | |||
[[projects]] | |||
branch = "master" | |||
name = "github.com/syndtr/goleveldb" | |||
packages = [ | |||
"leveldb", | |||
"leveldb/cache", | |||
"leveldb/comparer", | |||
"leveldb/errors", | |||
"leveldb/filter", | |||
"leveldb/iterator", | |||
"leveldb/journal", | |||
"leveldb/memdb", | |||
"leveldb/opt", | |||
"leveldb/storage", | |||
"leveldb/table", | |||
"leveldb/util" | |||
] | |||
revision = "c4c61651e9e37fa117f53c5a906d3b63090d8445" | |||
[[projects]] | |||
branch = "master" | |||
name = "github.com/tendermint/ed25519" | |||
packages = [ | |||
".", | |||
"edwards25519", | |||
"extra25519" | |||
] | |||
revision = "d8387025d2b9d158cf4efb07e7ebf814bcce2057" | |||
[[projects]] | |||
name = "github.com/tendermint/go-amino" | |||
packages = ["."] | |||
revision = "2106ca61d91029c931fd54968c2bb02dc96b1412" | |||
version = "0.10.1" | |||
[[projects]] | |||
name = "github.com/tendermint/tendermint" | |||
packages = [ | |||
"abci/client", | |||
"abci/example/code", | |||
"abci/example/kvstore", | |||
"abci/types", | |||
"config", | |||
"crypto", | |||
"crypto/merkle", | |||
"crypto/tmhash", | |||
"libs/common", | |||
"libs/db", | |||
"libs/events", | |||
"libs/flowrate", | |||
"libs/log", | |||
"libs/pubsub", | |||
"libs/pubsub/query", | |||
"p2p", | |||
"p2p/conn", | |||
"p2p/upnp", | |||
"proxy", | |||
"rpc/core/types", | |||
"rpc/lib/client", | |||
"rpc/lib/server", | |||
"rpc/lib/types", | |||
"state", | |||
"types" | |||
] | |||
revision = "2aa2b63cadc42cca1071c36adfd2f2ce14e1aa8f" | |||
version = "v0.22.3" | |||
[[projects]] | |||
branch = "master" | |||
name = "golang.org/x/crypto" | |||
packages = [ | |||
"curve25519", | |||
"internal/subtle", | |||
"nacl/box", | |||
"nacl/secretbox", | |||
"openpgp/armor", | |||
"openpgp/errors", | |||
"poly1305", | |||
"ripemd160", | |||
"salsa20/salsa" | |||
] | |||
revision = "a49355c7e3f8fe157a85be2f77e6e269a0f89602" | |||
[[projects]] | |||
name = "golang.org/x/net" | |||
packages = [ | |||
"context", | |||
"http/httpguts", | |||
"http2", | |||
"http2/hpack", | |||
"idna", | |||
"internal/timeseries", | |||
"netutil", | |||
"trace" | |||
] | |||
revision = "292b43bbf7cb8d35ddf40f8d5100ef3837cced3f" | |||
[[projects]] | |||
name = "golang.org/x/text" | |||
packages = [ | |||
"collate", | |||
"collate/build", | |||
"internal/colltab", | |||
"internal/gen", | |||
"internal/tag", | |||
"internal/triegen", | |||
"internal/ucd", | |||
"language", | |||
"secure/bidirule", | |||
"transform", | |||
"unicode/bidi", | |||
"unicode/cldr", | |||
"unicode/norm", | |||
"unicode/rangetable" | |||
] | |||
revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0" | |||
version = "v0.3.0" | |||
[[projects]] | |||
branch = "master" | |||
name = "google.golang.org/genproto" | |||
packages = ["googleapis/rpc/status"] | |||
revision = "e92b116572682a5b432ddd840aeaba2a559eeff1" | |||
[[projects]] | |||
name = "google.golang.org/grpc" | |||
packages = [ | |||
".", | |||
"balancer", | |||
"balancer/base", | |||
"balancer/roundrobin", | |||
"codes", | |||
"connectivity", | |||
"credentials", | |||
"encoding", | |||
"encoding/proto", | |||
"grpclb/grpc_lb_v1/messages", | |||
"grpclog", | |||
"internal", | |||
"keepalive", | |||
"metadata", | |||
"naming", | |||
"peer", | |||
"resolver", | |||
"resolver/dns", | |||
"resolver/passthrough", | |||
"stats", | |||
"status", | |||
"tap", | |||
"transport" | |||
] | |||
revision = "d11072e7ca9811b1100b80ca0269ac831f06d024" | |||
version = "v1.11.3" | |||
[solve-meta] | |||
analyzer-name = "dep" | |||
analyzer-version = 1 | |||
inputs-digest = "b8644e2f33b8c04ed76a9cda1b6d7741a0e36844fdb0ce0d68717332779bcd75" | |||
solver-name = "gps-cdcl" | |||
solver-version = 1 |
@ -1,50 +0,0 @@ | |||
# Gopkg.toml example | |||
# | |||
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html | |||
# for detailed Gopkg.toml documentation. | |||
# | |||
# required = ["github.com/user/thing/cmd/thing"] | |||
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] | |||
# | |||
# [[constraint]] | |||
# name = "github.com/user/project" | |||
# version = "1.0.0" | |||
# | |||
# [[constraint]] | |||
# name = "github.com/user/project2" | |||
# branch = "dev" | |||
# source = "github.com/myfork/project2" | |||
# | |||
# [[override]] | |||
# name = "github.com/x/y" | |||
# version = "2.4.0" | |||
# | |||
# [prune] | |||
# non-go = false | |||
# go-tests = true | |||
# unused-packages = true | |||
[[constraint]] | |||
name = "github.com/pkg/errors" | |||
version = "0.8.0" | |||
[[constraint]] | |||
branch = "master" | |||
name = "github.com/rcrowley/go-metrics" | |||
[[constraint]] | |||
name = "github.com/stretchr/testify" | |||
version = "1.2.1" | |||
[[constraint]] | |||
name = "github.com/tendermint/go-amino" | |||
version = "~0.10.1" | |||
[[constraint]] | |||
name = "github.com/tendermint/tendermint" | |||
version = "v0.22.3" | |||
[prune] | |||
go-tests = true | |||
unused-packages = true |