From 2658f10e220672bc4b3e940ba6c343f509141f35 Mon Sep 17 00:00:00 2001 From: Arthur Paulino Date: Thu, 17 Aug 2023 13:43:39 -0300 Subject: [PATCH] Op::Commit -> Op::Hide --- src/lem/circuit.rs | 4 ++-- src/lem/eval.rs | 4 ++-- src/lem/interpreter.rs | 2 +- src/lem/macros.rs | 14 +++++++------- src/lem/mod.rs | 10 +++++----- src/lem/slot.rs | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/lem/circuit.rs b/src/lem/circuit.rs index 8eb2688207..97d691d69e 100644 --- a/src/lem/circuit.rs +++ b/src/lem/circuit.rs @@ -754,7 +754,7 @@ impl Func { bound_allocations.insert(tgt[1].clone(), rem_ptr); } Op::Emit(_) => (), - Op::Commit(tgt, sec, pay) => { + Op::Hide(tgt, sec, pay) => { let sec = bound_allocations.get(sec)?; let pay = bound_allocations.get(pay)?; let sec_tag = g @@ -1150,7 +1150,7 @@ impl Func { // one constraint for the image's hash num_constraints += 1; } - Op::Commit(..) => { + Op::Hide(..) => { num_constraints += 4; globals.insert(FWrap(Tag::Expr(Num).to_field())); globals.insert(FWrap(Tag::Expr(Comm).to_field())); diff --git a/src/lem/eval.rs b/src/lem/eval.rs index 0c043d3711..4265ecdf35 100644 --- a/src/lem/eval.rs +++ b/src/lem/eval.rs @@ -625,7 +625,7 @@ fn apply_cont() -> Func { return(secret, env, continuation, makethunk) } Symbol("commit") => { - let comm = commit(zero, result); + let comm = hide(zero, result); return(comm, env, continuation, makethunk) } Symbol("num") => { @@ -730,7 +730,7 @@ fn apply_cont() -> Func { } Symbol("hide") => { let num = cast(evaled_arg, Expr::Num); - let hidden = commit(num, result); + let hidden = hide(num, result); return(hidden, env, continuation, makethunk) } Symbol("eq") => { diff --git a/src/lem/interpreter.rs b/src/lem/interpreter.rs index d5b5a1dd0a..2df0d67b77 100644 --- a/src/lem/interpreter.rs +++ b/src/lem/interpreter.rs @@ -302,7 +302,7 @@ impl Block { .hash4 .push(Some(PreimageData::PtrVec(preimg_ptrs.to_vec()))); } - Op::Commit(tgt, sec, src) => { + Op::Hide(tgt, sec, src) => { let src_ptr = bindings.get(src)?; let Ptr::Leaf(Tag::Expr(Num), secret) = bindings.get(sec)? else { bail!("{sec} is not a numeric pointer") diff --git a/src/lem/macros.rs b/src/lem/macros.rs index d5abdd46c5..45a656336f 100644 --- a/src/lem/macros.rs +++ b/src/lem/macros.rs @@ -160,8 +160,8 @@ macro_rules! op { $crate::var!($src), ) }; - ( let $tgt:ident = commit($sec:ident, $src:ident) ) => { - $crate::lem::Op::Commit($crate::var!($tgt), $crate::var!($sec), $crate::var!($src)) + ( let $tgt:ident = hide($sec:ident, $src:ident) ) => { + $crate::lem::Op::Hide($crate::var!($tgt), $crate::var!($sec), $crate::var!($src)) }; ( let ($sec:ident, $src:ident) = open($hash:ident) ) => { $crate::lem::Op::Open($crate::var!($sec), $crate::var!($src), $crate::var!($hash)) @@ -468,12 +468,12 @@ macro_rules! block { $($tail)* ) }; - (@seq {$($limbs:expr)*}, let $tgt:ident = commit($sec:ident, $src:ident) ; $($tail:tt)*) => { + (@seq {$($limbs:expr)*}, let $tgt:ident = hide($sec:ident, $src:ident) ; $($tail:tt)*) => { $crate::block! ( @seq { $($limbs)* - $crate::op!(let $tgt = commit($sec, $src) ) + $crate::op!(let $tgt = hide($sec, $src) ) }, $($tail)* ) @@ -612,7 +612,7 @@ mod tests { [mptr("foo"), mptr("goo"), mptr("moo"), mptr("noo")], mptr("aaa"), ), - Op::Commit(mptr("bar"), mptr("baz"), mptr("bazz")), + Op::Hide(mptr("bar"), mptr("baz"), mptr("bazz")), Op::Open(mptr("bar"), mptr("baz"), mptr("bazz")), ]; let lemops_macro = vec![ @@ -623,7 +623,7 @@ mod tests { op!(let (foo, goo) = unhash2(aaa)), op!(let (foo, goo, moo) = unhash3(aaa)), op!(let (foo, goo, moo, noo) = unhash4(aaa)), - op!(let bar = commit(baz, bazz)), + op!(let bar = hide(baz, bazz)), op!(let (bar, baz) = open(bazz)), ]; @@ -644,7 +644,7 @@ mod tests { let (foo, goo) = unhash2(aaa); let (foo, goo, moo) = unhash3(aaa); let (foo, goo, moo, noo) = unhash4(aaa); - let bar = commit(baz, bazz); + let bar = hide(baz, bazz); let (bar, baz) = open(bazz); return (bar, baz, bazz); }); diff --git a/src/lem/mod.rs b/src/lem/mod.rs index de501be2ae..50c41442e9 100644 --- a/src/lem/mod.rs +++ b/src/lem/mod.rs @@ -269,9 +269,9 @@ pub enum Op { Unhash3([Var; 3], Var), /// `Unhash4([a, b, c, d], x)` binds `a`, `b`, `c` and `d` to the 4 children of `x` Unhash4([Var; 4], Var), - /// `Commit(x, s, p)` binds `x` to a (comm) `Ptr` resulting from committing the + /// `Hide(x, s, p)` binds `x` to a (comm) `Ptr` resulting from hiding the /// payload `p` with (num) secret `s` - Commit(Var, Var, Var), + Hide(Var, Var, Var), /// `Open(s, p, h)` binds `s` and `p` to the secret and payload (respectively) /// of the commitment that resulted on (num or comm) `h` Open(Var, Var, Var), @@ -397,7 +397,7 @@ impl Func { is_bound(img, map)?; preimg.iter().for_each(|var| is_unique(var, map)) } - Op::Commit(tgt, sec, src) => { + Op::Hide(tgt, sec, src) => { is_bound(sec, map)?; is_bound(src, map)?; is_unique(tgt, map); @@ -660,11 +660,11 @@ impl Block { let preimg = insert_many(map, uniq, &preimg); ops.push(Op::Unhash4(preimg.try_into().unwrap(), img)) } - Op::Commit(tgt, sec, pay) => { + Op::Hide(tgt, sec, pay) => { let sec = map.get_cloned(&sec)?; let pay = map.get_cloned(&pay)?; let tgt = insert_one(map, uniq, &tgt); - ops.push(Op::Commit(tgt, sec, pay)) + ops.push(Op::Hide(tgt, sec, pay)) } Op::Open(sec, pay, comm_or_num) => { let comm_or_num = map.get_cloned(&comm_or_num)?; diff --git a/src/lem/slot.rs b/src/lem/slot.rs index f768ace1d4..6456e7c2c2 100644 --- a/src/lem/slot.rs +++ b/src/lem/slot.rs @@ -188,7 +188,7 @@ impl Block { Op::Hash2(..) | Op::Unhash2(..) => SlotsCounter::new((1, 0, 0, 0, 0)), Op::Hash3(..) | Op::Unhash3(..) => SlotsCounter::new((0, 1, 0, 0, 0)), Op::Hash4(..) | Op::Unhash4(..) => SlotsCounter::new((0, 0, 1, 0, 0)), - Op::Commit(..) | Op::Open(..) => SlotsCounter::new((0, 0, 0, 1, 0)), + Op::Hide(..) | Op::Open(..) => SlotsCounter::new((0, 0, 0, 1, 0)), Op::Lt(..) => SlotsCounter::new((0, 0, 0, 0, 1)), Op::Call(_, func, _) => func.slot, _ => SlotsCounter::default(),