use std::{cell::RefCell, cmp::Ordering, rc::Rc};
use beaver::SharedValueSource;
use curve25519_dalek::scalar::Scalar;
use network::MpcNetwork;
pub mod authenticated_ristretto;
pub mod authenticated_scalar;
pub mod beaver;
pub mod commitment;
pub mod error;
pub mod fabric;
mod macros;
pub mod mpc_ristretto;
pub mod mpc_scalar;
pub mod network;
#[allow(type_alias_bounds)]
pub type SharedNetwork<N: MpcNetwork + Send> = Rc<RefCell<N>>;
#[allow(type_alias_bounds)]
pub type BeaverSource<S: SharedValueSource<Scalar>> = Rc<RefCell<S>>;
pub trait Visible {
fn visibility(&self) -> Visibility;
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Visibility {
Private,
Shared,
Public,
}
impl Visibility {
pub(crate) fn min_visibility_two(a: &impl Visible, b: &impl Visible) -> Visibility {
if a.visibility().lt(&b.visibility()) {
a.visibility()
} else {
b.visibility()
}
}
}
impl Ord for Visibility {
fn cmp(&self, other: &Self) -> Ordering {
match self {
Visibility::Private => match other {
Visibility::Private => Ordering::Equal,
_ => Ordering::Less,
},
Visibility::Shared => match other {
Visibility::Private => Ordering::Greater,
Visibility::Shared => Ordering::Equal,
_ => Ordering::Less,
},
Visibility::Public => match other {
Visibility::Public => Ordering::Equal,
_ => Ordering::Greater,
},
}
}
}
impl PartialOrd for Visibility {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}