Skip to content

Commit 83900b0

Browse files
committed
Updated to v0.6.5
1 parent 946bbbe commit 83900b0

8 files changed

Lines changed: 149 additions & 103 deletions

File tree

.golangci.yml

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,43 +21,40 @@ linters-settings:
2121
- opinionated
2222
- performance
2323
- style
24-
disabled-checks:
25-
- dupImport # https://github.com/go-critic/go-critic/issues/845
26-
- ifElseChain
27-
- octalLiteral
28-
- whyNoLint
29-
- wrapperFunc
3024
goimports:
3125
local-prefixes: github.com/bitonicnl/verify-signed-message
32-
govet:
33-
check-shadowing: true
34-
settings:
35-
printf:
36-
funcs:
37-
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
38-
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
39-
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
40-
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
4126
misspell:
4227
locale: US
4328

4429
linters:
4530
enable:
4631
- asasalint
32+
- asciicheck
4733
- bidichk
4834
- bodyclose
35+
- containedctx
36+
- contextcheck
4937
- decorder
5038
- dogsled
5139
- dupl
40+
- dupword
41+
- durationcheck
5242
- errcheck
5343
- errchkjson
44+
- errname
5445
- errorlint
46+
- execinquery
5547
- exhaustive
5648
- exhaustruct
5749
- exportloopref
5850
- forbidigo
51+
- forcetypeassert
5952
- gci
53+
- ginkgolinter
54+
- gocheckcompilerdirectives
55+
- gochecknoglobals
6056
- gochecknoinits
57+
- gochecksumtype
6158
- gocognit
6259
- goconst
6360
- gocritic
@@ -73,39 +70,59 @@ linters:
7370
- goprintffuncname
7471
- gosec
7572
- gosimple
73+
- gosmopolitan
7674
- govet
7775
- grouper
76+
- importas
77+
- inamedparam
7878
- ineffassign
7979
- interfacebloat
8080
- ireturn
8181
- loggercheck
8282
- maintidx
8383
- makezero
84+
- mirror
8485
- misspell
86+
- musttag
8587
- nakedret
8688
- nestif
89+
- nilerr
8790
- nilnil
8891
- nlreturn
92+
- noctx
8993
- nolintlint
9094
- nonamedreturns
95+
- nosprintfhostport
9196
- paralleltest
97+
- perfsprint
9298
- prealloc
9399
- predeclared
94100
- promlinter
101+
- protogetter
95102
- reassign
96103
- revive
104+
- rowserrcheck
105+
- sloglint
106+
- spancheck
107+
- sqlclosecheck
97108
- staticcheck
98109
- stylecheck
110+
- tagalign
99111
- tagliatelle
100112
- tenv
113+
- testableexamples
114+
- testifylint
101115
- testpackage
102116
- thelper
117+
- tparallel
103118
- typecheck
104119
- unconvert
105120
- unparam
106121
- unused
107122
- usestdlibvars
123+
- wastedassign
108124
- whitespace
125+
- zerologlint
109126

110127
issues:
111128
# Show only new issues: if there are unstaged changes or untracked files,
@@ -117,12 +134,13 @@ issues:
117134
# Exclude some linters from running on tests files
118135
- path: _test\.go
119136
linters:
137+
- dupword
120138
- exhaustruct
121139

122140
# output configuration options
123141
output:
124142
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
125-
format: colored-line-number
143+
formats: [ { format: colored-line-number } ]
126144

127145
# print lines of code with issue, default is true
128146
print-issued-lines: true

go.mod

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ go 1.18
44

55
require (
66
github.com/btcsuite/btcd v0.24.0
7-
github.com/btcsuite/btcd/btcec/v2 v2.3.2
7+
github.com/btcsuite/btcd/btcec/v2 v2.3.3
88
github.com/btcsuite/btcd/btcutil v1.1.5
99
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0
10-
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0
10+
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0
1111
github.com/samber/lo v1.39.0
12-
github.com/stretchr/testify v1.8.4
12+
github.com/stretchr/testify v1.9.0
1313
)
1414

