crypto/random: Use chacha20, add forward secrecy (#2562)

Ref #2099
This commit is contained in:
Dev Ojha
2018-10-08 06:15:56 -07:00
committed by Alexander Simmerl
parent 35b671214c
commit b1e7fac787
3 changed files with 60 additions and 25 deletions

23
crypto/random_test.go Normal file
View File

@ -0,0 +1,23 @@
package crypto_test
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/crypto"
)
// the purpose of this test is primarily to ensure that the randomness
// generation won't error.
func TestRandomConsistency(t *testing.T) {
x1 := crypto.CRandBytes(256)
x2 := crypto.CRandBytes(256)
x3 := crypto.CRandBytes(256)
x4 := crypto.CRandBytes(256)
x5 := crypto.CRandBytes(256)
require.NotEqual(t, x1, x2)
require.NotEqual(t, x3, x4)
require.NotEqual(t, x4, x5)
require.NotEqual(t, x1, x5)
}