From cfd566df7b83c798147732663767281311f394d5 Mon Sep 17 00:00:00 2001 From: Sebastian Angel Date: Thu, 5 Jan 2023 06:47:26 -0800 Subject: [PATCH] trying to make this library build fine inside mpir --- build.rs | 42 ++++++++++++++++++++++++++++++++---------- src/client.rs | 2 +- tests/pir.rs | 4 +--- 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/build.rs b/build.rs index 34dc217..ca64d1b 100644 --- a/build.rs +++ b/build.rs @@ -1,15 +1,37 @@ -use cc; -use cmake; +use std::env; fn main() { + let path = env::current_dir().unwrap(); + + let mut pir_cpp = path.clone(); + pir_cpp.push("sealpir/pir.cpp"); + + let mut pir_server = path.clone(); + pir_server.push("sealpir/pir_server.cpp"); + + let mut pir_client = path.clone(); + pir_client.push("sealpir/pir_client.cpp"); + + let mut pir_bindings_file = path.clone(); + pir_bindings_file.push("sealpir-bindings/pir_rust.cpp"); + + let mut pir_bindings = path.clone(); + pir_bindings.push("sealpir-bindings"); + + let mut sealpir_dir = path.clone(); + sealpir_dir.push("sealpir"); + + let mut seal_dir = path; + seal_dir.push("deps/SEAL_2.3.1/SEAL/"); + cc::Build::new() - .file("sealpir/pir.cpp") - .file("sealpir/pir_server.cpp") - .file("sealpir/pir_client.cpp") - .file("sealpir-bindings/pir_rust.cpp") - .include("sealpir-bindings/") - .include("sealpir/") - .include("deps/SEAL_2.3.1/SEAL/") + .file(pir_cpp) + .file(pir_server) + .file(pir_client) + .file(pir_bindings_file) + .include(pir_bindings) + .include(sealpir_dir) + .include(seal_dir.clone()) .flag("-Wno-unknown-pragmas") .flag("-Wno-sign-compare") .flag("-Wno-unused-parameter") @@ -20,7 +42,7 @@ fn main() { .compile("libsealpir.a"); // Compile and link SEAL - let dst = cmake::Config::new("deps/SEAL_2.3.1/SEAL/") + let dst = cmake::Config::new(seal_dir) .define("CMAKE_BUILD_TYPE", "Release") .define("CMAKE_POSITION_INDEPENDENT_CODE", "ON") .build(); diff --git a/src/client.rs b/src/client.rs index f98507e..4a7c57a 100644 --- a/src/client.rs +++ b/src/client.rs @@ -137,7 +137,7 @@ impl<'a> PirClient<'a> { // offset into the FV plaintext let offset = get_fv_offset(self.client, ele_index, self.ele_size); - assert!(offset + self.ele_size <= result_size as u32); + assert!(offset + self.ele_size <= result_size); let r = slice::from_raw_parts_mut((ptr as *mut T).offset(offset as isize), 1).to_vec(); libc::free(ptr as *mut libc::c_void); diff --git a/tests/pir.rs b/tests/pir.rs index 6ea3106..7d2d88c 100644 --- a/tests/pir.rs +++ b/tests/pir.rs @@ -258,12 +258,11 @@ fn pir_sizes() { for logt in &logts { let mut server = PirServer::new(num, size, 2048, *logt, *d); - let client = PirClient::new(num, size, 2048, *logt, *d); let galois = client.get_key(); server.setup(&collection); - server.set_galois_key(&galois, 0); + server.set_galois_key(galois, 0); let query = client.gen_query(index); let reply = server.gen_reply(&query, 0); @@ -282,7 +281,6 @@ fn pir_sizes() { *d, reply.reply.len() / 1024 ); - } } }