From cb75680c9c2db30f8fb7413f0eaf819cad67d9f3 Mon Sep 17 00:00:00 2001 From: Luke Date: Fri, 30 Oct 2020 17:01:36 -0400 Subject: [PATCH] remove getBin --- verify.go | 18 ------------------ verify_test.go | 29 ----------------------------- 2 files changed, 47 deletions(-) diff --git a/verify.go b/verify.go index c34d333..f6a5534 100644 --- a/verify.go +++ b/verify.go @@ -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) { diff --git a/verify_test.go b/verify_test.go index ef6e4f3..79f1742 100644 --- a/verify_test.go +++ b/verify_test.go @@ -4,7 +4,6 @@ import ( "crypto/sha256" "encoding/hex" "fmt" - "math/big" "strconv" "testing" @@ -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) {