Skip to content

Commit

Permalink
remove dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
rdragos committed Oct 21, 2024
1 parent d69bc32 commit e07779b
Showing 1 changed file with 2 additions and 62 deletions.
64 changes: 2 additions & 62 deletions iris-mpc-cpu/src/database_generators.rs
Original file line number Diff line number Diff line change
@@ -1,60 +1,19 @@
use crate::shares::{ring_impl::RingElement, share::Share, vecshare::VecShare};
use crate::shares::{ring_impl::RingElement, share::Share};
use iris_mpc_common::{
galois_engine::degree4::{GaloisRingIrisCodeShare, GaloisRingTrimmedMaskCodeShare},
iris_db::iris::{IrisCode, IrisCodeArray},
iris_db::iris::IrisCode,
};
use rand::{CryptoRng, Rng, RngCore};
use std::sync::Arc;

type ShareRing = u16;
type ShareType = Share<ShareRing>;
type VecShareType = VecShare<u16>;
type ShareRingPlain = RingElement<ShareRing>;
// type ShareType = Share<u16>;

#[derive(PartialEq, Eq, Debug, Default, Clone)]
pub struct SharedIris {
pub shares: VecShareType,
pub mask: IrisCodeArray,
}

#[derive(PartialEq, Eq, Debug, Clone)]
pub struct GaloisRingSharedIris {
pub code: GaloisRingIrisCodeShare,
pub mask: GaloisRingTrimmedMaskCodeShare,
}

#[derive(Clone)]
pub struct SharedDB {
pub shares: Arc<Vec<VecShareType>>,
pub masks: Arc<Vec<IrisCodeArray>>,
}

pub struct RawSharedDatabase {
pub player0_shares: Vec<SharedIris>,
pub player1_shares: Vec<SharedIris>,
pub player2_shares: Vec<SharedIris>,
}

/// This one is taken from iris-mpc-semi/iris.rs
pub struct IrisShare {}
impl IrisShare {
pub fn get_shares<R: RngCore>(input: bool, mask: bool, rng: &mut R) -> Vec<ShareType> {
let val = RingElement((input & mask) as ShareRing);
let to_share = RingElement(mask as ShareRing) - val - val;

let a = rng.gen::<ShareRingPlain>();
let b = rng.gen::<ShareRingPlain>();
let c = to_share - a - b;

let share1 = Share::new(a, c);
let share2 = Share::new(b, a);
let share3 = Share::new(c, b);

vec![share1, share2, share3]
}
}

pub fn create_random_sharing<R: RngCore>(rng: &mut R, input: u16) -> Vec<Share<u16>> {
let val = RingElement(input);
let a = rng.gen::<ShareRingPlain>();
Expand All @@ -68,25 +27,6 @@ pub fn create_random_sharing<R: RngCore>(rng: &mut R, input: u16) -> Vec<Share<u
vec![share1, share2, share3]
}

pub fn generate_iris_shares<R: Rng>(rng: &mut R, iris: IrisCode) -> Vec<SharedIris> {
let mut res = vec![SharedIris::default(); 3];
for res_i in res.iter_mut() {
res_i
.mask
.as_raw_mut_slice()
.copy_from_slice(iris.mask.as_raw_slice());
}

for i in 0..IrisCode::IRIS_CODE_SIZE {
// We simulate the parties already knowing the shares of the code.
let shares = IrisShare::get_shares(iris.code.get_bit(i), iris.mask.get_bit(i), rng);
for party_id in 0..3 {
res[party_id].shares.push(shares[party_id].to_owned());
}
}
res
}

pub fn generate_galois_iris_shares<R: Rng + CryptoRng>(
rng: &mut R,
iris: IrisCode,
Expand Down

0 comments on commit e07779b

Please sign in to comment.