@@ -19,6 +19,8 @@ import {
19
19
PrivateKernelInnerCircuitPrivateInputs ,
20
20
PrivateKernelTailCircuitPrivateInputs ,
21
21
type PrivateKernelTailCircuitPublicInputs ,
22
+ type PrivateLog ,
23
+ type ScopedPrivateLogData ,
22
24
type TxRequest ,
23
25
VK_TREE_HEIGHT ,
24
26
VerificationKeyAsFields ,
@@ -37,10 +39,48 @@ import {
37
39
} from '@aztec/protocol-contracts' ;
38
40
39
41
import { type WitnessMap } from '@noir-lang/types' ;
42
+ import { strict as assert } from 'assert' ;
40
43
41
44
import { PrivateKernelResetPrivateInputsBuilder } from './hints/build_private_kernel_reset_private_inputs.js' ;
42
45
import { type ProvingDataOracle } from './proving_data_oracle.js' ;
43
46
47
+ // TODO(#10592): Temporary workaround to check that the private logs are correctly split into non-revertible set and revertible set.
48
+ // This should be done in TailToPublicOutputValidator in private kernel tail.
49
+ function checkPrivateLogs (
50
+ privateLogs : ScopedPrivateLogData [ ] ,
51
+ nonRevertiblePrivateLogs : PrivateLog [ ] ,
52
+ revertiblePrivateLogs : PrivateLog [ ] ,
53
+ splitCounter : number ,
54
+ ) {
55
+ let numNonRevertible = 0 ;
56
+ let numRevertible = 0 ;
57
+ privateLogs
58
+ . filter ( privateLog => privateLog . inner . counter !== 0 )
59
+ . forEach ( privateLog => {
60
+ if ( privateLog . inner . counter < splitCounter ) {
61
+ assert (
62
+ privateLog . inner . log . toBuffer ( ) . equals ( nonRevertiblePrivateLogs [ numNonRevertible ] . toBuffer ( ) ) ,
63
+ `mismatch non-revertible private logs at index ${ numNonRevertible } ` ,
64
+ ) ;
65
+ numNonRevertible ++ ;
66
+ } else {
67
+ assert (
68
+ privateLog . inner . log . toBuffer ( ) . equals ( revertiblePrivateLogs [ numRevertible ] . toBuffer ( ) ) ,
69
+ `mismatch revertible private logs at index ${ numRevertible } ` ,
70
+ ) ;
71
+ numRevertible ++ ;
72
+ }
73
+ } ) ;
74
+ assert (
75
+ nonRevertiblePrivateLogs . slice ( numNonRevertible ) . every ( l => l . isEmpty ( ) ) ,
76
+ 'Unexpected non-empty private log in non-revertible set.' ,
77
+ ) ;
78
+ assert (
79
+ revertiblePrivateLogs . slice ( numRevertible ) . every ( l => l . isEmpty ( ) ) ,
80
+ 'Unexpected non-empty private log in revertible set.' ,
81
+ ) ;
82
+ }
83
+
44
84
const NULL_PROVE_OUTPUT : PrivateKernelSimulateOutput < PrivateKernelCircuitPublicInputs > = {
45
85
publicInputs : PrivateKernelCircuitPublicInputs . empty ( ) ,
46
86
verificationKey : VerificationKeyAsFields . makeEmpty ( CLIENT_IVC_VERIFICATION_KEY_LENGTH_IN_FIELDS ) ,
@@ -225,6 +265,12 @@ export class KernelProver {
225
265
226
266
pushTestData ( 'private-kernel-inputs-ordering' , privateInputs ) ;
227
267
const tailOutput = await this . proofCreator . simulateProofTail ( privateInputs ) ;
268
+ if ( tailOutput . publicInputs . forPublic ) {
269
+ const privateLogs = privateInputs . previousKernel . publicInputs . end . privateLogs ;
270
+ const nonRevertiblePrivateLogs = tailOutput . publicInputs . forPublic . nonRevertibleAccumulatedData . privateLogs ;
271
+ const revertiblePrivateLogs = tailOutput . publicInputs . forPublic . revertibleAccumulatedData . privateLogs ;
272
+ checkPrivateLogs ( privateLogs , nonRevertiblePrivateLogs , revertiblePrivateLogs , validationRequestsSplitCounter ) ;
273
+ }
228
274
229
275
acirs . push ( tailOutput . bytecode ) ;
230
276
witnessStack . push ( tailOutput . outputWitness ) ;
0 commit comments