mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-01 23:45:50 +00:00
ee0d92c6d2
Signed-off-by: Roman Khimov <roman@nspcc.ru>
28 lines
513 B
Go
28 lines
513 B
Go
package consensus
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
"testing"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestCrypt(t *testing.T) {
|
|
key, err := keys.NewPrivateKey()
|
|
require.NoError(t, err)
|
|
|
|
priv := privateKey{key}
|
|
|
|
pub := key.PublicKey()
|
|
|
|
data := []byte{1, 2, 3, 4}
|
|
hash := sha256.Sum256(data)
|
|
|
|
sign, err := priv.Sign(data)
|
|
require.NoError(t, err)
|
|
require.True(t, pub.Verify(sign, hash[:]))
|
|
|
|
sign[0] = ^sign[0]
|
|
require.False(t, pub.Verify(sign, hash[:]))
|
|
}
|