Skip to content

Commit

Permalink
Op::Commit -> Op::Hide
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurpaulino committed Aug 17, 2023
1 parent 357791e commit 2658f10
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/lem/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()));
Expand Down
4 changes: 2 additions & 2 deletions src/lem/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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") => {
Expand Down Expand Up @@ -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") => {
Expand Down
2 changes: 1 addition & 1 deletion src/lem/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
14 changes: 7 additions & 7 deletions src/lem/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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)*
)
Expand Down Expand Up @@ -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![
Expand All @@ -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)),
];

Expand All @@ -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);
});
Expand Down
10 changes: 5 additions & 5 deletions src/lem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)?;
Expand Down
2 changes: 1 addition & 1 deletion src/lem/slot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 2658f10

Please sign in to comment.