Skip to content

Commit

Permalink
fix(circom): Light client fix commitment bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimo99 authored and zah committed Mar 9, 2023
1 parent 4f0225d commit 06ccdb8
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 61 deletions.
2 changes: 1 addition & 1 deletion beacon-light-client/circom/circuits/light_client.circom
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ template LightClient(N) {
component bits2num1 = Bits2Num(253);

for(var i = 0; i < 253; i++) {
bits2num1.in[i] <== commitment.out[253 - i];
bits2num1.in[i] <== commitment.out[252 - i];
}

component bits2Num2 = Bits2Num(3);
Expand Down
4 changes: 2 additions & 2 deletions beacon-light-client/circom/scripts/light_client/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"redisPort": 6379,
"beaconRestApiHost": "192.168.1.116",
"beaconRestApiPort": 4000,
"rapidSnarkProverPath": "../../../../vendor/rapidsnark/build/prover",
"zkeyFilePath": "../../build/light_client/light_client_0.zkey",
"rapidSnarkProverPath": "../../../../../vendor/rapidsnark/build/prover",
"zkeyFilePath": "../../../build/light_client/light_client_0.zkey",
"witnessGeneratorPath": "../../../build/light_client/light_client_cpp/light_client",
"updatePolingTime": 60000
}
2 changes: 1 addition & 1 deletion beacon-light-client/circom/scripts/light_client/state.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"lastDownloadedUpdate":157604,"lastUpdateOnChain":157463}
{"lastDownloadedUpdate":185668,"lastUpdateOnChain":157463}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
RELAYER_WITNESSES_FOLDER,
PROOF_GENERATOR_QUEUE,
RELAYER_INPUTS_FOLDER,
RELAYER_PROOFS_FOLDER,
} from '../relayer-helper';
import * as config from '../config.json';

Expand Down Expand Up @@ -40,18 +41,24 @@ new Worker<ProofInputType>(
)}`,
);

// await exec(
// `${RAPIDSNARK_PROVER_PATH} ${ZKEY_FILE_PATH} ${path.join(
// RELAYER_WITNESSES_FOLDER,
// `witness_${job.data.prevUpdateSlot}_${job.data.updateSlot}.wtns`,
// )} ${path.join(
// RELAYER_PROOFS_FOLDER,
// `proof_${job.data.prevUpdateSlot}_${job.data.updateSlot}.json`,
// )} ${path.join(
// RELAYER_PROOFS_FOLDER,
// `public_${job.data.prevUpdateSlot}_${job.data.updateSlot}.json`,
// )}`,
// );
await exec(
`${config.rapidSnarkProverPath} ${config.zkeyFilePath} ${path.join(
__dirname,
'..',
RELAYER_WITNESSES_FOLDER,
`witness_${job.data.prevUpdateSlot}_${job.data.updateSlot}.wtns`,
)} ${path.join(
__dirname,
'..',
RELAYER_PROOFS_FOLDER,
`proof_${job.data.prevUpdateSlot}_${job.data.updateSlot}.json`,
)} ${path.join(
__dirname,
'..',
RELAYER_PROOFS_FOLDER,
`public_${job.data.prevUpdateSlot}_${job.data.updateSlot}.json`,
)}`,
);

// remove witness as it is huge unneeded file
await rm(
Expand All @@ -73,6 +80,6 @@ new Worker<ProofInputType>(
host: config.redisHost,
port: config.redisPort,
},
concurrency: 4,
concurrency: 1,
},
);
45 changes: 1 addition & 44 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4106,7 +4106,7 @@ __metadata:
ethers: ^5.6.4
hardhat: ^2.9.3
snarkit2: "https://github.com/fluidex/snarkit2#70142d8bbc5ec79cfa6869205263ff77e8423975"
snarkjs: 0.4.24
snarkjs: "github:metacraft-labs/snarkjs"
ts-node: ^10.9.1
languageName: unknown
linkType: soft
Expand Down Expand Up @@ -4135,17 +4135,6 @@ __metadata:
languageName: node
linkType: hard

"circom_runtime@npm:0.1.18":
version: 0.1.18
resolution: "circom_runtime@npm:0.1.18"
dependencies:
ffjavascript: 0.2.55
bin:
calcwit: calcwit.js
checksum: 77169a1289359b2eb91805c74d82f4623d6b91d795d7319bee1ee6afd5ac24b8bfe675a0d03ba8820599293dcddfbe1621e66e2075516fa6e7c1ec15fa16c661
languageName: node
linkType: hard

"circom_runtime@npm:0.1.20":
version: 0.1.20
resolution: "circom_runtime@npm:0.1.20"
Expand Down Expand Up @@ -9059,18 +9048,6 @@ __metadata:
languageName: node
linkType: hard

"r1csfile@npm:0.0.36":
version: 0.0.36
resolution: "r1csfile@npm:0.0.36"
dependencies:
"@iden3/bigarray": 0.0.2
"@iden3/binfileutils": 0.0.11
fastfile: 0.0.20
ffjavascript: 0.2.55
checksum: 6b0bdb036b4692f3926d8317169edad1629ff2a790d9244d2958b714427fef5602fee9c81edfe5486f61882adc45cae095c6e5a2329a2a93210e9284f42b33ad
languageName: node
linkType: hard

"r1csfile@npm:0.0.37":
version: 0.0.37
resolution: "r1csfile@npm:0.0.37"
Expand Down Expand Up @@ -9779,26 +9756,6 @@ __metadata:
languageName: node
linkType: hard

"snarkjs@npm:0.4.24":
version: 0.4.24
resolution: "snarkjs@npm:0.4.24"
dependencies:
"@iden3/binfileutils": 0.0.11
bfj: ^7.0.2
blake2b-wasm: ^2.4.0
circom_runtime: 0.1.18
ejs: ^3.1.6
fastfile: 0.0.20
ffjavascript: 0.2.55
js-sha3: ^0.8.0
logplease: ^1.2.15
r1csfile: 0.0.36
bin:
snarkjs: build/cli.cjs
checksum: 0af3b17c295532439f0ae018f0a0d5a40653be4cfb9450dd31873bc343d3913f8b04c72da3d2e81778c8a44df1247c7e0d5fe4add4b162203b2946d3e2cf2ceb
languageName: node
linkType: hard

"snarkjs@npm:^0.3.60":
version: 0.3.60
resolution: "snarkjs@npm:0.3.60"
Expand Down

0 comments on commit 06ccdb8

Please sign in to comment.