arcium-core-utils 0.5.0

Arcium core utils
Documentation
use std::ops::{Add, Mul};

use primitives::types::{Batched, Positive, PositivePlusOne};
use typenum::{Prod, B1, U2, U3, U4, U5, U6};

use crate::preprocessing::Preprocessing;

/// A marker trait for batched preprocessing types that are composed of
/// individual items of preprocessing types.
pub trait BatchedPreprocessing: Preprocessing + Batched<Item: Preprocessing> {}
impl<T: Preprocessing + Batched<Item: Preprocessing>> BatchedPreprocessing for T {}

/// A generic trait to serve as batch size across all protocols. To be replaced
/// by const generics if they ever stabilize.
pub trait BatchSize:
    Positive
    + Add<B1, Output: Positive + Add<B1, Output: Positive>>
    + Mul<U2, Output: Positive + Mul<U3, Output = Prod<Self, U6>>>
    + Mul<U3, Output: Positive + Mul<U2, Output = Prod<Self, U6>>>
    + Mul<U4, Output: Positive>
    + Mul<U5, Output: Positive>
    + Mul<U6, Output: Positive + Add<B1, Output: Positive>>
{
}
impl<
        T: Positive
            + Add<B1, Output: PositivePlusOne>
            + Mul<U2, Output: Positive + Mul<U3, Output = Prod<T, U6>>>
            + Mul<U3, Output: Positive + Mul<U2, Output = Prod<T, U6>>>
            + Mul<U4, Output: Positive>
            + Mul<U5, Output: Positive>
            + Mul<U6, Output: PositivePlusOne>,
    > BatchSize for T
{
}