okvs 0.2.0

WIP implementation of Oblivious Key-Value Stores
Documentation
use crate::{bits::Bits, hashable::Hashable};

pub mod garbled_bf;
pub mod garbled_ct;
pub mod paxos;

pub trait Okvs<V: Bits>: Sized {
    /// Keeps trying `Self::try_encode` until a solution is found.
    fn encode<K: Hashable>(key_value_pairs: &[(K, V)], lambda: usize) -> Self {
        loop {
            let result = Self::try_encode(key_value_pairs, lambda);
            if let Some(okvs) = result {
                return okvs;
            }
        }
    }

    /// Encodes the OKVS. The security parameters is `lambda`, which represents the maximum false positive probability.
    fn try_encode<K: Hashable>(key_value_pairs: &[(K, V)], lambda: usize) -> Option<Self>;

    fn decode<K: Hashable>(&self, key: &K) -> V;

    fn to_bytes(self) -> Vec<u8>;

    fn from_bytes(bytes: &[u8]) -> Self;
}