mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-23 09:41:38 +00:00
fixed crypto
This commit is contained in:
35
crypto/ed25519_test.go
Normal file
35
crypto/ed25519_test.go
Normal file
@ -0,0 +1,35 @@
|
||||
package crypto
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"crypto/rand"
|
||||
)
|
||||
|
||||
func TestSign(t *testing.T) {
|
||||
privKey := make([]byte, 32)
|
||||
_, err := rand.Read(privKey)
|
||||
if err != nil { t.Fatal(err) }
|
||||
pubKey := MakePubKey(privKey)
|
||||
signature := SignMessage([]byte("hello"), privKey, pubKey)
|
||||
|
||||
v1 := &Verify{
|
||||
Message: []byte("hello"),
|
||||
PubKey: pubKey,
|
||||
Signature: signature,
|
||||
}
|
||||
|
||||
ok := VerifyBatch([]*Verify{v1, v1, v1, v1})
|
||||
if ok != true { t.Fatal("Expected ok == true") }
|
||||
if v1.Valid != true { t.Fatal("Expected v1.Valid to be true") }
|
||||
|
||||
v2 := &Verify{
|
||||
Message: []byte{0x73},
|
||||
PubKey: pubKey,
|
||||
Signature: signature,
|
||||
}
|
||||
|
||||
ok = VerifyBatch([]*Verify{v1, v1, v1, v2})
|
||||
if ok != false { t.Fatal("Expected ok == false") }
|
||||
if v1.Valid != true { t.Fatal("Expected v1.Valid to be true") }
|
||||
if v2.Valid != false { t.Fatal("Expected v2.Valid to be true") }
|
||||
}
|
Reference in New Issue
Block a user