From 966eafc47df639195c98374d3c366c32acd6f231 Mon Sep 17 00:00:00 2001 From: poma Date: Fri, 4 Oct 2019 16:14:25 +0300 Subject: [PATCH] change fromSolidityInput and toSolidityInput so single array proof format --- src/utils.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/utils.js b/src/utils.js index ddc1dcf..17d38e7 100644 --- a/src/utils.js +++ b/src/utils.js @@ -67,9 +67,12 @@ function convertWitness(witness) { function toSolidityInput(proof) { const result = { - pi_a: [proof.pi_a[0], proof.pi_a[1]], - pi_b: [[proof.pi_b[0][1], proof.pi_b[0][0]], [proof.pi_b[1][1], proof.pi_b[1][0]]], - pi_c: [proof.pi_c[0], proof.pi_c[1]], + proof: [ + proof.pi_a[0], proof.pi_a[1], + proof.pi_b[0][1], proof.pi_b[0][0], + proof.pi_b[1][1], proof.pi_b[1][0], + proof.pi_c[0], proof.pi_c[1], + ] }; if (proof.publicSignals) { result.publicSignals = proof.publicSignals; @@ -80,9 +83,9 @@ function toSolidityInput(proof) { function fromSolidityInput(proof) { proof = unhexifyBigInts(proof); const result = { - pi_a: [proof.pi_a[0], proof.pi_a[1], bigInt(1)], - pi_b: [[proof.pi_b[0][1], proof.pi_b[0][0]], [proof.pi_b[1][1], proof.pi_b[1][0]], [bigInt(1), bigInt(0)]], - pi_c: [proof.pi_c[0], proof.pi_c[1], bigInt(1)] + pi_a: [proof.proof[0], proof.proof[1], bigInt(1)], + pi_b: [[proof.proof[3], proof.proof[2]], [proof.proof[5], proof.proof[4]], [bigInt(1), bigInt(0)]], + pi_c: [proof.proof[6], proof.proof[7], bigInt(1)] }; if (proof.publicSignals) { result.publicSignals = proof.publicSignals;