Skip to content

Commit

Permalink
fix: issue due to nullifier root and commitment root in wrong order i…
Browse files Browse the repository at this point in the history
…n the contract
  • Loading branch information
lydiagarms committed May 28, 2024
1 parent 6c5a61a commit 2d65562
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,11 @@ class ContractBoilerplateGenerator {
params?.forEach(circuitParamNode => {
switch (circuitParamNode.bpType) {
case 'nullification':
if (!newList.includes('nullifierRoot'))
newList.push('nullifierRoot');
if (circuitParamNode.isNullified) {
if (!newList.includes('nullifierRoot'))
newList.push('nullifierRoot')
if (!newList.includes('newNullifierRoot'))
newList.push('newNullifierRoot');
newList.push('nullifier');

}
Expand Down Expand Up @@ -175,7 +177,7 @@ class ContractBoilerplateGenerator {
}
circuitParams[ functionName ] = parameterList;
}
const constructorContainsSecret = Object.values(this.scope.bindings).some((binding: any) => binding.node.kind === 'constructor')
const constructorContainsSecret = Object.values(this.scope.bindings).some((binding: any) => binding.node.kind === 'constructor');
return { nullifiersRequired, oldCommitmentAccessRequired, newCommitmentsRequired, containsAccessedOnlyState, encryptionRequired, constructorContainsSecret, circuitParams, isjoinSplitCommitmentsFunction};
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ class ContractBoilerplateGenerator {
switch (input) {
case 'nullifierRoot':
verifyInput.push( `
inputs[k++] = _inputs.nullifierRoot;`);
inputs[k++] = _inputs.nullifierRoot;`);
break;
case 'newNullifierRoot':
verifyInput.push( `
inputs[k++] = _inputs.latestNullifierRoot;`);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -820,15 +820,14 @@ export const OrchestrationCodeBoilerPlate: any = (node: any) => {
// params[1] = arr of commitment root(s)
// params[2] = arr of nullifiers
// params[3] = arr of commitments
if (params[0][0][0]) params[0][0] = `${params[0][0][0]},${params[0][0][1]},`; // nullifierRoot - array

if (params[0][0][0]) params[0][0] = `${params[0][0][0]},${params[0][0][1]},`; // nullifierRoot - array
if (params[0][2][0]) params[0][2] = `${params[0][2][0]},`; // commitmentRoot - array
if (params[0][1][0]) params[0][1] = `[${params[0][1]}],`; // nullifiers - array
if (params[0][3][0]) params[0][3] = `[${params[0][3]}],`; // commitments - array
if (params[0][4][0]) params[0][4] = `[${params[0][4]}],`; // cipherText - array of arrays
if (params[0][5][0]) params[0][5] = `[${params[0][5]}],`; // cipherText - array of arrays


if (node.functionName === 'cnstrctr') return {
statements: [
`\n\n// Save transaction for the constructor:
Expand Down

0 comments on commit 2d65562

Please sign in to comment.