1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//! Insecure MTProvider, intended for testing.
use crate::mul_triple::arithmetic::MulTriples;
use crate::mul_triple::MTProvider;
use crate::protocols::Ring;
use async_trait::async_trait;
use std::convert::Infallible;
use std::marker::PhantomData;

/// An insecure [`MTProvider`] which simply returns [`MulTriples::zeros`]. **Do not use in
/// production!**.
#[derive(Clone, Default)]
pub struct InsecureMTProvider<R>(PhantomData<R>);

#[async_trait]
impl<R: Ring> MTProvider for InsecureMTProvider<R> {
    type Output = MulTriples<R>;
    type Error = Infallible;

    async fn precompute_mts(&mut self, _amount: usize) -> Result<(), Infallible> {
        // Nothing to do
        Ok(())
    }

    async fn request_mts(&mut self, amount: usize) -> Result<Self::Output, Self::Error> {
        Ok(MulTriples::zeros(amount))
    }
}