Skip to content

Commit

Permalink
Remove secp256_rand.go and update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustav Simonsson committed Feb 13, 2015
1 parent 39434e3 commit f35d62b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 107 deletions.
97 changes: 0 additions & 97 deletions crypto/secp256k1/secp256_rand.go

This file was deleted.

21 changes: 11 additions & 10 deletions crypto/secp256k1/secp256_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package secp256k1
import (
"bytes"
"fmt"
"github.com/ethereum/go-ethereum/crypto/randentropy"
"log"
"testing"
)
Expand All @@ -12,7 +13,7 @@ const SigSize = 65 //64+1

func Test_Secp256_00(t *testing.T) {

var nonce []byte = RandByte(32) //going to get bitcoins stolen!
var nonce []byte = randentropy.GetEntropyMixed(32) //going to get bitcoins stolen!

if len(nonce) != 32 {
t.Fatal()
Expand Down Expand Up @@ -50,7 +51,7 @@ func Test_Secp256_01(t *testing.T) {
//test size of messages
func Test_Secp256_02s(t *testing.T) {
pubkey, seckey := GenerateKeyPair()
msg := RandByte(32)
msg := randentropy.GetEntropyMixed(32)
sig, _ := Sign(msg, seckey)
CompactSigTest(sig)
if sig == nil {
Expand All @@ -73,7 +74,7 @@ func Test_Secp256_02s(t *testing.T) {
//test signing message
func Test_Secp256_02(t *testing.T) {
pubkey1, seckey := GenerateKeyPair()
msg := RandByte(32)
msg := randentropy.GetEntropyMixed(32)
sig, _ := Sign(msg, seckey)
if sig == nil {
t.Fatal("Signature nil")
Expand All @@ -96,7 +97,7 @@ func Test_Secp256_02(t *testing.T) {
//test pubkey recovery
func Test_Secp256_02a(t *testing.T) {
pubkey1, seckey1 := GenerateKeyPair()
msg := RandByte(32)
msg := randentropy.GetEntropyMixed(32)
sig, _ := Sign(msg, seckey1)

if sig == nil {
Expand Down Expand Up @@ -125,7 +126,7 @@ func Test_Secp256_02a(t *testing.T) {
func Test_Secp256_03(t *testing.T) {
_, seckey := GenerateKeyPair()
for i := 0; i < TESTS; i++ {
msg := RandByte(32)
msg := randentropy.GetEntropyMixed(32)
sig, _ := Sign(msg, seckey)
CompactSigTest(sig)

Expand All @@ -141,7 +142,7 @@ func Test_Secp256_03(t *testing.T) {
func Test_Secp256_04(t *testing.T) {
for i := 0; i < TESTS; i++ {
pubkey1, seckey := GenerateKeyPair()
msg := RandByte(32)
msg := randentropy.GetEntropyMixed(32)
sig, _ := Sign(msg, seckey)
CompactSigTest(sig)

Expand All @@ -164,15 +165,15 @@ func Test_Secp256_04(t *testing.T) {
// -SIPA look at this

func randSig() []byte {
sig := RandByte(65)
sig := randentropy.GetEntropyMixed(65)
sig[32] &= 0x70
sig[64] %= 4
return sig
}

func Test_Secp256_06a_alt0(t *testing.T) {
pubkey1, seckey := GenerateKeyPair()
msg := RandByte(32)
msg := randentropy.GetEntropyMixed(32)
sig, _ := Sign(msg, seckey)

if sig == nil {
Expand Down Expand Up @@ -203,12 +204,12 @@ func Test_Secp256_06a_alt0(t *testing.T) {

func Test_Secp256_06b(t *testing.T) {
pubkey1, seckey := GenerateKeyPair()
msg := RandByte(32)
msg := randentropy.GetEntropyMixed(32)
sig, _ := Sign(msg, seckey)

fail_count := 0
for i := 0; i < TESTS; i++ {
msg = RandByte(32)
msg = randentropy.GetEntropyMixed(32)
pubkey2, _ := RecoverPubkey(msg, sig)
if bytes.Equal(pubkey1, pubkey2) == true {
t.Fail()
Expand Down

0 comments on commit f35d62b

Please sign in to comment.