1515
require (
1616
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f // indirect
17-
github.com/davecgh/go-spew v1.1.1 // indirect
17+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
1818
github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect
19-
github.com/pmezard/go-difflib v1.0.0 // indirect
20-
golang.org/x/crypto v0.20.0 // indirect
21-
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
22-
golang.org/x/sys v0.17.0 // indirect
19+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
20+
golang.org/x/crypto v0.22.0 // indirect
21+
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f // indirect
22+
golang.org/x/sys v0.19.0 // indirect
2323
gopkg.in/yaml.v3 v3.0.1 // indirect
2424
)

go.sum

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ github.com/btcsuite/btcd v0.24.0 h1:gL3uHE/IaFj6fcZSu03SvqPMSx7s/dPzfpG/atRwWdo=
66
github.com/btcsuite/btcd v0.24.0/go.mod h1:K4IDc1593s8jKXIF7yS7yCTSxrknB9z0STzc2j6XgE4=
77
github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA=
88
github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE=
9-
github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U=
10-
github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
9+
github.com/btcsuite/btcd/btcec/v2 v2.3.3 h1:6+iXlDKE8RMtKsvK0gshlXIuPbyWM/h84Ensb7o3sC0=
10+
github.com/btcsuite/btcd/btcec/v2 v2.3.3/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
1111
github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A=
1212
github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE=
1313
github.com/btcsuite/btcd/btcutil v1.1.5 h1:+wER79R5670vs/ZusMTF1yTcRYE5GUsFbdjdisflzM8=
@@ -28,14 +28,15 @@ github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtE
2828
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
2929
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3030
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
31-
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
3231
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
32+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
33+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3334
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
3435
github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y=
3536
github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo=
3637
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
37-
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs=
38-
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0=
38+
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnNEcHYvcCuK6dPZSg=
39+
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0=
3940
github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218=
4041
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
4142
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
@@ -65,22 +66,23 @@ github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5
6566
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
6667
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
6768
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
68-
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
6969
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
70+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
71+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
7072
github.com/samber/lo v1.39.0 h1:4gTz1wUhNYLhFSKl6O+8peW0v2F4BCY034GRpU9WnuA=
7173
github.com/samber/lo v1.39.0/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA=
7274
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
7375
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
74-
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
75-
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
76+
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
77+
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
7678
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
7779
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
7880
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
7981
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
80-
golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg=
81-
golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ=
82-
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ=
83-
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc=
82+
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
83+
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
84+
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f h1:99ci1mjWVBWwJiEKYY6jWa4d2nTQVIEhZIptnrVb1XY=
85+
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI=
8486
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
8587
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
8688
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
@@ -96,8 +98,8 @@ golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7w
9698
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
9799
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
98100
golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
99-
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
100-
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
101+
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
102+
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
101103
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
102104
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
103105
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=

