Skip to content

Commit

Permalink
remove getBin
Browse files Browse the repository at this point in the history
  • Loading branch information
rohenaz committed Oct 30, 2020
1 parent 3fdca1d commit cb75680
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 47 deletions.
18 changes: 0 additions & 18 deletions verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,24 +124,6 @@ func pubKeyToAddress(pubkeyXy2 secp256k1.XY, compressed bool, magic []byte) (add
return bsvecAddress.String()
}

// This function is copied from "piotrnar/gocoin/lib/secp256k1".
// And modified for local package.
// License is:
// https://github.com/piotrnar/gocoin/blob/master/lib/secp256k1/COPYING
func getBin(num *secp256k1.Number, le int) ([]byte, error) {
if num == nil {
return nil, errors.New("secp256k1.Number is nil")
}
bts := num.Bytes()
if len(bts) > le {
return nil, errors.New("buffer too small")
}
if len(bts) == le {
return bts, nil
}
return append(make([]byte, le-len(bts)), bts...), nil
}

// sigMessageToAddress will convert a signature & message to a list of addresses
func sigMessageToAddress(signature, message string) ([]string, error) {

Expand Down
29 changes: 0 additions & 29 deletions verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"crypto/sha256"
"encoding/hex"
"fmt"
"math/big"
"strconv"
"testing"

Expand Down Expand Up @@ -304,34 +303,6 @@ func TestVerifyMessageSigRecoverFailed(t *testing.T) {

}

// TestVerifyMessageGetBin will test the method getBin()
func TestVerifyMessageGetBin(t *testing.T) {
t.Parallel()

var (
// Testing private methods
tests = []struct {
inputNumber *secp256k1.Number
inputLength int
expectedError bool
}{
{nil, 1, true},
{&secp256k1.Number{Int: *big.NewInt(400)}, 1, true},
{&secp256k1.Number{Int: *big.NewInt(1)}, 1, false},
}
)

// Run tests
for _, test := range tests {
if _, err := getBin(test.inputNumber, test.inputLength); err != nil && !test.expectedError {
t.Errorf("%s Failed: [%v] [%d] inputted and error not expected but got: %s", t.Name(), test.inputNumber, test.inputLength, err.Error())
} else if err == nil && test.expectedError {
t.Log(len(test.inputNumber.Bytes()), test.inputLength)
t.Errorf("%s Failed: [%v] [%d] inputted and error was expected", t.Name(), test.inputNumber, test.inputLength)
}
}
}

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

Expand Down

0 comments on commit cb75680

Please sign in to comment.