use super::*;
use alloc::boxed::Box;
use rand_core::SeedableRng;
pub trait ORAMCreator<ValueSize: ArrayLength, RngType: CryptoRng> {
type Output: ORAM<ValueSize> + Send + Sync + 'static;
fn create<M: 'static + FnMut() -> RngType>(
size: u64,
stash_size: usize,
rng_maker: &mut M,
) -> Self::Output;
}
pub trait PositionMapCreator<RngType: CryptoRng> {
fn create<M: 'static + FnMut() -> RngType>(
size: u64,
height: u32,
stash_size: usize,
rng_maker: &mut M,
) -> Box<dyn PositionMap + Send + Sync + 'static>;
}
pub trait ORAMStorageCreator<BlockSize: ArrayLength, MetaSize: ArrayLength> {
type Output: ORAMStorage<BlockSize, MetaSize> + Send + Sync + 'static;
type Error: Display + Debug;
fn create<R: CryptoRng>(size: u64, csprng: &mut R) -> Result<Self::Output, Self::Error>;
}
pub trait OMapCreator<KeySize: ArrayLength, ValueSize: ArrayLength, R: CryptoRng> {
type Output: ObliviousHashMap<KeySize, ValueSize> + Send + Sync + 'static;
fn create<M: 'static + FnMut() -> R>(
desired_capacity: u64,
stash_size: usize,
rng_maker: M,
) -> Self::Output;
}
pub fn rng_maker<R: CryptoRng + SeedableRng + 'static>(
mut source: R,
) -> impl FnMut() -> R + 'static {
move || {
let mut seed = R::Seed::default();
source.fill_bytes(seed.as_mut());
R::from_seed(seed)
}
}