From 216189e4bedcf06ceb8589029c859663a9c272b8 Mon Sep 17 00:00:00 2001 From: David Wong Date: Tue, 1 Aug 2023 13:04:41 -0700 Subject: [PATCH] add function to get output out of witness --- c/tester.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/c/tester.js b/c/tester.js index 26922ad..d58913e 100644 --- a/c/tester.js +++ b/c/tester.js @@ -196,6 +196,29 @@ class CTester { return lines.join("\n"); } + // get output out of the witness + async getOutput(witness) { + const self = this; + if (!self.symbols) await self.loadSymbols(); + + let result = []; + for (let i = 0; true; i++) { + const tmp = self.symbols[`main.out[${i}]`]; + if (tmp === undefined) { + break; + } + result.push(witness[tmp.varIdx].toString()); + } + + if(result.length == 0) { + assert(false, "No output found"); + } else if(result.length == 1) { + return result[0]; + } else { + return result; + } + } + async checkConstraints(witness) { const self = this; if (!self.constraints) await self.loadConstraints();