diff --git a/priv_key.go b/priv_key.go index 61d373f60..82e1cfced 100644 --- a/priv_key.go +++ b/priv_key.go @@ -83,9 +83,10 @@ func (privKey PrivKeyEd25519) Generate(index int) PrivKeyEd25519 { panic(err) } newBytes := Sha256(bz) - var newKey [64]byte - copy(newKey[:], newBytes) - return PrivKeyEd25519(newKey) + newKey := new([64]byte) + copy(newKey[:32], newBytes) + ed25519.MakePublicKey(newKey) + return PrivKeyEd25519(*newKey) } func GenPrivKeyEd25519() PrivKeyEd25519 { diff --git a/priv_key_test.go b/priv_key_test.go index 3fbfba34d..6abe36ac5 100644 --- a/priv_key_test.go +++ b/priv_key_test.go @@ -1,15 +1,21 @@ -package crypto - -/* +package crypto_test import ( - "fmt" "testing" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + crypto "github.com/tendermint/go-crypto" ) +func TestGeneratePrivKey(t *testing.T) { + testPriv := crypto.GenPrivKeyEd25519() + testGenerate := testPriv.Generate(1) + signBytes := []byte("something to sign") + assert.True(t, testGenerate.PubKey().VerifyBytes(signBytes, testGenerate.Sign(signBytes))) +} + +/* + type BadKey struct { PrivKeyEd25519 }