okvs 0.2.0

WIP implementation of Oblivious Key-Value Stores
Documentation
use std::{
    fmt::Debug,
    ops::{BitXor, BitXorAssign},
};

use rand::{thread_rng, Rng};

pub(crate) fn bit_at_is_set(slice: &[u64], position: usize) -> bool {
    (slice[position / 64] >> (position % 64)) & 1 == 1
}

// TODO: Consider removing BitXor
pub trait Bits: BitXor<Output = Self> + BitXorAssign + Sized + Copy + Debug {
    const BYTES: usize;
    fn random() -> Self;
    fn to_bytes(self) -> Vec<u8>;
    fn from_bytes(bytes: &[u8]) -> Self;
}

impl Bits for u64 {
    const BYTES: usize = 8;

    fn random() -> Self {
        thread_rng().gen()
    }

    fn to_bytes(self) -> Vec<u8> {
        self.to_ne_bytes().to_vec()
    }

    fn from_bytes(bytes: &[u8]) -> Self {
        let mut array = [0; 8];
        array.copy_from_slice(bytes);
        Self::from_ne_bytes(array)
    }
}