Skip to content

Commit

Permalink
trying to make this library build fine inside mpir
Browse files Browse the repository at this point in the history
  • Loading branch information
sga001 committed Jan 5, 2023
1 parent dede8ae commit cfd566d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 14 deletions.
42 changes: 32 additions & 10 deletions build.rs
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions tests/pir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -282,7 +281,6 @@ fn pir_sizes() {
*d,
reply.reply.len() / 1024
);

}
}
}
Expand Down

0 comments on commit cfd566d

Please sign in to comment.