internal/flags/recovery_flags_test.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package flags_test
33
import (
44
"testing"
55

6-
"github.com/stretchr/testify/require"
76
"github.com/stretchr/testify/suite"
87

98
"github.com/bitonicnl/verify-signed-message/internal/flags"
@@ -21,19 +20,19 @@ func TestRecoveryFlagTestSuite(t *testing.T) {
2120
}
2221

2322
func (s *RecoveryFlagTestSuite) TestAll() {
24-
require.Equal(s.T(), []int{27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42}, flags.All())
23+
s.Equal([]int{27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42}, flags.All())
2524
}
2625

2726
func (s *RecoveryFlagTestSuite) TestCompressed() {
28-
require.Equal(s.T(), []int{31, 32, 33, 34}, flags.Compressed())
27+
s.Equal([]int{31, 32, 33, 34}, flags.Compressed())
2928
}
3029

3130
func (s *RecoveryFlagTestSuite) TestElectrumP2WPKH() {
32-
require.Equal(s.T(), []int{31, 32, 33, 34}, flags.ElectrumP2WPKH())
31+
s.Equal([]int{31, 32, 33, 34}, flags.ElectrumP2WPKH())
3332
}
3433

3534
func (s *RecoveryFlagTestSuite) TestElectrumP2WPKHAndP2SH() {
36-
require.Equal(s.T(), []int{31, 32, 33, 34}, flags.ElectrumP2WPKHAndP2SH())
35+
s.Equal([]int{31, 32, 33, 34}, flags.ElectrumP2WPKHAndP2SH())
3736
}
3837

3938
func (s *RecoveryFlagTestSuite) TestGetKeyID() {
@@ -80,17 +79,17 @@ func (s *RecoveryFlagTestSuite) TestShouldBeCompressed() {
8079
}
8180

8281
func (s *RecoveryFlagTestSuite) TestTrezor() {
83-
require.Equal(s.T(), []int{35, 36, 37, 38, 39, 40, 41, 42}, flags.Trezor())
82+
s.Equal([]int{35, 36, 37, 38, 39, 40, 41, 42}, flags.Trezor())
8483
}
8584

8685
func (s *RecoveryFlagTestSuite) TestTrezorP2WPKH() {
87-
require.Equal(s.T(), []int{39, 40, 41, 42}, flags.TrezorP2WPKH())
86+
s.Equal([]int{39, 40, 41, 42}, flags.TrezorP2WPKH())
8887
}
8988

9089
func (s *RecoveryFlagTestSuite) TestTrezorP2WPKHAndP2SH() {
91-
require.Equal(s.T(), []int{35, 36, 37, 38}, flags.TrezorP2WPKHAndP2SH())
90+
s.Equal([]int{35, 36, 37, 38}, flags.TrezorP2WPKHAndP2SH())
9291
}
9392

9493
func (s *RecoveryFlagTestSuite) TestUncompressed() {
95-
require.Equal(s.T(), []int{27, 28, 29, 30}, flags.Uncompressed())
94+
s.Equal([]int{27, 28, 29, 30}, flags.Uncompressed())
9695
}

internal/signature/signature_test.go

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"github.com/btcsuite/btcd/btcec/v2"
1010
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
1111
"github.com/btcsuite/btcd/chaincfg/chainhash"
12-
"github.com/stretchr/testify/require"
1312
"github.com/stretchr/testify/suite"
1413

1514
"github.com/bitonicnl/verify-signed-message/internal"
@@ -47,62 +46,62 @@ func TestServiceTestSuite(t *testing.T) {
4746

4847
func (s *SignatureTestSuite) TestParseCompactInvalid() {
4948
compactedSignature, err := signature.ParseCompact([]byte{})
50-
require.EqualError(s.T(), err, "invalid compact signature size")
51-
require.Nil(s.T(), compactedSignature)
49+
s.Require().EqualError(err, "invalid compact signature size")
50+
s.Nil(compactedSignature)
5251
}
5352

5453
func (s *SignatureTestSuite) TestParseCompact() {
5554
compactedSignature, err := signature.ParseCompact(s.signatureEncoded)
56-
require.NoError(s.T(), err)
55+
s.Require().NoError(err)
5756

5857
// Retrieve the unexported fields
5958
R := s.getFieldFromSignature(compactedSignature, "r")
6059
S := s.getFieldFromSignature(compactedSignature, "s")
6160

6261
// Ensure they match what we defined
63-
require.Equal(s.T(), "112454100686917088716763005039207074580155840372180209748670933598947425987108", R.String())
64-
require.Equal(s.T(), "23603267825273168310009216611640910854054822424267934178492474518750065713966", S.String())
62+
s.Equal("112454100686917088716763005039207074580155840372180209748670933598947425987108", R.String())
63+
s.Equal("23603267825273168310009216611640910854054822424267934178492474518750065713966", S.String())
6564
}
6665

6766
func (s *SignatureTestSuite) TestVerifyInvalidPublicKey() {
6867
err := signature.Verify(s.signatureEncoded, &btcec.PublicKey{}, []byte{})
69-
require.EqualError(s.T(), err, "public key was not correctly instantiated")
68+
s.Require().EqualError(err, "public key was not correctly instantiated")
7069
}
7170

7271
func (s *SignatureTestSuite) TestVerifyInvalidEncodedSignature() {
7372
key, err := btcec.NewPrivateKey()
74-
require.NoError(s.T(), err)
73+
s.Require().NoError(err)
7574

7675
err = signature.Verify([]byte{}, key.PubKey(), []byte{})
77-
require.EqualError(s.T(), err, "invalid compact signature size")
76+
s.Require().EqualError(err, "invalid compact signature size")
7877
}
7978

8079
func (s *SignatureTestSuite) TestVerifyInvalidSignature() {
8180
key, err := btcec.NewPrivateKey()
82-
require.NoError(s.T(), err)
81+
s.Require().NoError(err)
8382

8483
err = signature.Verify(s.signatureEncoded, key.PubKey(), []byte{})
85-
require.EqualError(s.T(), err, "signature could not be verified")
84+
s.Require().EqualError(err, "signature could not be verified")
8685
}
8786

8887
func (s *SignatureTestSuite) TestVerifyInvalidMessage() {
8988
magicMessage := internal.CreateMagicMessage("INVALID")
9089
messageHash := chainhash.DoubleHashB([]byte(magicMessage))
9190

9291
publicKey, err := btcec.ParsePubKey(s.publicKeyEncoded)
93-
require.NoError(s.T(), err)
92+
s.Require().NoError(err)
9493

95-
require.EqualError(s.T(), signature.Verify(s.signatureEncoded, publicKey, messageHash), "signature could not be verified")
94+
s.Require().EqualError(signature.Verify(s.signatureEncoded, publicKey, messageHash), "signature could not be verified")
9695
}
9796

9897
func (s *SignatureTestSuite) TestVerify() {
9998
magicMessage := internal.CreateMagicMessage("test message")
10099
messageHash := chainhash.DoubleHashB([]byte(magicMessage))
101100

102101
publicKey, err := btcec.ParsePubKey(s.publicKeyEncoded)
103-
require.NoError(s.T(), err)
102+
s.Require().NoError(err)
104103

105-
require.NoError(s.T(), signature.Verify(s.signatureEncoded, publicKey, messageHash))
104+
s.Require().NoError(signature.Verify(s.signatureEncoded, publicKey, messageHash))
106105
}
107106

108107
func (s *SignatureTestSuite) getFieldFromSignature(compactedSignature *ecdsa.Signature, field string) *big.Int {
@@ -115,7 +114,7 @@ func (s *SignatureTestSuite) getFieldFromSignature(compactedSignature *ecdsa.Sig
115114
// Grab the unexported field
116115
rReflected := elem.FieldByName(field)
117116
m, ok := reflect.NewAt(rReflected.Type(), unsafe.Pointer(rReflected.UnsafeAddr())).Elem().Interface().(btcec.ModNScalar)
118-
require.True(s.T(), ok)
117+
s.True(ok)
119118

120119
// Grab ModNScalar bytes
121120
bytes := m.Bytes()

internal/validation.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ func ValidateP2WPKH(recoveryFlag int, pubkeyHash []byte, addr btcutil.Address, n
7272
}
7373

7474
// ValidateP2TR ensures that the passed P2TR address matches the address generated from the public key hash, recovery flag and network.
75+
//
76+
// Only addresses without a tapscript are allowed because the verification is using the internal key.
7577
func ValidateP2TR(recoveryFlag int, pubKey *btcec.PublicKey, addr btcutil.Address, net *chaincfg.Params) (bool, error) {
7678
// Ensure proper address type will be generated
77-
if lo.Contains[int](flags.Compressed(), recoveryFlag) {
78-
return false, errors.New("cannot use P2TR for recovery flag 'compressed'")
79-
} else if lo.Contains[int](flags.TrezorP2WPKHAndP2SH(), recoveryFlag) {
79+
if lo.Contains[int](flags.TrezorP2WPKHAndP2SH(), recoveryFlag) {
8080
return false, errors.New("cannot use P2TR for recovery flag 'BIP137 (Trezor) P2WPKH-P2SH'")
8181
} else if lo.Contains[int](flags.TrezorP2WPKH(), recoveryFlag) {
8282
return false, errors.New("cannot use P2TR for recovery flag 'BIP137 (Trezor) P2WPKH'")

0 commit comments

Comments
 (0)