arcium-primitives 0.6.0

Arcium primitives
Documentation
use std::fmt::Debug;

use serde::{de::DeserializeOwned, Serialize};
use wincode::{SchemaRead, SchemaWrite};

use crate::{
    random::RandomWith,
    sharing::{PairwiseAuthenticated, Reconstructible, Verifiable},
    types::Batched,
};

pub mod bundler;
pub mod generator;
pub mod stream;
pub mod types;

pub use types::{dabits, powpairs, singlets, triples};

/// A marker trait for input-independent correlated randomness types that can be
/// consumed in the (input-dependent) online phase to speed it up.
/// Includes verification and random generation capabilities.
pub trait Correlation:
    'static
    + Debug
    + Sized
    + Send
    + Sync
    + Clone
    + PartialEq
    + Serialize
    + DeserializeOwned
    + SchemaWrite<Src = Self>
    + for<'a> SchemaRead<'a>
    + Reconstructible
    + Verifiable
    + PairwiseAuthenticated
    + RandomWith<Vec<Self::GlobalAuthKey>>
{
}

impl<
        T: 'static
            + Debug
            + Sized
            + Send
            + Sync
            + Clone
            + PartialEq
            + Serialize
            + DeserializeOwned
            + Verifiable
            + PairwiseAuthenticated
            + RandomWith<Vec<Self::GlobalAuthKey>>
            + for<'a> wincode::SchemaRead<'a, Dst = T>
            + wincode::SchemaWrite<Src = T>,
    > Correlation for T
{
}

/// A marker trait for input-independent types that can be generated in batches, i.e. for which it
/// is more efficient to generate/request/verify multiple elements at once rather than one at a
/// time.
pub trait CorrelatedBatch:
    Correlation<GlobalAuthKey = <Self::Item as PairwiseAuthenticated>::GlobalAuthKey>
    + Batched<Item: Correlation>
{
}
impl<
        T: Correlation<GlobalAuthKey = <T::Item as PairwiseAuthenticated>::GlobalAuthKey>
            + Batched<Item: Correlation>,
    > CorrelatedBatch for T
{
}