From e47a8238b25b61cb84c122cccdd4755331d85f7b Mon Sep 17 00:00:00 2001 From: Arthur Paulino Date: Tue, 6 Feb 2024 13:42:18 -0300 Subject: [PATCH] chore: migrate examples to the Bn256 field --- examples/circom.rs | 10 +++++----- examples/sha256_ivc.rs | 8 ++++---- examples/sha256_nivc.rs | 8 ++++---- examples/tp_table.rs | 9 ++++----- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/examples/circom.rs b/examples/circom.rs index 5a934a9921..6cd8e2b4c0 100644 --- a/examples/circom.rs +++ b/examples/circom.rs @@ -38,6 +38,7 @@ use lurk::circuit::gadgets::pointer::AllocatedPtr; #[cfg(not(target_arch = "wasm32"))] use lurk::coprocessor::circom::non_wasm::CircomCoprocessor; +use halo2curves::bn256::Fr as Bn; use lurk::eval::lang::Lang; use lurk::field::LurkField; use lurk::lem::{pointers::Ptr, store::Store}; @@ -48,7 +49,6 @@ use lurk::public_parameters::{ }; use lurk::Symbol; use lurk_macros::Coproc; -use pasta_curves::pallas::Scalar as Fr; const REDUCTION_COUNT: usize = 1; @@ -99,17 +99,17 @@ enum Sha256Coproc { /// `cargo run --release -- circom --name sha256_2 examples/sha256/` /// `cargo run --release --example circom` fn main() { - let store = &Store::::default(); + let store = &Store::default(); let sym_str = Symbol::new(&[".circom_sha256_2"], false); // two inputs - let circom_sha256: CircomSha256 = CircomSha256::new(0); - let mut lang = Lang::>::new(); + let circom_sha256: CircomSha256 = CircomSha256::new(0); + let mut lang = Lang::>::new(); lang.add_coprocessor(sym_str, CircomCoprocessor::new(circom_sha256)); let lang_rc = Arc::new(lang); let expr = "(.circom_sha256_2)".to_string(); let ptr = store.read_with_default_state(&expr).unwrap(); - let nova_prover = NovaProver::>::new(REDUCTION_COUNT, lang_rc.clone()); + let nova_prover = NovaProver::>::new(REDUCTION_COUNT, lang_rc.clone()); println!("Setting up public parameters..."); diff --git a/examples/sha256_ivc.rs b/examples/sha256_ivc.rs index ce36b1822c..5151355526 100644 --- a/examples/sha256_ivc.rs +++ b/examples/sha256_ivc.rs @@ -1,4 +1,4 @@ -use pasta_curves::pallas::Scalar as Fr; +use halo2curves::bn256::Fr as Bn; use std::{sync::Arc, time::Instant}; use tracing_subscriber::{fmt, prelude::*, EnvFilter, Registry}; use tracing_texray::TeXRayLayer; @@ -62,16 +62,16 @@ fn main() { let args = std::env::args().collect::>(); let n = args.get(1).unwrap_or(&"1".into()).parse().unwrap(); - let store = &Store::::default(); + let store = &Store::default(); let cproc_sym = user_sym(&format!("sha256_ivc_{n}")); let call = sha256_ivc(store, n, &(0..n).collect::>()); - let mut lang = Lang::>::new(); + let mut lang = Lang::>::new(); lang.add_coprocessor(cproc_sym, Sha256Coprocessor::new(n)); let lang_rc = Arc::new(lang.clone()); - let nova_prover = NovaProver::>::new(REDUCTION_COUNT, lang_rc.clone()); + let nova_prover = NovaProver::>::new(REDUCTION_COUNT, lang_rc.clone()); println!("Setting up public parameters (rc = {REDUCTION_COUNT})..."); diff --git a/examples/sha256_nivc.rs b/examples/sha256_nivc.rs index c7ab304645..e609694859 100644 --- a/examples/sha256_nivc.rs +++ b/examples/sha256_nivc.rs @@ -1,4 +1,4 @@ -use pasta_curves::pallas::Scalar as Fr; +use halo2curves::bn256::Fr as Bn; use std::{sync::Arc, time::Instant}; use tracing_subscriber::{fmt, prelude::*, EnvFilter, Registry}; use tracing_texray::TeXRayLayer; @@ -66,12 +66,12 @@ fn main() { let args = std::env::args().collect::>(); let n = args.get(1).unwrap_or(&"1".into()).parse().unwrap(); - let store = &Store::::default(); + let store = &Store::default(); let cproc_sym = user_sym(&format!("sha256_nivc_{n}")); let call = sha256_nivc(store, n, &(0..n).collect::>()); - let mut lang = Lang::>::new(); + let mut lang = Lang::>::new(); lang.add_coprocessor(cproc_sym, Sha256Coprocessor::new(n)); let lang_rc = Arc::new(lang.clone()); @@ -80,7 +80,7 @@ fn main() { let frames = evaluate(Some((&lurk_step, &cprocs, &lang)), call, store, 1000).unwrap(); let supernova_prover = - SuperNovaProver::>::new(REDUCTION_COUNT, lang_rc.clone()); + SuperNovaProver::>::new(REDUCTION_COUNT, lang_rc.clone()); println!("Setting up running claim parameters (rc = {REDUCTION_COUNT})..."); let pp_start = Instant::now(); diff --git a/examples/tp_table.rs b/examples/tp_table.rs index 588accd9e2..46019663ab 100644 --- a/examples/tp_table.rs +++ b/examples/tp_table.rs @@ -1,13 +1,13 @@ use anyhow::{anyhow, Result}; use ascii_table::{Align, AsciiTable}; use criterion::black_box; +use halo2curves::bn256::Fr as Bn; use lurk::{ eval::lang::{Coproc, Lang}, lem::{eval::evaluate, store::Store}, proof::nova::{public_params, NovaProver, PublicParams}, }; use num_traits::ToPrimitive; -use pasta_curves::pallas::Scalar as Fr; use statrs::statistics::Statistics; use std::{cell::OnceCell, sync::Arc, time::Instant}; @@ -142,7 +142,6 @@ fn n_folds_env() -> Result { /// │ 16 │ 59.38±0.83 │ 56.42±0.63 │ /// └────────────┴────────────┴────────────┘ /// ``` -/// The first table fn main() { let rc_vec = rc_env().unwrap_or_else(|_| vec![100]); let max_n_folds = n_folds_env().unwrap_or(3); @@ -152,12 +151,12 @@ fn main() { let limit = n_iters(max_n_folds, *max_rc); - let store = Store::::default(); + let store = Store::default(); let program = store.read_with_default_state(PROGRAM).unwrap(); - let frames = evaluate::>(None, program, &store, limit).unwrap(); + let frames = evaluate::>(None, program, &store, limit).unwrap(); - let lang = Lang::::new(); + let lang = Lang::::new(); let lang_arc = Arc::new(lang.clone()); let mut data = Vec::with_capacity(rc_vec.len());