diff --git a/pkg/core/account_state_test.go b/pkg/core/account_state_test.go index ae157f07e..1452211ed 100644 --- a/pkg/core/account_state_test.go +++ b/pkg/core/account_state_test.go @@ -4,7 +4,6 @@ import ( "bytes" "testing" - "github.com/CityOfZion/neo-go/pkg/crypto" "github.com/CityOfZion/neo-go/pkg/crypto/keys" "github.com/CityOfZion/neo-go/pkg/util" "github.com/stretchr/testify/assert" @@ -18,9 +17,11 @@ func TestDecodeEncodeAccountState(t *testing.T) { ) for i := 0; i < n; i++ { balances[randomUint256()] = util.Fixed8(int64(randomInt(1, 10000))) - votes[i] = &keys.PublicKey{ - ECPoint: crypto.RandomECPoint(), - } + k, err := keys.NewPrivateKey() + assert.Nil(t, err) + p, err := k.PublicKey() + assert.Nil(t, err) + votes[i] = p } a := &AccountState{ diff --git a/pkg/crypto/elliptic_curve.go b/pkg/crypto/elliptic_curve.go index c2b2edebc..371f92db1 100644 --- a/pkg/crypto/elliptic_curve.go +++ b/pkg/crypto/elliptic_curve.go @@ -5,7 +5,6 @@ package crypto import ( "bytes" - "crypto/rand" "encoding/binary" "encoding/hex" "errors" @@ -63,23 +62,6 @@ func NewEllipticCurve() EllipticCurve { return c } -// RandomECPoint returns a random generated ECPoint, mostly used -// for testing. -func RandomECPoint() ECPoint { - c := NewEllipticCurve() - b := make([]byte, c.N.BitLen()/8+8) - if _, err := io.ReadFull(rand.Reader, b); err != nil { - return ECPoint{} - } - - d := new(big.Int).SetBytes(b) - d.Mod(d, new(big.Int).Sub(c.N, big.NewInt(1))) - d.Add(d, big.NewInt(1)) - - q := new(big.Int).SetBytes(d.Bytes()) - return c.ScalarBaseMult(q) -} - // ECPointFromReader return a new point from the given reader. // f == 4, 6 or 7 are not implemented. func ECPointFromReader(r io.Reader) (point ECPoint, err error) { diff --git a/pkg/crypto/keys/publickey_test.go b/pkg/crypto/keys/publickey_test.go index cddd76c5d..0ca4f4fbd 100644 --- a/pkg/crypto/keys/publickey_test.go +++ b/pkg/crypto/keys/publickey_test.go @@ -22,7 +22,10 @@ func TestEncodeDecodeInfinity(t *testing.T) { func TestEncodeDecodePublicKey(t *testing.T) { for i := 0; i < 4; i++ { - p := &PublicKey{crypto.RandomECPoint()} + k, err := NewPrivateKey() + assert.Nil(t, err) + p, err := k.PublicKey() + assert.Nil(t, err) buf := new(bytes.Buffer) assert.Nil(t, p.EncodeBinary(buf))