@@ -56,7 +56,9 @@ library TxGen {
56
56
RiscZeroMockVerifier mockVerifier ,
57
57
bytes32 commitmentTreeRoot , // historical root
58
58
Resource memory consumed ,
59
- Resource memory created
59
+ uint256 consumedValueCommitmentRandomness ,
60
+ Resource memory created ,
61
+ uint256 createdValueCommitmentRandomness
60
62
) internal returns (Compliance.VerifierInput memory unit ) {
61
63
bytes32 nf = nullifier (consumed, 0 );
62
64
bytes32 cm = commitment (created);
@@ -68,7 +70,7 @@ library TxGen {
68
70
kind: kind (consumed),
69
71
quantity: consumed.quantity,
70
72
consumed: true ,
71
- valueCommitmentRandomness: 1
73
+ valueCommitmentRandomness: consumedValueCommitmentRandomness
72
74
})
73
75
);
74
76
// Construct the delta for creation based on kind and quantity
@@ -80,7 +82,7 @@ library TxGen {
80
82
kind: kind (created),
81
83
quantity: created.quantity,
82
84
consumed: false ,
83
- valueCommitmentRandomness: 1
85
+ valueCommitmentRandomness: createdValueCommitmentRandomness
84
86
})
85
87
)
86
88
);
@@ -151,7 +153,9 @@ library TxGen {
151
153
mockVerifier: mockVerifier,
152
154
commitmentTreeRoot: initialRoot (),
153
155
consumed: consumed[i].resource,
154
- created: created[i].resource
156
+ consumedValueCommitmentRandomness: 1 ,
157
+ created: created[i].resource,
158
+ createdValueCommitmentRandomness: 1
155
159
});
156
160
}
157
161
action = Action ({logicVerifierInputs: logicVerifierInputs, complianceVerifierInputs: complianceVerifierInputs});
@@ -316,66 +320,35 @@ library TxGen {
316
320
bytes32 actionTreeRoot = actionTreeTags.computeRoot ();
317
321
// Create logic and compliance verifier inputs
318
322
for (uint256 i = 0 ; i < truncatedResources.length ; i++ ) {
323
+ uint256 index = (i * 2 );
324
+
319
325
Resource memory consumedResource = truncatedResources[i][0 ];
320
326
Resource memory createdResource = truncatedResources[i][1 ];
321
- bytes32 nf = nullifier (consumedResource, 0 );
322
- bytes32 cm = commitment (createdResource);
323
-
324
327
// Created logic verifier input for a consumed resource
325
- action.logicVerifierInputs[2 * i] =
326
- Logic.VerifierInput ({tag: nf, verifyingKey: consumedResource.logicRef, proof: "" , appData: appData});
327
- action.logicVerifierInputs[2 * i].proof = mockVerifier.mockProve ({
328
- imageId: consumedResource.logicRef,
329
- journalDigest: sha256 (action.logicVerifierInputs[2 * i].toJournal (actionTreeRoot, true ))
330
- }).seal;
328
+ action.logicVerifierInputs[index] = logicVerifierInput ({
329
+ mockVerifier: mockVerifier,
330
+ actionTreeRoot: actionTreeRoot,
331
+ resource: consumedResource,
332
+ isConsumed: true ,
333
+ appData: appData
334
+ });
331
335
// Create logic verifier input for a created resource
332
- action.logicVerifierInputs[2 * i + 1 ] =
333
- Logic.VerifierInput ({tag: cm, verifyingKey: createdResource.logicRef, proof: "" , appData: appData});
334
- action.logicVerifierInputs[2 * i + 1 ].proof = mockVerifier.mockProve ({
335
- imageId: createdResource.logicRef,
336
- journalDigest: sha256 (action.logicVerifierInputs[2 * i + 1 ].toJournal (actionTreeRoot, false ))
337
- }).seal;
338
- // Create the delta for the consumed resource
339
- Delta.CurvePoint memory unitDelta = DeltaGen.generateInstance (
340
- vm,
341
- DeltaGen.InstanceInputs ({
342
- kind: kind (consumedResource),
343
- quantity: consumedResource.quantity,
344
- consumed: true ,
345
- valueCommitmentRandomness: params.valueCommitmentRandomness[i][0 ]
346
- })
347
- );
348
-
349
- // Add the delta for the created resource
350
- unitDelta = Delta.add (
351
- unitDelta,
352
- DeltaGen.generateInstance (
353
- vm,
354
- DeltaGen.InstanceInputs ({
355
- kind: kind (createdResource),
356
- quantity: createdResource.quantity,
357
- consumed: false ,
358
- valueCommitmentRandomness: params.valueCommitmentRandomness[i][1 ]
359
- })
360
- )
361
- );
362
- // Create the compliance verifier input
363
- Compliance.Instance memory instance = Compliance.Instance ({
364
- unitDeltaX: bytes32 (unitDelta.x),
365
- unitDeltaY: bytes32 (unitDelta.y),
366
- consumed: Compliance.ConsumedRefs ({
367
- nullifier: nf,
368
- logicRef: consumedResource.logicRef,
369
- commitmentTreeRoot: initialRoot ()
370
- }),
371
- created: Compliance.CreatedRefs ({commitment: cm, logicRef: createdResource.logicRef})
336
+ action.logicVerifierInputs[index + 1 ] = logicVerifierInput ({
337
+ mockVerifier: mockVerifier,
338
+ actionTreeRoot: actionTreeRoot,
339
+ resource: createdResource,
340
+ isConsumed: false ,
341
+ appData: appData
372
342
});
373
- action.complianceVerifierInputs[i] = Compliance.VerifierInput ({
374
- instance: instance,
375
- proof: mockVerifier.mockProve ({
376
- imageId: Compliance._VERIFYING_KEY,
377
- journalDigest: sha256 (instance.toJournal ())
378
- }).seal
343
+ // Create compliance verifier input for the resource pairs
344
+ action.complianceVerifierInputs[i] = complianceVerifierInput ({
345
+ vm: vm,
346
+ mockVerifier: mockVerifier,
347
+ commitmentTreeRoot: initialRoot (),
348
+ consumed: consumedResource,
349
+ consumedValueCommitmentRandomness: params.valueCommitmentRandomness[i][0 ],
350
+ created: createdResource,
351
+ createdValueCommitmentRandomness: params.valueCommitmentRandomness[i][1 ]
379
352
});
380
353
}
381
354
}
0 commit comments