Skip to content

Commit

Permalink
Removed old dep, old tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed Nov 22, 2020
1 parent fd7813e commit 5adc3cf
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 108 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ require (
github.com/bitcoinsv/bsvutil v0.0.0-20181216182056-1d77cf353ea9
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/libsv/go-bt v0.0.3
github.com/piotrnar/gocoin v0.0.0-20201027184336-0c389d7eb2c0
github.com/stretchr/testify v1.6.1
)
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/libsv/go-bt v0.0.3 h1:wuyubNlVQ8bay9jJy5JpolvMxoiwSA/u5y+zMnVrDIE=
github.com/libsv/go-bt v0.0.3/go.mod h1:6/eqZS8F56KztrcUdoYXHFx8ZBr4cg5Hp0jf0cG73J4=
github.com/piotrnar/gocoin v0.0.0-20201027184336-0c389d7eb2c0 h1:PuqJFsnjEnbgSk7b629KC4jyuWqr5tM09k80ZpyptHY=
github.com/piotrnar/gocoin v0.0.0-20201027184336-0c389d7eb2c0/go.mod h1:sW6i99ojgdRHcz53PCjyEeoTEDFh9dfP5iiEIiNfcaM=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down
105 changes: 0 additions & 105 deletions verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ package bitcoin
import (
"crypto/sha256"
"fmt"
"strconv"
"testing"

"github.com/piotrnar/gocoin/lib/secp256k1"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -128,109 +126,6 @@ func BenchmarkVerifyMessage(b *testing.B) {
}
}

// TestVerifyMessageSigRecover will test the method recoverSig()
//
// From: https://github.com/piotrnar/gocoin/blob/master/lib/secp256k1/sig_test.go
func TestVerifyMessageSigRecover(t *testing.T) {
var vs = [][6]string{
{
"6028b9e3a31c9e725fcbd7d5d16736aaaafcc9bf157dfb4be62bcbcf0969d488",
"036d4a36fa235b8f9f815aa6f5457a607f956a71a035bf0970d8578bf218bb5a",
"9cff3da1a4f86caf3683f865232c64992b5ed002af42b321b8d8a48420680487",
"0",
"56dc5df245955302893d8dda0677cc9865d8011bc678c7803a18b5f6faafec08",
"54b5fbdcd8fac6468dac2de88fadce6414f5f3afbb103753e25161bef77705a6",
},
{
"b470e02f834a3aaafa27bd2b49e07269e962a51410f364e9e195c31351a05e50",
"560978aed76de9d5d781f87ed2068832ed545f2b21bf040654a2daff694c8b09",
"9ce428d58e8e4caf619dc6fc7b2c2c28f0561654d1f80f322c038ad5e67ff8a6",
"1",
"15b7e7d00f024bffcd2e47524bb7b7d3a6b251e23a3a43191ed7f0a418d9a578",
"bf29a25e2d1f32c5afb18b41ae60112723278a8af31275965a6ec1d95334e840",
},
}

var sig secp256k1.Signature
var pubkey, exp secp256k1.XY
var msg secp256k1.Number

for i := range vs {
sig.R.SetHex(vs[i][0])
sig.S.SetHex(vs[i][1])
msg.SetHex(vs[i][2])
rid, _ := strconv.ParseInt(vs[i][3], 10, 32)
exp.X.SetHex(vs[i][4])
exp.Y.SetHex(vs[i][5])

success := secp256k1.RecoverPublicKey(sig.R.Bytes(), sig.S.Bytes(), msg.Bytes(), int(rid), &pubkey)
assert.Equal(t, true, success)
assert.Equal(t, true, exp.X.Equals(&pubkey.X))
assert.Equal(t, true, exp.Y.Equals(&pubkey.Y))
}
}

// TestVerifyMessageSigRecoverFailed will test the method recoverSig()
func TestVerifyMessageSigRecoverFailed(t *testing.T) {

// Bad signature cases
var vs = [][6]string{
{
"0",
"0",
"0",
"0",
"0",
"0",
},
{
"000",
"560978aed76de9d5d781f87ed2068832ed545f2b21bf040654a2daff694c8b09",
"9ce428d58e8e4caf619dc6fc7b2c2c28f0561654d1f80f322c038ad5e67ff8a6",
"1",
"000",
"bf29a25e2d1f32c5afb18b41ae60112723278a8af31275965a6ec1d95334e840",
},
{
"000",
"1234567",
"1234567",
"1",
"000",
"1234567",
},
{
"bf29a25e2d1f32c5afb18b41ae60112723278a8af31275965a6ec1d95334e840",
"bf29a25e2d1f32c5afb18b41ae60112723278a8af31275965a6ec1d95334e840",
"bf29a25e2d1f32c5afb18b41ae60112723278a8af31275965a6ec1d95334e840",
"1",
"bf29a25e2d1f32c5afb18b41ae60112723278a8af31275965a6ec1d95334e840",
"bf29a25e2d1f32c5afb18b41ae60112723278a8af31275965a6ec1d95334e840",
},
}

var sig secp256k1.Signature
var pubkey, exp secp256k1.XY
var msg secp256k1.Number

for i := range vs {
sig.R.SetHex(vs[i][0])
sig.S.SetHex(vs[i][1])
msg.SetHex(vs[i][2])
rid, err := strconv.ParseInt(vs[i][3], 10, 32)
assert.NoError(t, err)

exp.X.SetHex(vs[i][4])
exp.Y.SetHex(vs[i][5])

assert.Equal(t,
false,
secp256k1.RecoverPublicKey(sig.R.Bytes(), sig.S.Bytes(), msg.Bytes(), int(rid), &pubkey),
)
}

}

// TestVerifyMessageDER will test the method VerifyMessageDER()
func TestVerifyMessageDER(t *testing.T) {

Expand Down

0 comments on commit 5adc3cf

Please sign in to comment.