@@ -166,4 +166,62 @@ describe('TSS MPC Pick BitGo GPG Pub Key Utils:', function () {
166166 ) ;
167167 await assert . rejects ( async ( ) => await ecdsaMpcv2Util . testPickBitgoPubGpgKeyForSigning ( true ) ) ;
168168 } ) ;
169+
170+ it ( 'should select the correct GPG key for verifyWalletSignatures with hardcoded options' , async function ( ) {
171+ // Test environment setup
172+ const env = 'test' ;
173+ const bitgoInstance = TestBitGo . decorate ( BitGo , { env } ) ;
174+ bitgoInstance . initializeTestVars ( ) ;
175+ const coinInstance = bitgoInstance . coin ( eddsaCoinName ) ;
176+ const eddsaMpcv1Util = new TestEddsaMpcv1Utils (
177+ bitgoInstance ,
178+ coinInstance ,
179+ new Wallet ( bitgoInstance , coinInstance , eddsaWalletData )
180+ ) ;
181+
182+ // Get the key that would be selected when using hardcoded BitGo keys
183+ // mpcv1 and nitro are passed as options
184+ const gpgKey = await eddsaMpcv1Util . testPickBitgoPubGpgKeyForSigning ( false , undefined , undefined ) ;
185+
186+ // Mock implementation of verifyWalletSignatures to capture the bitgoGpgKey that gets used
187+ let capturedKey ;
188+ eddsaMpcv1Util . verifyWalletSignatures = async function (
189+ userGpgPub ,
190+ backupGpgPub ,
191+ bitgoKeychain ,
192+ decryptedShare ,
193+ verifierIndex ,
194+ useHardcodedBitGoKeys
195+ ) {
196+ // Save the key that would be used when specifying hardcoded options
197+ if ( useHardcodedBitGoKeys ) {
198+ const hardcodedKey = await openpgp . readKey ( {
199+ armoredKey : BitgoMpcGpgPubKeys . bitgoMpcGpgPubKeys [ 'mpcv1' ] [ 'nitro' ] [ 'test' ] ,
200+ } ) ;
201+ capturedKey = hardcodedKey . armor ( ) ;
202+ }
203+ // Not actually verifying in this test
204+ return ;
205+ } ;
206+
207+ // Call with hardcoded key options
208+ await eddsaMpcv1Util . verifyWalletSignatures (
209+ 'mock-user-key' ,
210+ 'mock-backup-key' ,
211+ {
212+ commonKeychain : 'mock-keychain' ,
213+ walletHSMGPGPublicKeySigs : '' ,
214+ id : '' ,
215+ type : 'tss' ,
216+ } ,
217+ 'decrypted-share' ,
218+ 1 ,
219+ { env : 'test' , pubKeyType : 'nitro' }
220+ ) ;
221+
222+ // Verify the hardcoded key matches what we expect
223+ capturedKey . should . equal ( BitgoMpcGpgPubKeys . bitgoMpcGpgPubKeys [ 'mpcv1' ] [ 'nitro' ] [ 'test' ] ) ;
224+ // Also verify it's the same as what's returned by testPickBitgoPubGpgKeyForSigning
225+ gpgKey . armor ( ) . should . equal ( capturedKey ) ;
226+ } ) ;
169227} ) ;
0 commit comments