use super::*;
use alloc::boxed::Box;
use rand_core::SeedableRng;
pub trait ORAMCreator<ValueSize: ArrayLength<u8>, RngType: RngCore + 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: RngCore + 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<u8>, MetaSize: ArrayLength<u8>> {
type Output: ORAMStorage<BlockSize, MetaSize> + Send + Sync + 'static;
type Error: Display + Debug;
fn create<R: RngCore + CryptoRng>(
size: u64,
csprng: &mut R,
) -> Result<Self::Output, Self::Error>;
}
pub trait OMapCreator<KeySize: ArrayLength<u8>, ValueSize: ArrayLength<u8>, R: RngCore + 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: RngCore + 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)
}
}