Skip to content

Commit

Permalink
fix: bug for internal function calls where non-secret parameters that…
Browse files Browse the repository at this point in the history
… interact with a secret only within the internal function call are marked as not interacting with the secret and so not input to the proof in the orchestration
  • Loading branch information
lydiagarms committed May 13, 2024
1 parent 2d60350 commit 89498ae
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/transformers/visitors/toOrchestrationVisitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ const addPublicInput = (path: NodePath, state: any, IDnode: any) => {

// if the node is the indexExpression, we dont need its value in the circuit
state.publicInputs ??= [];
if (!(path.containerName === 'indexExpression' && !(path.parentPath.isSecret|| path.parent.containsSecret))) state.publicInputs.push(node);
if (!(path.containerName === 'indexExpression' && !(path.parentPath.isSecret|| path.parent.containsSecret))) state.publicInputs.push(node);
}

if (['Identifier', 'IndexAccess'].includes(node.indexExpression?.nodeType)) addPublicInput(NodePath.getPath(node.indexExpression), state, null);
Expand Down Expand Up @@ -598,7 +598,6 @@ const visitor = {
indicator: stateVarIndicator,
});
}

if (secretModified || accessedOnly) {
newNodes.generateProofNode.privateStates[
name
Expand Down Expand Up @@ -1357,8 +1356,18 @@ const visitor = {
// we now have a param or a local var dec
let interactsWithSecret = false;

if (scope.bindings[node.id].referencingPaths.some(refPath => refPath.node.interactsWithSecret))
interactsWithSecret = true;
scope.bindings[node.id].referencingPaths.forEach(refPath => {
interactsWithSecret ||= refPath.node.interactsWithSecret;
// check for internal function call if the parameter passed in the function call interacts with secret or not
if(refPath.parentPath.isInternalFunctionCall()){
refPath.parentPath.node.arguments?.forEach((element, index) => {
if(node.id === element.referencedDeclaration) {
let key = (Object.keys((refPath.getReferencedPath(refPath.parentPath.node?.expression) || refPath.parentPath).scope.bindings)[index]);
interactsWithSecret ||= refPath.getReferencedPath(refPath.parentPath.node?.expression)?.scope.indicators[key]?.interactsWithSecret
}
})
}
});

if (
parent.nodeType === 'VariableDeclarationStatement' &&
Expand Down

0 comments on commit 89498ae

Please sign in to comment.