diff --git a/Cargo.toml b/Cargo.toml
index e5ef798..ca1ae25 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -24,6 +24,7 @@ ark-serialize = { version = "^0.5.0", default-features = false }
rand = "0.8.5"
rand_core = {version = "0.6", default-features = false}
base64 = "0.22.1"
+lz4_flex = { version = "0.11" } # compression
folding-schemes = { git = "https://github.com/privacy-scaling-explorations/sonobe", package = "folding-schemes", features=["light-test"], rev="c6f1a246e0705582a75de6becf4ad21f325fa5a1"}
arkeddsa = { git = "https://github.com/arnaucube/arkeddsa", features=["r1cs"], rev="0a9ea7ac1df07363af0fda723e313e775563b9f4"}
diff --git a/README.md b/README.md
index 4814bb0..068de82 100644
--- a/README.md
+++ b/README.md
@@ -3,6 +3,7 @@ Follows the ideas of ETHdos (https://ethdos.xyz/blog), but using folding schemes
It uses Sonobe under the hood, compiled to WASM.
## Usage
+- requirements: [rust](https://rustup.rs/), [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/)
- run native tests: `cargo test --release -- --nocapture`
- build wasm: `wasm-pack build --target web`
- serve the web: `python -m http.server 8080`
diff --git a/src/fcircuit.rs b/src/fcircuit.rs
index 811c5a6..e239eda 100644
--- a/src/fcircuit.rs
+++ b/src/fcircuit.rs
@@ -115,7 +115,7 @@ pub mod tests {
const N: usize = 1;
let ext_inps = gen_signatures::(&mut rng, &poseidon_config, 1);
- let e = ext_inps[0].clone();
+ let e = ext_inps[0];
let msg = hash_pk(&poseidon_config, e.pk);
@@ -143,7 +143,7 @@ pub mod tests {
let circuit = FC::new(poseidon_config).unwrap();
let xy: (Fr, Fr) = pks_sigs[0].pk.0.xy().unwrap();
let pk0 = vec![xy.0, xy.1];
- let z_i: Vec = vec![pk0.clone(), pk0, vec![Fr::zero()]].concat();
+ let z_i: Vec = [pk0.clone(), pk0, vec![Fr::zero()]].concat();
let external_inputs_var =
SigPkVar::::new_witness(cs.clone(), || Ok(pks_sigs[0]))
diff --git a/src/lib.rs b/src/lib.rs
index 7a8fbb2..1b7a21d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -171,16 +171,23 @@ pub fn fold_sigs(params: Vec, sigs_pks: Vec) -> String {
ivc_proof
.serialize_compressed(&mut ivc_proof_bytes)
.unwrap();
+
+ let ivc_proof_bytes_comp = lz4_flex::block::compress_prepend_size(&ivc_proof_bytes);
+
dbg(format!(
- "ivc_proof size: {} mb",
+ "ivc_proof size (uncompressed): {} mb",
ivc_proof_bytes.len() / (1024 * 1024)
));
+ dbg(format!(
+ "ivc_proof size (compressed): {} mb",
+ ivc_proof_bytes_comp.len() / (1024 * 1024)
+ ));
- b64.encode(ivc_proof_bytes)
+ b64.encode(ivc_proof_bytes_comp)
}
#[wasm_bindgen]
-pub fn verify_proof(verifier_params: String, ivc_proof: String) -> String {
+pub fn verify_proof(verifier_params: String, ivc_proof_b64: String) -> String {
let poseidon_config = poseidon_canonical_config::();
let vp = FS::vp_deserialize_with_mode(
@@ -190,13 +197,14 @@ pub fn verify_proof(verifier_params: String, ivc_proof: String) -> String {
poseidon_config.clone(), // fcircuit_params
)
.unwrap();
- // let proof =
- // FS::IVCProof::deserialize_compressed(b64.decode(ivc_proof).unwrap().as_slice()).unwrap();
+ let ivc_proof_bytes_comp = b64.decode(ivc_proof_b64).unwrap();
+ let ivc_proof_bytes =
+ lz4_flex::block::decompress_size_prepended(&ivc_proof_bytes_comp).unwrap();
let proof = , Pedersen, false> as FoldingScheme<
G1,
G2,
FC,
- >>::IVCProof::deserialize_compressed(b64.decode(ivc_proof).unwrap().as_slice())
+ >>::IVCProof::deserialize_compressed(ivc_proof_bytes.as_slice())
.unwrap();
FS::verify(
@@ -212,6 +220,7 @@ mod tests {
use ark_bn254::{Fr, G1Projective as G1};
use ark_ec::AffineRepr;
use ark_grumpkin::Projective as G2;
+ use ark_serialize::CanonicalSerialize;
use ark_std::Zero;
use rand::rngs::OsRng;
@@ -250,7 +259,7 @@ mod tests {
// set the initial state
let xy = pks_sigs[0].pk.0.xy().unwrap();
let pk0 = vec![xy.0, xy.1];
- let z_0: Vec = vec![pk0.clone(), pk0, vec![Fr::zero()]].concat();
+ let z_0: Vec = [pk0.clone(), pk0, vec![Fr::zero()]].concat();
type FC = EthDosCircuit;
let f_circuit = FC::new(poseidon_config.clone()).unwrap();
@@ -271,9 +280,10 @@ mod tests {
// run n steps of the folding iteration
let start_full = get_time();
+ #[allow(clippy::needless_range_loop)]
for i in 0..N_STEPS {
let start = get_time();
- nova.prove_step(rng, pks_sigs[i].clone(), None).unwrap();
+ nova.prove_step(rng, pks_sigs[i], None).unwrap();
dbg(format!("Nova::prove_step {}: {:?}", nova.i, elapsed(start)));
}
dbg(format!(
@@ -287,8 +297,23 @@ mod tests {
dbg!(&ivc_proof.z_i);
FS::verify(
nova_params.1.clone(), // Nova's verifier params
- ivc_proof,
+ ivc_proof.clone(),
)
.unwrap();
+
+ // print IVCProof size (uncompressed & compressed)
+ let mut ivc_proof_bytes = vec![];
+ ivc_proof
+ .serialize_compressed(&mut ivc_proof_bytes)
+ .unwrap();
+ let ivc_proof_bytes_comp = lz4_flex::block::compress_prepend_size(&ivc_proof_bytes);
+ dbg(format!(
+ "ivc_proof size (uncompressed): {} mb",
+ ivc_proof_bytes.len() / (1024 * 1024)
+ ));
+ dbg(format!(
+ "ivc_proof size (compressed): {} mb",
+ ivc_proof_bytes_comp.len() / (1024 * 1024)
+ ));
}
}