Skip to content

Commit

Permalink
feat: impl compressor12 (#34)
Browse files Browse the repository at this point in the history
* feat: pil2circom, r1cs2plonk

* chore: develop

* feat: pil2circom, r1cs2plonk

* chore: develop

* chore: develop

* chore: develop

* feat: pil2circom, r1cs2plonk
  • Loading branch information
eigmax authored Dec 29, 2022
1 parent bad0179 commit 6278acf
Show file tree
Hide file tree
Showing 12 changed files with 1,747 additions and 13 deletions.
14 changes: 5 additions & 9 deletions starkjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,19 @@ PIL compiler and Circom transpiler. The stark prover is [starky](../starky).
### Generate Polynomial

```
npm run pc
npm run fib
```
will generate the PIL json, Commitment Polynomial file and Constant Polynomial file.

### Generate the Stark proof's circuits

```
../target/debug/zkit stark_prove -s ../starky/data/starkStruct.json.2 \
-p ../starky/data/pe.pil.json \
-o ../starky/data/pe.const \
-m ../starky/data/pe.cm
../target/release/zkit stark_prove -s ../starky/data/starkStruct.json.gl \
-p /tmp/fib.pil.json \
-o /tmp/fib.const \
-m /tmp/fib.cm -c circuits/stark_verifier.circom
```

### Generate Circom file

TODO

### Compile verifier and generate snark proof
```
cd ../test
Expand Down
2 changes: 1 addition & 1 deletion starkjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"pilcom": "^0.0.18",
"tmp-promise": "3.0.3",
"json-bigint": "^1.0.0",
"pil-stark": "0.0.48"
"pil-stark": "0.0.44"
},
"files": [
"index.js",
Expand Down
3 changes: 3 additions & 0 deletions starky/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ thiserror="1.0"
log = "0.4.0"
env_logger = "0.10"

# R1CS
plonky = { package="plonky", path = "../plonky", version = "0.0.1" }

[dev-dependencies]
criterion = "0.4"
pprof = { version = "0.3", features = ["flamegraph"] }
Expand Down
4 changes: 4 additions & 0 deletions starky/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ pub mod polsarray;
mod traits;
pub mod types;

pub mod stark_verifier_gl_circom;

pub mod linearhash;
pub mod linearhash_bn128;

Expand Down Expand Up @@ -43,6 +45,8 @@ mod starkinfo_map;
pub mod transcript;
pub mod transcript_bn128;

pub mod pil2circom;

#[macro_use]
extern crate serde_json;

Expand Down
39 changes: 39 additions & 0 deletions starky/src/pil2circom.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
use crate::digest::ElementDigest;
use crate::errors::Result;
use crate::starkinfo::Program;
use crate::starkinfo::StarkInfo;
use crate::types::{StarkStruct, PIL};

pub struct StarkOption {
pub enable_input: bool,
pub verkey_input: bool,
pub skip_main: bool,
}

pub fn pil2circom(
pil: &PIL,
const_root: &ElementDigest,
stark_struct: &StarkStruct,
starkinfo: &mut StarkInfo,
program: &mut Program,
options: &StarkOption,
) -> Result<String> {
starkinfo.set_code_dimensions_first(&mut program.verifier_code)?;
starkinfo.set_code_dimensions_first(&mut program.verifier_query_code)?;

let res;
if stark_struct.verificationHashType.as_str() == "GL" {
res = crate::stark_verifier_gl_circom::render(
starkinfo,
program,
pil,
stark_struct,
const_root,
options,
);
} else {
panic!("BN128 not supported");
}

return Ok(res);
}
7 changes: 7 additions & 0 deletions starky/src/r1cs2plonk.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use crate::f3g::F3G;
use plonky::r1cs_file::R1CSFile;
use plonky::reader::load_r1cs;

pub fn r1cs2plonk(r1cs: &R1CSFile) {

}
Loading

0 comments on commit 6278acf

Please sign in to comment.