mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 23:02:16 +00:00
fix ed25519 Generate
This commit is contained in:
parent
915416979b
commit
ad837a8183
@ -83,9 +83,10 @@ func (privKey PrivKeyEd25519) Generate(index int) PrivKeyEd25519 {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
newBytes := Sha256(bz)
|
newBytes := Sha256(bz)
|
||||||
var newKey [64]byte
|
newKey := new([64]byte)
|
||||||
copy(newKey[:], newBytes)
|
copy(newKey[:32], newBytes)
|
||||||
return PrivKeyEd25519(newKey)
|
ed25519.MakePublicKey(newKey)
|
||||||
|
return PrivKeyEd25519(*newKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GenPrivKeyEd25519() PrivKeyEd25519 {
|
func GenPrivKeyEd25519() PrivKeyEd25519 {
|
||||||
|
@ -1,15 +1,21 @@
|
|||||||
package crypto
|
package crypto_test
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"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 {
|
type BadKey struct {
|
||||||
PrivKeyEd25519
|
PrivKeyEd25519
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user