From a47a3cdbbced0c4b9c1d69bd619211e96862eba7 Mon Sep 17 00:00:00 2001 From: SwatiRawal <97442865+SwatiEY@users.noreply.github.com> Date: Mon, 3 Jul 2023 16:56:53 +0100 Subject: [PATCH] Changed zokrates for compile and setup (#197) * feat: changed zokrates for compile and setup * fix: fixed action test * fix: fixed action test * fix: fixed action test * fix: fixed action test * fix: fixed vk * fix: modified action test * fix: possible fix for zokrates-worker * fix: added a fix for encrypted events * chore : updated the readme --------- Co-authored-by: Miranda Wood --- .github/workflows/main.yml | 3 ++- README.md | 3 ++- src/boilerplate/common/generic-test.mjs | 2 +- src/boilerplate/common/migrations/2_shield.js | 7 ++++++- src/boilerplate/common/zokrates.mjs | 2 +- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 831723066..7d7e5e9db 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -62,10 +62,11 @@ jobs: - name: run zapp npm apitest run: npx mocha --exit --timeout 50000 --require @babel/register apitest.js - + - name: disp logs on failure if: failure() run: | docker logs assign_zokrates_1 docker logs if-statement_zokrates_1 docker logs internalFunctionCallTest1_zokrates_1 + diff --git a/README.md b/README.md index be59972c4..b89668ad3 100644 --- a/README.md +++ b/README.md @@ -356,7 +356,8 @@ The configuration can be done during `./bin/setup` phase in the following way. ### Zokrates Worker -Starlight uses containerised zokrates from [zokrates-worker-starlight](https://github.com/EYBlockchain/starlight/pkgs/container/zokrates-worker-starlight) which is built from repo [zokrates-worker](https://github.com/EYBlockchain/zokrates-worker/tree/hari/starlight). +Starlight uses containerised zokrates from [zokrates-worker-starlight](https://github.com/EYBlockchain/starlight/pkgs/container/zokrates-worker-starlight). +Here we have use two zokrates container, zokrates -version:0.7.12 to compile the circuits and zokrates -version:0.8.1 to do the setup and generate-proof to improve the key and proof generation time. ### Contributing diff --git a/src/boilerplate/common/generic-test.mjs b/src/boilerplate/common/generic-test.mjs index 18f896382..57bd6875c 100644 --- a/src/boilerplate/common/generic-test.mjs +++ b/src/boilerplate/common/generic-test.mjs @@ -46,7 +46,7 @@ describe('FUNCTION_NAME', async function () { console.log(`Merkle tree event returnValues:`); console.log(tx.returnValues[0]); } - if (encEvent.event) { + if (encEvent[0].event) { encryption.msgs = encEvent[0].returnValues[0]; encryption.key = encEvent[0].returnValues[1]; console.log("EncryptedMsgs:"); diff --git a/src/boilerplate/common/migrations/2_shield.js b/src/boilerplate/common/migrations/2_shield.js index 067866d18..65636691e 100644 --- a/src/boilerplate/common/migrations/2_shield.js +++ b/src/boilerplate/common/migrations/2_shield.js @@ -7,11 +7,16 @@ CUSTOM_PROOF_IMPORT const CONTRACT_NAME = artifacts.require("CONTRACT_NAME"); const functionNames = [FUNCTION_NAMES]; const vkInput = []; +let vk = []; functionNames.forEach(name => { const vkJson = JSON.parse( fs.readFileSync(`/app/orchestration/common/db/${name}_vk.key`, 'utf-8'), ); - const vk = Object.values(vkJson).flat(Infinity); + if (vkJson.scheme) { + vk = Object.values(vkJson).slice(2).flat(Infinity); + } else { + vk = Object.values(vkJson).flat(Infinity); + } vkInput.push(vk); }); diff --git a/src/boilerplate/common/zokrates.mjs b/src/boilerplate/common/zokrates.mjs index 1ff4ddb0a..47b36e8c4 100644 --- a/src/boilerplate/common/zokrates.mjs +++ b/src/boilerplate/common/zokrates.mjs @@ -49,7 +49,7 @@ export const generateProof = async (functionName, inputs) => { */ export const generateKeys = async circuitFileName => { const filepath = `${circuitFileName}`; - // logger.info('Generating Keys for Circuit: ', circuitFileName); + //logger.info('Generating Keys for Circuit: ', circuitFileName); try { const axiosConfig = { method: 'post',