Skip to content

Commit

Permalink
fix dumb lang test
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurpaulino committed Aug 6, 2023
1 parent c8428bb commit 42b53f6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
15 changes: 6 additions & 9 deletions examples/sha256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use lurk::field::LurkField;
use lurk::proof::{nova::NovaProver, Prover};
use lurk::ptr::Ptr;
use lurk::public_parameters::public_params;
use lurk::state::user_sym;
use lurk::store::Store;
use lurk::sym;
use lurk_macros::Coproc;

use bellperson::gadgets::boolean::{AllocatedBit, Boolean};
Expand Down Expand Up @@ -170,18 +170,15 @@ fn main() {
u.reverse();

let store = &mut Store::<Fr>::new();
let sym_str = sym!("sha256", format!("{}-zero-bytes", input_size));
let cproc_sym = user_sym(&format!("sha256-{input_size}-zero-bytes"));
let cproc_sym_ptr = store.intern_symbol(&cproc_sym);

let lang = Lang::<Fr, Sha256Coproc<Fr>>::new_with_bindings(
store,
vec![(
sym_str.clone(),
Sha256Coprocessor::new(input_size, u).into(),
)],
vec![(cproc_sym, Sha256Coprocessor::new(input_size, u).into())],
);

let coproc_expr = format!("({})", sym_str);
let ptr = store.read(&coproc_expr).unwrap();
let cproc_call = store.list(&[cproc_sym_ptr]);

let nova_prover = NovaProver::<Fr, Sha256Coproc<Fr>>::new(REDUCTION_COUNT, lang.clone());
let lang_rc = Arc::new(lang);
Expand All @@ -202,7 +199,7 @@ fn main() {

let proof_start = Instant::now();
let (proof, z0, zi, num_steps) = nova_prover
.evaluate_and_prove(&pp, ptr, empty_sym_env(store), store, 10000, lang_rc)
.evaluate_and_prove(&pp, cproc_call, empty_sym_env(store), store, 10000, lang_rc)
.unwrap();
let proof_end = proof_start.elapsed();

Expand Down
15 changes: 7 additions & 8 deletions src/proof/nova.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ impl<'a: 'b, 'b, F: CurveCycleEquipped, C: Coprocessor<F>> Proof<'a, F, C> {
#[cfg(test)]
pub mod tests {
use crate::num::Num;
use crate::state::State;
use crate::state::{State, user_sym};

use super::*;
use crate::eval::empty_sym_env;
Expand Down Expand Up @@ -3675,26 +3675,25 @@ pub mod tests {
fn test_dumb_lang() {
use crate::coprocessor::test::DumbCoprocessor;
use crate::eval::tests::coproc::DumbCoproc;
use crate::symbol::Symbol;

let s = &mut Store::<Fr>::new();

let mut lang = Lang::<Fr, DumbCoproc<Fr>>::new();
let name = Symbol::sym(&["cproc", "dumb"]);
let name = user_sym("cproc-dumb");
let dumb = DumbCoprocessor::new();
let coproc = DumbCoproc::DC(dumb);

lang.add_coprocessor(name, coproc, s);

// 9^2 + 8 = 89
let expr = "(.cproc.dumb 9 8)";
let expr = "(cproc-dumb 9 8)";

// The dumb coprocessor cannot be shadowed.
let expr2 = "(let ((.cproc.dumb (lambda (a b) (* a b))))
(.cproc.dumb 9 8))";
let expr2 = "(let ((cproc-dumb (lambda (a b) (* a b))))
(cproc-dumb 9 8))";

let expr3 = "(.cproc.dumb 9 8 123)";
let expr4 = "(.cproc.dumb 9)";
let expr3 = "(cproc-dumb 9 8 123)";
let expr4 = "(cproc-dumb 9)";

let res = s.num(89);
let error = s.get_cont_error();
Expand Down

0 comments on commit 42b53f6

Please sign in to comment.