Skip to content

Commit 6a4b730

Browse files
authored
Merge pull request #339 from sine-fdn/polytune/simplify-context-struct
polytune: simplify mpc Context struct
2 parents 55c024f + 2ed0ee3 commit 6a4b730

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

src/mpc/protocol.rs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -299,32 +299,32 @@ pub async fn mpc(
299299
_mpc(&ctx).await
300300
}
301301

302-
pub(crate) struct Context<'circ, 'inp, 'out, 'ch, 'p, C: Channel> {
303-
channel: &'ch C,
304-
circ: &'circ Circuit,
305-
inputs: &'inp [bool],
302+
pub(crate) struct Context<'c, C: Channel> {
303+
channel: &'c C,
304+
circ: &'c Circuit,
305+
inputs: &'c [bool],
306306
is_contrib: bool,
307307
p_fpre: Preprocessor,
308308
p_eval: usize,
309309
p_own: usize,
310310
p_max: usize,
311-
p_out: &'out [usize],
311+
p_out: &'c [usize],
312312
num_and_ops: usize,
313313
num_inputs: usize,
314-
tmp_dir: Option<&'p Path>,
314+
tmp_dir: Option<&'c Path>,
315315
}
316316

317-
impl<'circ, 'inp, 'out, 'ch, 'p, C: Channel> Context<'circ, 'inp, 'out, 'ch, 'p, C> {
317+
impl<'c, C: Channel> Context<'c, C> {
318318
#[allow(clippy::too_many_arguments)]
319319
pub(crate) fn new(
320-
channel: &'ch C,
321-
circ: &'circ Circuit,
322-
inputs: &'inp [bool],
320+
channel: &'c C,
321+
circ: &'c Circuit,
322+
inputs: &'c [bool],
323323
p_fpre: Preprocessor,
324324
p_eval: usize,
325325
p_own: usize,
326-
p_out: &'out [usize],
327-
tmp_dir: Option<&'p Path>,
326+
p_out: &'c [usize],
327+
tmp_dir: Option<&'c Path>,
328328
) -> Self {
329329
let p_max = circ.input_regs.len();
330330
let is_contrib = p_own != p_eval;
@@ -366,9 +366,7 @@ impl<'circ, 'inp, 'out, 'ch, 'p, C: Channel> Context<'circ, 'inp, 'out, 'ch, 'p,
366366
}
367367
}
368368

369-
pub(crate) async fn _mpc(
370-
ctx: &Context<'_, '_, '_, '_, '_, impl Channel>,
371-
) -> Result<Vec<bool>, Error> {
369+
pub(crate) async fn _mpc(ctx: &Context<'_, impl Channel>) -> Result<Vec<bool>, Error> {
372370
let now = Instant::now();
373371
debug!(
374372
"MPC protocol execution with {} parties, of which output parties have indices {:?} and the circuit has {} AND gates",
@@ -450,7 +448,7 @@ fn validate(ctx: &Context<impl Channel>) -> Result<(), Error> {
450448
#[allow(clippy::type_complexity)]
451449
#[instrument(level=Level::DEBUG, skip(ctx), err)]
452450
async fn fn_independent_pre(
453-
ctx: &Context<'_, '_, '_, '_, '_, impl Channel>,
451+
ctx: &Context<'_, impl Channel>,
454452
) -> Result<
455453
(
456454
Delta,
@@ -557,7 +555,7 @@ fn init_and_shares(
557555

558556
#[instrument(level=Level::DEBUG, skip_all, err)]
559557
async fn gen_auth_bits(
560-
ctx: &Context<'_, '_, '_, '_, '_, impl Channel>,
558+
ctx: &Context<'_, impl Channel>,
561559
delta: Delta,
562560
mut and_shares: FileOrMemBuf<(Share, Share)>,
563561
mut shared_two_by_two: Option<Vec<Vec<Option<ChaCha20Rng>>>>,
@@ -627,7 +625,7 @@ async fn gen_auth_bits(
627625
#[allow(clippy::type_complexity)]
628626
#[instrument(level=Level::DEBUG, skip_all, err)]
629627
async fn garble(
630-
ctx: &Context<'_, '_, '_, '_, '_, impl Channel>,
628+
ctx: &Context<'_, impl Channel>,
631629
delta: Delta,
632630
mut auth_bits: FileOrMemBuf<Share>,
633631
random_shares: &mut FileOrMemBuf<Share>,
@@ -812,7 +810,7 @@ async fn garble(
812810
num_inputs = ctx.num_inputs,
813811
), err)]
814812
async fn input_processing(
815-
ctx: &Context<'_, '_, '_, '_, '_, impl Channel>,
813+
ctx: &Context<'_, impl Channel>,
816814
delta: Delta,
817815
input_labels: &[Label],
818816
random_shares: &mut FileOrMemBuf<Share>,
@@ -1043,7 +1041,7 @@ fn evaluate(
10431041
num_output_wires = ctx.circ.output_regs.len(),
10441042
), err)]
10451043
async fn output(
1046-
ctx: &Context<'_, '_, '_, '_, '_, impl Channel>,
1044+
ctx: &Context<'_, impl Channel>,
10471045
delta: Delta,
10481046
shares: Vec<Share>,
10491047
labels: Vec<Label>,

0 commit comments

Comments
 (0)