Type checks for ABY translation (#76)

This commit is contained in:
Edward Chen
2022-04-19 21:32:36 -04:00
committed by GitHub
parent 157370f307
commit 4b01634d7d

View File

@@ -136,9 +136,14 @@ impl ToABY {
/// Given term `t`, type-check `t` is of type Bool
fn check_bool(&self, t: &Term) {
self.cache
match self
.cache
.get(t)
.unwrap_or_else(|| panic!("Missing wire for {:?}", t));
.unwrap_or_else(|| panic!("Missing wire for {:?}", t))
{
EmbeddedTerm::Bool(_) => (),
_ => panic!("Non-bool for {:?}", t),
}
}
fn embed_bool(&mut self, t: Term) {
@@ -186,8 +191,8 @@ impl ToABY {
let op = "MUX";
self.check_bool(&t.cs[0]);
self.check_bv(&t.cs[1]);
self.check_bv(&t.cs[2]);
self.check_bool(&t.cs[1]);
self.check_bool(&t.cs[2]);
let sel = self.term_to_share_cnt.get(&t.cs[0]).unwrap();
let a = self.term_to_share_cnt.get(&t.cs[1]).unwrap();
@@ -260,9 +265,14 @@ impl ToABY {
/// Given term `t`, type-check `t` is of type Bv
fn check_bv(&self, t: &Term) {
self.cache
match self
.cache
.get(t)
.unwrap_or_else(|| panic!("Missing wire for {:?}", t));
.unwrap_or_else(|| panic!("Missing wire for {:?}", t))
{
EmbeddedTerm::Bv(_) => (),
_ => panic!("Non-bv for {:?}", t),
}
}
fn embed_bv(&mut self, t: Term) {