1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
pub mod core {
    extern crate curve25519_dalek;
    extern crate elgamal_ristretto;

    use crate::errors::{QueryError, StorageError};

    // #TODO: may need a higher abstraction representation of a Scalar (result)
    // Ciphertext
    use curve25519_dalek::scalar::Scalar;
    use elgamal_ristretto::ciphertext::Ciphertext;

    /// A representation of the sinkhole database to query.
    ///
    /// Implementations of this trait contain the
    /// servers private data addition and retrieval.
    pub trait Storage {
        /// Adds content to the database.
        fn add(&self, content: Scalar, index: usize) -> Result<(), StorageError>;

        /// Returns the data for a given ID.
        fn retrieve(&self, query: Vec<Ciphertext>) -> Result<Ciphertext, StorageError>;
    }

    pub trait Query {
        fn extract_result(&self, result: Ciphertext, k: u32) -> Result<Scalar, QueryError>;
    }
}