Browse Source

merge cuckoo module into utils

Lennart Braun 1 year ago
parent
commit
2c4b860fac

+ 0 - 1
Cargo.toml

@@ -2,7 +2,6 @@
 
 members = [
     "communicator",
-    "cuckoo",
     "dpf",
     "oram",
     "utils",

+ 0 - 29
cuckoo/Cargo.toml

@@ -1,29 +0,0 @@
-[package]
-name = "cuckoo"
-version = "0.1.0"
-edition = "2021"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
-utils = { path = "../utils" }
-bincode = "2.0.0-rc.2"
-funty = "2.0.0"
-libm = "0.2.5"
-rand = "0.8.5"
-rand_chacha = "0.3.1"
-
-[dev-dependencies]
-criterion = "0.4.0"
-
-[[bin]]
-name = "params"
-path = "src/bin/params.rs"
-
-[[bench]]
-name = "cuckoo"
-harness = false
-
-[[bench]]
-name = "hash"
-harness = false

+ 0 - 2
cuckoo/src/lib.rs

@@ -1,2 +0,0 @@
-pub mod cuckoo;
-pub mod hash;

+ 0 - 1
dpf/Cargo.toml

@@ -6,7 +6,6 @@ edition = "2021"
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
-cuckoo = { path = "../cuckoo" }
 utils = { path = "../utils" }
 bincode = "2.0.0-rc.2"
 num = "0.4.0"

+ 1 - 1
dpf/benches/mpdpf.rs

@@ -1,9 +1,9 @@
 use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
-use cuckoo::hash::AesHashFunction;
 use dpf::mpdpf::{DummyMpDpf, MultiPointDpf, SmartMpDpf};
 use dpf::spdpf::{DummySpDpf, HalfTreeSpDpf};
 use rand::{thread_rng, Rng};
 use utils::field::{Fp, FromHash};
+use utils::hash::AesHashFunction;
 
 const LOG_DOMAIN_SIZES: [u32; 4] = [8, 12, 16, 20];
 

+ 6 - 6
dpf/src/mpdpf.rs

@@ -1,5 +1,6 @@
 //! Trait definitions and implementations of multi-point distributed point functions (MP-DPFs).
 
+use crate::spdpf::SinglePointDpf;
 use bincode;
 use core::fmt;
 use core::fmt::Debug;
@@ -7,12 +8,11 @@ use core::marker::PhantomData;
 use core::ops::{Add, AddAssign};
 use num::traits::Zero;
 use rayon::prelude::*;
-
-use crate::spdpf::SinglePointDpf;
-use cuckoo::{
-    cuckoo::Hasher as CuckooHasher, cuckoo::Parameters as CuckooParameters,
-    cuckoo::NUMBER_HASH_FUNCTIONS as CUCKOO_NUMBER_HASH_FUNCTIONS, hash::HashFunction,
+use utils::cuckoo::{
+    Hasher as CuckooHasher, Parameters as CuckooParameters,
+    NUMBER_HASH_FUNCTIONS as CUCKOO_NUMBER_HASH_FUNCTIONS,
 };
+use utils::hash::HashFunction;
 
 /// Trait for the keys of a multi-point DPF scheme.
 pub trait MultiPointDpfKey: Clone + Debug {
@@ -620,10 +620,10 @@ where
 mod tests {
     use super::*;
     use crate::spdpf::DummySpDpf;
-    use cuckoo::hash::AesHashFunction;
     use rand::distributions::{Distribution, Standard};
     use rand::{thread_rng, Rng};
     use std::num::Wrapping;
+    use utils::hash::AesHashFunction;
 
     fn test_mpdpf_with_param<MPDPF: MultiPointDpf>(
         log_domain_size: u32,

+ 0 - 1
oram/Cargo.toml

@@ -25,7 +25,6 @@ strum = { version = "0.24.1", features = ["derive"] }
 strum_macros = "0.24"
 
 [dev-dependencies]
-cuckoo = { path = "../cuckoo" }
 clap = { version = "4.1.4", features = ["derive"] }
 criterion = "0.4.0"
 serde_json = "1.0"

+ 1 - 1
oram/examples/bench_doram.rs

@@ -1,7 +1,6 @@
 use clap::{CommandFactory, Parser};
 use communicator::tcp::{make_tcp_communicator, NetworkOptions, NetworkPartyInfo};
 use communicator::{AbstractCommunicator, CommunicationStats};
-use cuckoo::hash::AesHashFunction;
 use dpf::mpdpf::SmartMpDpf;
 use dpf::spdpf::HalfTreeSpDpf;
 use ff::{Field, PrimeField};
@@ -21,6 +20,7 @@ use std::process;
 use std::time::{Duration, Instant};
 use strum::IntoEnumIterator;
 use utils::field::Fp;
+use utils::hash::AesHashFunction;
 
 type MPDPF = SmartMpDpf<Fp, HalfTreeSpDpf<Fp>, AesHashFunction<u16>>;
 type DOram = DistributedOramProtocol<Fp, MPDPF, HalfTreeSpDpf<Fp>>;

+ 14 - 0
utils/Cargo.toml

@@ -11,6 +11,8 @@ bincode = "2.0.0-rc.2"
 aes = "0.8.2"
 blake3 = "1.3.3"
 ff = { version = "0.13.0", features = ["derive"] }
+funty = "2.0.0"
+libm = "0.2.5"
 num = "0.4.0"
 rand = "0.8.5"
 rand_chacha = "0.3.1"
@@ -19,10 +21,22 @@ rug = "1.19.0"
 [dev-dependencies]
 criterion = "0.4.0"
 
+[[bin]]
+name = "cuckoo_params"
+path = "src/bin/cuckoo_params.rs"
+
+[[bench]]
+name = "cuckoo"
+harness = false
+
 [[bench]]
 name = "field"
 harness = false
 
+[[bench]]
+name = "hash"
+harness = false
+
 [[bench]]
 name = "permutation"
 harness = false

+ 2 - 2
cuckoo/benches/cuckoo.rs → utils/benches/cuckoo.rs

@@ -1,6 +1,6 @@
 use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};
-use cuckoo::cuckoo::{Hasher, Parameters};
-use cuckoo::hash::AesHashFunction;
+use utils::cuckoo::{Hasher, Parameters};
+use utils::hash::AesHashFunction;
 
 const LOG_DOMAIN_SIZES: [u32; 4] = [8, 12, 16, 20];
 

+ 1 - 1
cuckoo/benches/hash.rs → utils/benches/hash.rs

@@ -1,5 +1,5 @@
 use criterion::{black_box, criterion_group, criterion_main, Criterion};
-use cuckoo::hash::{AesHashFunction, HashFunction};
+use utils::hash::{AesHashFunction, HashFunction};
 
 pub fn bench_hash_range(c: &mut Criterion) {
     let n = 100_000;

+ 2 - 2
cuckoo/src/bin/params.rs → utils/src/bin/cuckoo_params.rs

@@ -1,5 +1,5 @@
-use cuckoo::cuckoo::{Hasher, Parameters};
-use cuckoo::hash::AesHashFunction;
+use utils::cuckoo::{Hasher, Parameters};
+use utils::hash::AesHashFunction;
 
 fn main() {
     let log_domain_sizes = [4, 8, 12, 16, 20, 24, 26];

+ 0 - 0
cuckoo/src/cuckoo.rs → utils/src/cuckoo.rs


+ 1 - 1
cuckoo/src/hash.rs → utils/src/hash.rs

@@ -1,3 +1,4 @@
+use crate::fixed_key_aes::FixedKeyAes;
 use bincode;
 use core::fmt::Debug;
 use core::ops::Range;
@@ -5,7 +6,6 @@ use funty::Integral;
 use rand::{thread_rng, Rng, SeedableRng};
 use rand_chacha::ChaCha12Rng;
 use std::marker::PhantomData;
-use utils::fixed_key_aes::FixedKeyAes;
 
 pub trait HashFunctionParameters {}
 pub trait HashFunctionValue: Integral + TryInto<usize>

+ 2 - 0
utils/src/lib.rs

@@ -1,5 +1,7 @@
 pub mod bit_decompose;
+pub mod cuckoo;
 pub mod field;
 pub mod fixed_key_aes;
+pub mod hash;
 pub mod permutation;
 pub mod pseudorandom_conversion;