Browse Source

WIP: Lightweight version of `ark-circom` (#41)

* remove ethers-core

* test

* return ethereum and add a feature

* lint fixes

---------

Co-authored-by: s1fr0 <28568419+s1fr0@users.noreply.github.com>
Co-authored-by: tyshkor <tyshko1@gmail.com>
pull/3/head
tyshko-rostyslav 1 year ago
committed by GitHub
parent
commit
5a1b78b320
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 482 additions and 352 deletions
  1. +474
    -346
      Cargo.lock
  2. +5
    -3
      Cargo.toml
  3. +1
    -1
      src/circom/r1cs_reader.rs
  4. +1
    -0
      src/lib.rs
  5. +1
    -2
      src/witness/witness_calculator.rs

+ 474
- 346
Cargo.lock
File diff suppressed because it is too large
View File


+ 5
- 3
Cargo.toml

@ -26,11 +26,12 @@ hex = "0.4.3"
byteorder = "1.4.3"
# ethereum compat
ethers-core = { git = "https://github.com/gakonst/ethers-rs", default-features = false }
ethers-core = { git = "https://github.com/gakonst/ethers-rs", default-features = false, optional = true }
ethers = { git = "https://github.com/gakonst/ethers-rs", features = ["abigen"], optional = true }
# error handling
thiserror = "1.0.26"
color-eyre = "0.5"
color-eyre = "0.6.1"
criterion = "0.3.4"
cfg-if = "1.0"
@ -39,7 +40,6 @@ cfg-if = "1.0"
hex-literal = "0.2.1"
tokio = { version = "1.7.1", features = ["macros"] }
serde_json = "1.0.64"
ethers = { git = "https://github.com/gakonst/ethers-rs", features = ["abigen"] }
[[bench]]
name = "groth16"
@ -48,3 +48,5 @@ harness = false
[features]
bench-complex-all = []
circom-2 = []
full = ["ethers", "ethers-core"]
default = ["full"]

+ 1
- 1
src/circom/r1cs_reader.rs

@ -73,7 +73,7 @@ impl R1CSFile {
for _ in 0..num_sections {
let sec_type = reader.read_u32::<LittleEndian>()?;
let sec_size = reader.read_u64::<LittleEndian>()?;
let offset = reader.seek(SeekFrom::Current(0))?;
let offset = reader.stream_position()?;
sec_offsets.insert(sec_type, offset);
sec_sizes.insert(sec_type, sec_size);
reader.seek(SeekFrom::Current(sec_size as i64))?;

+ 1
- 0
src/lib.rs

@ -7,6 +7,7 @@ pub use witness::WitnessCalculator;
pub mod circom;
pub use circom::{CircomBuilder, CircomCircuit, CircomConfig, CircomReduction};
#[cfg(feature = "full")]
pub mod ethereum;
mod zkey;

+ 1
- 2
src/witness/witness_calculator.rs

@ -313,8 +313,7 @@ mod runtime {
// NOTE: We can also get more information why it is failing, see p2str etc here:
// https://github.com/iden3/circom_runtime/blob/master/js/witness_calculator.js#L52-L64
println!(
"runtime error, exiting early: {0} {1} {2} {3} {4} {5}",
a, b, c, d, e, f
"runtime error, exiting early: {a} {b} {c} {d} {e} {f}",
);
Err(RuntimeError::user(Box::new(ExitCode(1))))
}

Loading…
Cancel
Save