@@ -34,10 +34,7 @@ type fakeKMS struct {
3434func (f * fakeKMS ) GetPublicKey (_ context.Context , _ * kms.GetPublicKeyInput , _ ... func (* kms.Options )) (* kms.GetPublicKeyOutput , error ) {
3535 pubBytes := crypto .FromECDSAPub (& f .priv .PublicKey ) // 0x04 || X || Y
3636 der , err := asn1 .Marshal (asn1Spki {
37- Algorithm : struct {
38- Algorithm asn1.ObjectIdentifier
39- Parameters asn1.ObjectIdentifier
40- }{Algorithm : ecPublicKeyOID , Parameters : secp256k1OID },
37+ Algorithm : asn1AlgorithmIdentifier {Algorithm : ecPublicKeyOID , Parameters : secp256k1OID },
4138 PublicKey : asn1.BitString {Bytes : pubBytes , BitLength : len (pubBytes ) * 8 },
4239 })
4340 if err != nil {
@@ -66,10 +63,10 @@ func (f *fakeKMS) Sign(_ context.Context, in *kms.SignInput, _ ...func(*kms.Opti
6663 return & kms.SignOutput {Signature : der }, nil
6764}
6865
69- func newTestKMSSigner (t * testing.T , fake * fakeKMS ) * kmsSigner {
66+ func newTestKMSSigner (t * testing.T , fake * fakeKMS , chainID * big. Int ) * kmsSigner {
7067 t .Helper ()
7168 expected := crypto .PubkeyToAddress (fake .priv .PublicKey )
72- ks , err := newKMSSignerWithClient (context .Background (), fake , "test-key-id" , expected )
69+ ks , err := newKMSSignerWithClient (context .Background (), fake , "test-key-id" , expected , chainID )
7370 require .NoError (t , err )
7471 assert .Equal (t , expected , ks .address ())
7572 return ks
@@ -81,10 +78,10 @@ func TestKMSSigner_AddressValidation(t *testing.T) {
8178 fake := & fakeKMS {priv : priv }
8279
8380 // matching address succeeds
84- newTestKMSSigner (t , fake )
81+ newTestKMSSigner (t , fake , big . NewInt ( 534352 ) )
8582
8683 // mismatching address fails fast
87- _ , err = newKMSSignerWithClient (context .Background (), fake , "test-key-id" , common .HexToAddress ("0xdeadbeef00000000000000000000000000000000" ))
84+ _ , err = newKMSSignerWithClient (context .Background (), fake , "test-key-id" , common .HexToAddress ("0xdeadbeef00000000000000000000000000000000" ), big . NewInt ( 534352 ) )
8885 require .Error (t , err )
8986 assert .Contains (t , err .Error (), "does not match" )
9087}
@@ -134,12 +131,11 @@ func TestKMSSigner_SignAllTxTypes(t *testing.T) {
134131
135132 for _ , tc := range cases {
136133 t .Run (tc .name , func (t * testing.T ) {
137- ks := newTestKMSSigner (t , & fakeKMS {priv : priv , forceHi : tc .forceHi })
134+ ks := newTestKMSSigner (t , & fakeKMS {priv : priv , forceHi : tc .forceHi }, chainID )
138135 ts := & TransactionSigner {
139- config : & config.SignerConfig {SignerType : AWSKMSSignerType },
140- kmsSigner : ks ,
141- kmsTxSigner : gethTypes .LatestSignerForChainID (chainID ),
142- addr : ks .address (),
136+ config : & config.SignerConfig {SignerType : AWSKMSSignerType },
137+ kmsSigner : ks ,
138+ addr : ks .address (),
143139 }
144140
145141 tx := gethTypes .NewTx (tc .txData )
@@ -183,10 +179,7 @@ func (f *rawKMS) Sign(_ context.Context, _ *kms.SignInput, _ ...func(*kms.Option
183179func marshalSPKI (t * testing.T , algo , curve asn1.ObjectIdentifier , point []byte , bitLen int ) []byte {
184180 t .Helper ()
185181 der , err := asn1 .Marshal (asn1Spki {
186- Algorithm : struct {
187- Algorithm asn1.ObjectIdentifier
188- Parameters asn1.ObjectIdentifier
189- }{Algorithm : algo , Parameters : curve },
182+ Algorithm : asn1AlgorithmIdentifier {Algorithm : algo , Parameters : curve },
190183 PublicKey : asn1.BitString {Bytes : point , BitLength : bitLen },
191184 })
192185 require .NoError (t , err )
@@ -207,7 +200,7 @@ func TestKMSSigner_MalformedPublicKey(t *testing.T) {
207200 evenPoint [len (evenPoint )- 1 ] &^= 1
208201
209202 // control: a well-formed SPKI must still be accepted.
210- _ , err = newKMSSignerWithClient (context .Background (), & rawKMS {pub : marshalSPKI (t , ecPublicKeyOID , secp256k1OID , point , full )}, "k" , addr )
203+ _ , err = newKMSSignerWithClient (context .Background (), & rawKMS {pub : marshalSPKI (t , ecPublicKeyOID , secp256k1OID , point , full )}, "k" , addr , big . NewInt ( 534352 ) )
211204 require .NoError (t , err )
212205
213206 cases := []struct {
@@ -222,7 +215,7 @@ func TestKMSSigner_MalformedPublicKey(t *testing.T) {
222215 }
223216 for _ , tc := range cases {
224217 t .Run (tc .name , func (t * testing.T ) {
225- _ , err := newKMSSignerWithClient (context .Background (), & rawKMS {pub : tc .pub }, "k" , addr )
218+ _ , err := newKMSSignerWithClient (context .Background (), & rawKMS {pub : tc .pub }, "k" , addr , big . NewInt ( 534352 ) )
226219 require .Error (t , err )
227220 assert .Contains (t , err .Error (), tc .want )
228221 })
@@ -264,7 +257,7 @@ func TestKMSSigner_InvalidSignerAddress(t *testing.T) {
264257 _ , err := newKMSSigner (context .Background (), & config.AWSKMSSignerConfig {
265258 KeyID : "some-key-id" ,
266259 SignerAddress : "not-a-hex-address" ,
267- })
260+ }, big . NewInt ( 534352 ) )
268261 require .Error (t , err )
269262 assert .Contains (t , err .Error (), "not a valid hex address" )
270263}
0 commit comments