extern crate oram;
use oram::{Address, BlockSize, BlockValue, DefaultOram, Oram, OramError};
use rand::{rngs::OsRng, Rng};
const BLOCK_SIZE: BlockSize = 4096;
const DB_SIZE: Address = 64;
const DATABASE: [[u8; BLOCK_SIZE as usize]; DB_SIZE as usize] =
[[0; BLOCK_SIZE as usize]; DB_SIZE as usize];
fn main() -> Result<(), OramError> {
let mut rng = OsRng;
let mut oram = DefaultOram::<BlockValue<4096>>::new(DB_SIZE, &mut rng)?;
for (i, bytes) in DATABASE.iter().enumerate() {
oram.write(i as Address, BlockValue::new(*bytes), &mut rng)?;
}
let num_operations = 100;
for _ in 0..num_operations {
let random_index = rng.gen_range(0..DB_SIZE);
let _ = oram.read(random_index, &mut rng)?;
}
Ok(())
}