@@ -269,34 +269,31 @@ describe('signTxRequest:', function () {
269269 const userShare = fs . readFileSync ( shareFiles [ vector . party1 ] ) ;
270270 const userPrvBase64 = Buffer . from ( userShare ) . toString ( 'base64' ) ;
271271
272- // Encrypt the prv with v2 to trigger the v2 path
273272 const encryptedPrv = await bitgo . encryptAsync ( {
274273 input : userPrvBase64 ,
275274 password : walletPassphrase ,
276275 encryptionVersion : 2 ,
277276 } ) ;
278277 JSON . parse ( encryptedPrv ) . v . should . equal ( 2 ) ;
279278
280- // Round 1: encrypt session + GPG key with v2 + adata (purely local, no server call)
281279 const round1Result = await tssUtils . createOfflineRound1Share ( {
282280 txRequest,
283281 prv : userPrvBase64 ,
284282 walletPassphrase,
285283 encryptedPrv,
286284 } ) ;
287285
288- // Verify round 1 output has v2 envelopes with adata
289286 const r1SessionEnvelope = JSON . parse ( round1Result . encryptedRound1Session ) ;
290287 r1SessionEnvelope . v . should . equal ( 2 ) ;
291288 r1SessionEnvelope . should . have . property ( 'adata' ) ;
292289 r1SessionEnvelope . should . have . property ( 'hkdfSalt' ) ;
290+ r1SessionEnvelope . adata . should . containEql ( 'DKLS23_SIGNING_ROUND1_STATE' ) ;
293291
294292 const r1GpgEnvelope = JSON . parse ( round1Result . encryptedUserGpgPrvKey ) ;
295293 r1GpgEnvelope . v . should . equal ( 2 ) ;
296294 r1GpgEnvelope . should . have . property ( 'adata' ) ;
297- r1SessionEnvelope . adata . should . equal ( r1GpgEnvelope . adata ) ;
295+ r1GpgEnvelope . adata . should . containEql ( 'DKLS23_SIGNING_USER_GPG_KEY' ) ;
298296
299- // Nock BitGo round 1 response and submit
300297 await nockTxRequestResponseSignatureShareRoundOne ( bitgoParty , txRequest , bitgoGpgKey ) ;
301298 const transactions = getRoute ( 'ecdsa' ) ;
302299 const round1TxRequestResponse = await bitgo
@@ -307,7 +304,6 @@ describe('signTxRequest:', function () {
307304 } )
308305 . result ( ) ;
309306
310- // Merge server response with original txRequest (server only returns signatureShares)
311307 const round1TxReq : TxRequest = {
312308 ...txRequest ,
313309 transactions : [
@@ -318,7 +314,6 @@ describe('signTxRequest:', function () {
318314 ] ,
319315 } ;
320316
321- // Round 2: decrypt v2 round 1 session (validates adata), encrypt round 2 session
322317 const round2Result = await tssUtils . createOfflineRound2Share ( {
323318 txRequest : round1TxReq ,
324319 prv : userPrvBase64 ,
@@ -328,13 +323,11 @@ describe('signTxRequest:', function () {
328323 encryptedRound1Session : round1Result . encryptedRound1Session ,
329324 } ) ;
330325
331- // Verify round 2 output has v2 envelope with adata
332326 const r2Envelope = JSON . parse ( round2Result . encryptedRound2Session ) ;
333327 r2Envelope . v . should . equal ( 2 ) ;
334328 r2Envelope . should . have . property ( 'adata' ) ;
335- r2Envelope . adata . should . equal ( r1SessionEnvelope . adata ) ;
329+ r2Envelope . adata . should . containEql ( 'DKLS23_SIGNING_ROUND2_STATE' ) ;
336330
337- // Nock BitGo round 2 response and submit
338331 await nockTxRequestResponseSignatureShareRoundTwo ( bitgoParty , txRequest , bitgoGpgKey ) ;
339332 const round2TxRequestResponse = await bitgo
340333 . post ( bitgo . url ( `/wallet/${ txRequest . walletId } /txrequests/${ txRequest . txRequestId + transactions } /sign` , 2 ) )
@@ -354,7 +347,6 @@ describe('signTxRequest:', function () {
354347 ] ,
355348 } ;
356349
357- // Round 3: decrypt v2 round 2 session (validates adata), produce final signature share
358350 const round3Result = await tssUtils . createOfflineRound3Share ( {
359351 txRequest : round2TxReq ,
360352 prv : userPrvBase64 ,
@@ -367,15 +359,29 @@ describe('signTxRequest:', function () {
367359 round3Result . should . have . property ( 'signatureShareRound3' ) ;
368360 } ) ;
369361
362+ it ( 'validateAdata accepts v2 envelopes with matching adata and domain separator' , async function ( ) {
363+ const adata = 'txhash:m/0/1' ;
364+ const domainSep = 'DKLS23_SIGNING_ROUND1_STATE' ;
365+ const ct = await bitgo . encryptAsync ( {
366+ input : 'test-data' ,
367+ password : 'testpass' ,
368+ encryptionVersion : 2 ,
369+ adata : `${ domainSep } :${ adata } ` ,
370+ } ) ;
371+
372+ ( tssUtils as any ) . validateAdata ( adata , ct , domainSep ) ;
373+ } ) ;
374+
370375 it ( 'validateAdata rejects v2 envelopes with mismatched adata' , async function ( ) {
376+ const domainSep = 'DKLS23_SIGNING_ROUND1_STATE' ;
371377 const ct = await bitgo . encryptAsync ( {
372378 input : 'test-data' ,
373379 password : 'testpass' ,
374380 encryptionVersion : 2 ,
375- adata : ' context-A' ,
381+ adata : ` ${ domainSep } : context-A` ,
376382 } ) ;
377383
378- ( ( ) => ( tssUtils as any ) . validateAdata ( 'context-B' , ct ) ) . should . throw ( / A d a t a d o e s n o t m a t c h / ) ;
384+ ( ( ) => ( tssUtils as any ) . validateAdata ( 'context-B' , ct , domainSep ) ) . should . throw ( / A d a t a d o e s n o t m a t c h / ) ;
379385 } ) ;
380386 } ) ;
381387
0 commit comments