@@ -226,6 +226,7 @@ contract ProtocolAdapterMockVerifierTest is Test {
226
226
Resource[2 ][MAX_RESOURCES] resources;
227
227
uint256 [MAX_RESOURCES] bijection;
228
228
uint256 targetResourcesLen;
229
+ uint256 [2 ][MAX_RESOURCES] valueCommitmentRandomness;
229
230
}
230
231
231
232
function commitment (Resource memory resource ) internal pure returns (bytes32 hash ) {
@@ -295,15 +296,20 @@ contract ProtocolAdapterMockVerifierTest is Test {
295
296
}
296
297
// Compute action tree tags and action tree root
297
298
bytes32 [] memory actionTreeTags = new bytes32 [](2 * truncatedResources.length );
299
+ totalValueCommitmentRandomness = 0 ;
298
300
for (uint256 i = 0 ; i < truncatedResources.length ; ++ i) {
299
301
uint256 index = (i * 2 );
300
302
301
303
actionTreeTags[index] = nullifier (truncatedResources[i][0 ], 0 );
302
304
actionTreeTags[index + 1 ] = commitment (truncatedResources[i][1 ]);
305
+ // Adjust and accumulate the value randomness commitments
306
+ params.valueCommitmentRandomness[i][0 ] = bound (params.valueCommitmentRandomness[i][0 ], 1 , SECP256K1_ORDER-1 );
307
+ params.valueCommitmentRandomness[i][1 ] = bound (params.valueCommitmentRandomness[i][1 ], 1 , SECP256K1_ORDER-1 );
308
+ totalValueCommitmentRandomness = addmod (totalValueCommitmentRandomness, params.valueCommitmentRandomness[i][0 ], SECP256K1_ORDER);
309
+ totalValueCommitmentRandomness = addmod (totalValueCommitmentRandomness, params.valueCommitmentRandomness[i][1 ], SECP256K1_ORDER);
303
310
}
304
311
bytes32 actionTreeRoot = actionTreeTags.computeRoot ();
305
312
// Create logic and compliance verifier inputs
306
- totalValueCommitmentRandomness = 0 ;
307
313
for (uint256 i = 0 ; i < truncatedResources.length ; i++ ) {
308
314
Resource memory consumedResource = truncatedResources[i][0 ];
309
315
Resource memory createdResource = truncatedResources[i][1 ];
@@ -339,9 +345,10 @@ contract ProtocolAdapterMockVerifierTest is Test {
339
345
kind: kind (consumedResource),
340
346
quantity: consumedResource.quantity,
341
347
consumed: true ,
342
- valueCommitmentRandomness: 1
348
+ valueCommitmentRandomness: params.valueCommitmentRandomness[i][ 0 ]
343
349
})
344
350
);
351
+
345
352
// Add the delta for the created resource
346
353
unitDelta = Delta.add (
347
354
unitDelta,
@@ -351,11 +358,10 @@ contract ProtocolAdapterMockVerifierTest is Test {
351
358
kind: kind (createdResource),
352
359
quantity: createdResource.quantity,
353
360
consumed: false ,
354
- valueCommitmentRandomness: 1
361
+ valueCommitmentRandomness: params.valueCommitmentRandomness[i][ 1 ]
355
362
})
356
363
)
357
364
);
358
- totalValueCommitmentRandomness += 2 ;
359
365
// Create the compliance verifier input
360
366
Compliance.Instance memory instance = Compliance.Instance ({
361
367
unitDeltaX: bytes32 (unitDelta.x),
@@ -389,7 +395,7 @@ contract ProtocolAdapterMockVerifierTest is Test {
389
395
for (uint256 i = 0 ; i < actions.length ; i++ ) {
390
396
uint256 valueCommitmentRandomness;
391
397
(actions[i], valueCommitmentRandomness) = generateAction (params.actionParams[i]);
392
- totalValueCommitmentRandomness += valueCommitmentRandomness;
398
+ totalValueCommitmentRandomness = addmod (totalValueCommitmentRandomness, valueCommitmentRandomness, SECP256K1_ORDER) ;
393
399
}
394
400
// Generate delta proof
395
401
bytes memory proof = "" ;
0 commit comments