Skip to content

Commit

Permalink
fix: fix some issues for SM (#76)
Browse files Browse the repository at this point in the history
* chore: upgrade SM

* chore: upgrade SM
  • Loading branch information
eigmax authored Jul 14, 2023
1 parent 07062ab commit f74a68e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
14 changes: 7 additions & 7 deletions SM/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ npm run vm
### Bottom Layer: FRI Proof

```
../target/release/zkit stark_prove -s ./build/proof/starkstruct.json \
../target/release/eigen-zkit stark_prove -s ./build/proof/starkstruct.json \
-p ./circuits/zkvm.pil.json \
-o ./circuits/zkvm.const \
-m ./circuits/zkvm.cm -c circuits/zkvm.circom -i circuits/zkvm.zkin.json
--o ./circuits/zkvm.const \
--m ./circuits/zkvm.cm -c circuits/zkvm.circom --i circuits/zkvm.zkin.json
```

### Recursive Layer: FRI Proof

```
../target/release/zkit compile -p goldilocks -i circuits/zkvm.circom -l node_modules/pil-stark/circuits.gl --O2=full -o /tmp/
../target/release/eigen-zkit compile -p goldilocks -i circuits/zkvm.circom -l node_modules/pil-stark/circuits.gl --O2=full -o /tmp/
node ../starkjs/src/compressor12/main_compressor12_setup.js \
-r /tmp/zkvm.r1cs \
Expand All @@ -38,10 +38,10 @@ node ../starkjs/src/compressor12/main_compressor12_exec.js \
-e /tmp/c12.exec \
-m /tmp/c12.cm
../target/release/zkit stark_prove -s ./tools/zkvm.c12.starkstruct.json \
../target/release/eigen-zkit stark_prove -s ./tools/zkvm.c12.starkstruct.json \
-p /tmp/c12.pil.json \
-o /tmp/c12.const \
-m /tmp/c12.cm -c circuits/circuit.circom -i circuits/circuit.zkin.json
--o /tmp/c12.const \
--m /tmp/c12.cm -c circuits/circuit.circom --i circuits/circuit.zkin.json
```

### Top Layer: Snark proof
Expand Down
6 changes: 3 additions & 3 deletions SM/tools/gen_final_proof.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ echo "2. Generate witness"
node ${WORKSPACE}/${CIRCUIT}_js/generate_witness.js ${WORKSPACE}/${CIRCUIT}_js/$CIRCUIT.wasm ../circuits/${CIRCUIT}.zkin.json $WORKSPACE/witness.wtns

echo "3. Export verification key"
${ZKIT} export_verification_key -s ${SRS} -c $WORKSPACE/$CIRCUIT.r1cs -v $WORKSPACE/vk.bin
${ZKIT} export_verification_key -s ${SRS} -c $WORKSPACE/$CIRCUIT.r1cs --v $WORKSPACE/vk.bin

echo "4. prove"
${ZKIT} prove -c $WORKSPACE/$CIRCUIT.r1cs -w $WORKSPACE/witness.wtns -s ${SRS} -b $WORKSPACE/proof.bin
${ZKIT} prove -c $WORKSPACE/$CIRCUIT.r1cs -w $WORKSPACE/witness.wtns -s ${SRS} --b $WORKSPACE/proof.bin

echo "5. Verify the proof"
${ZKIT} verify -p $WORKSPACE/proof.bin -v $WORKSPACE/vk.bin

echo "6. Generate verifier"
mkdir -p ${CIRCUIT}/contracts
${ZKIT} generate_verifier -v $WORKSPACE/vk.bin -s ${CIRCUIT}/contracts/verifier.sol
${ZKIT} generate_verifier -v $WORKSPACE/vk.bin --s ${CIRCUIT}/contracts/verifier.sol
7 changes: 3 additions & 4 deletions SM/tools/zkvm.c12.starkstruct.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"nBits": 19,
"nBitsExt": 20,
"nBits": 17,
"nBitsExt": 18,
"nQueries": 8,
"verificationHashType": "BN128",
"steps": [
{ "nBits": 20 },
{ "nBits": 15 },
{ "nBits": 18 },
{ "nBits": 11 },
{ "nBits": 7 },
{ "nBits": 4 }
Expand Down
2 changes: 1 addition & 1 deletion starky/src/stark_verifier_circom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ fn unrollCode(code: &Vec<Section>, starkinfo: &StarkInfo) -> (String, String) {
} else if inst.src[0].dim == 1 && inst.src[1].dim == 3 {
str_code.push_str(&format!(
r#"
signal {}[3] <== [{} + {}[0], {}[1]. {}[2]];"#,
signal {}[3] <== [{} + {}[0], {}[1], {}[2]];"#,
ref_(&inst.dest),
ref_(&inst.src[0]),
ref_(&inst.src[1]),
Expand Down

0 comments on commit f74a68e

Please sign in to comment.