From 89498aea597055db1f1e444e7344538d56736907 Mon Sep 17 00:00:00 2001 From: Lydia Garms Date: Mon, 13 May 2024 18:18:03 +0100 Subject: [PATCH] fix: bug for internal function calls where non-secret parameters that 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 --- .../visitors/toOrchestrationVisitor.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/transformers/visitors/toOrchestrationVisitor.ts b/src/transformers/visitors/toOrchestrationVisitor.ts index f995df9a4..63a4e21ac 100644 --- a/src/transformers/visitors/toOrchestrationVisitor.ts +++ b/src/transformers/visitors/toOrchestrationVisitor.ts @@ -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); @@ -598,7 +598,6 @@ const visitor = { indicator: stateVarIndicator, }); } - if (secretModified || accessedOnly) { newNodes.generateProofNode.privateStates[ name @@ -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' &&