bitbucket.org/number571/tendermint@v0.8.14/crypto/gost256/gost256_test.go (about)

     1  package gost256_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  	"github.com/stretchr/testify/require"
     8  
     9  	"bitbucket.org/number571/tendermint/crypto"
    10  	"bitbucket.org/number571/tendermint/crypto/gost256"
    11  )
    12  
    13  const (
    14  	TEST_SUBJECT  = "subject"
    15  	TEST_PASSWORD = "password"
    16  )
    17  
    18  func TestSignAndValidateGost256(t *testing.T) {
    19  	privKey := gost256.GenPrivKeyWithInput(TEST_SUBJECT, TEST_PASSWORD)
    20  	pubKey := privKey.PubKey()
    21  
    22  	msg := crypto.CRandBytes(128)
    23  	sig, err := privKey.Sign(msg)
    24  	require.Nil(t, err)
    25  
    26  	assert.True(t, pubKey.VerifySignature(msg, sig))
    27  
    28  	sig[3] ^= byte(0x01)
    29  
    30  	assert.False(t, pubKey.VerifySignature(msg, sig))
    31  }