Skip to content

Commit dc6e555

Browse files
authored
Flags (#1)
* From env * To env * Other notif * For all dirs * Dirs * Nicer readme * Docs * Fix * Other flag * Avoid ignoring tests * Nits * Nits 2
1 parent 1a19089 commit dc6e555

File tree

6 files changed

+190
-44
lines changed

6 files changed

+190
-44
lines changed

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,6 @@ pi-rs-cli-utils = {path = "./pi-rs-cli-utils"}
3030
[[bench]]
3131
name = "bench"
3232
harness = false
33+
34+
[lib]
35+
bench = false

Makefile

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ PREVIOUS_DIR=..
88
# these are the FrodoPIR parameters to be used for benchmarking
99
NUMBER_OF_ELEMENTS_EXP=16
1010
LWE_DIMENSION=1774 # as per FrodoPIR paper
11-
ELEMENT_SIZE_BITS=13
11+
ELEMENT_SIZE_BITS=8192 # 2**13
1212
PLAINTEXT_SIZE_EXP=10
1313
NUM_SHARDS=8
14+
DB=true
15+
KV=true
1416

1517
# rust flags
1618
RUST_BACKTRACE=1
@@ -24,8 +26,8 @@ DB_ENV=DB_FILE=${PREVIOUS_DIR}/${DB_FILE_PATH} PARAMS_OUTPUT_PATH=${PREVIOUS_DIR
2426
DB_GEN_PRELIM=DB_ALL_ONES=${DB_ALL_ONES} DB_NUM_ENTRIES_EXP=${DB_NUM_ENTRIES_EXP} DB_OUTPUT_PATH=${DB_FILE_PATH} DB_ELEMENT_SIZE_BITS=${ELEMENT_SIZE_BITS}
2527

2628
PRELIM=${RUST_FLAGS}
27-
PIR_FLAGS=-m ${NUMBER_OF_ELEMENTS_EXP} --dim ${LWE_DIMENSION} --ele_size ${ELEMENT_SIZE_BITS} --plaintext_bits ${PLAINTEXT_SIZE_EXP} --num_shards ${NUM_SHARDS}
28-
PIR_ENV=PIR_NUMBER_OF_ELEMENTS_EXP=${NUMBER_OF_ELEMENTS_EXP} PIR_LWE_DIM=${LWE_DIMENSION} PIR_ELEM_SIZE_BITS=${ELEMENT_SIZE_BITS} PIR_PLAINTEXT_BITS=${PLAINTEXT_SIZE_EXP} PIR_NUM_SHARDS=${NUM_SHARDS}
29+
PIR_FLAGS=-m ${NUMBER_OF_ELEMENTS_EXP} --dim ${LWE_DIMENSION} --ele_size ${ELEMENT_SIZE_BITS} --plaintext_bits ${PLAINTEXT_SIZE_EXP} --num_shards ${NUM_SHARDS} -offline ${DB}
30+
PIR_ENV=PIR_NUMBER_OF_ELEMENTS_EXP=${NUMBER_OF_ELEMENTS_EXP} PIR_LWE_DIM=${LWE_DIMENSION} PIR_ELEM_SIZE_BITS=${ELEMENT_SIZE_BITS} PIR_PLAINTEXT_BITS=${PLAINTEXT_SIZE_EXP} PIR_NUM_SHARDS=${NUM_SHARDS} BENCH_DB_GEN=${DB} BENCH_KV=${KV}
2931
PIR_ENV_ALL=PIR_LWE_DIM=${LWE_DIMENSION} PIR_NUM_SHARDS=${NUM_SHARDS}
3032

3133
LIB_PRELIM=${DB_FILE_PRELIM}
@@ -54,14 +56,45 @@ docs:
5456
bench:
5557
${PRELIM} ${PIR_ENV} ${CARGO} bench
5658

57-
bench-standard:
58-
${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=8192 PIR_NUMBER_OF_ELEMENTS_EXP=16 PIR_PLAINTEXT_BITS=10 ${CARGO} bench > benchmarks-16-1kb.txt
59-
${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=8192 PIR_NUMBER_OF_ELEMENTS_EXP=17 PIR_PLAINTEXT_BITS=10 ${CARGO} bench > benchmarks-17-1kb.txt
60-
${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=8192 PIR_NUMBER_OF_ELEMENTS_EXP=18 PIR_PLAINTEXT_BITS=10 ${CARGO} bench > benchmarks-18-1kb.txt
61-
${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=8192 PIR_NUMBER_OF_ELEMENTS_EXP=19 PIR_PLAINTEXT_BITS=9 ${CARGO} bench > benchmarks-19-1kb.txt
62-
${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=8192 PIR_NUMBER_OF_ELEMENTS_EXP=20 PIR_PLAINTEXT_BITS=9 ${CARGO} bench > benchmarks-20-1kb.txt
63-
64-
bench-keyword:
65-
${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=819200 PIR_NUMBER_OF_ELEMENTS_EXP=14 PIR_PLAINTEXT_BITS=10 ${CARGO} bench > benchmarks-14-kw.txt
66-
${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=245760 PIR_NUMBER_OF_ELEMENTS_EXP=17 PIR_PLAINTEXT_BITS=10 ${CARGO} bench > benchmarks-17-kw.txt
67-
${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=2048 PIR_NUMBER_OF_ELEMENTS_EXP=20 PIR_PLAINTEXT_BITS=9 ${CARGO} bench > benchmarks-20-kw.txt
59+
bench-keyword-standard:
60+
${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=8192 PIR_NUMBER_OF_ELEMENTS_EXP=16 PIR_PLAINTEXT_BITS=10 BENCH_DB_GEN=true BENCH_KV=true ${CARGO} bench > benchmarks-16-1kb.txt
61+
${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=8192 PIR_NUMBER_OF_ELEMENTS_EXP=17 PIR_PLAINTEXT_BITS=10 BENCH_DB_GEN=true BENCH_KV=true ${CARGO} bench > benchmarks-17-1kb.txt
62+
${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=8192 PIR_NUMBER_OF_ELEMENTS_EXP=18 PIR_PLAINTEXT_BITS=10 BENCH_DB_GEN=true BENCH_KV=true ${CARGO} bench > benchmarks-18-1kb.txt
63+
${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=8192 PIR_NUMBER_OF_ELEMENTS_EXP=19 PIR_PLAINTEXT_BITS=9 BENCH_DB_GEN=true BENCH_KV=true ${CARGO} bench > benchmarks-19-1kb.txt
64+
${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=8192 PIR_NUMBER_OF_ELEMENTS_EXP=20 PIR_PLAINTEXT_BITS=9 BENCH_DB_GEN=true BENCH_KV=true ${CARGO} bench > benchmarks-20-1kb.txt
65+
66+
bench-keyword-all:
67+
${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=819200 PIR_NUMBER_OF_ELEMENTS_EXP=14 PIR_PLAINTEXT_BITS=10 BENCH_DB_GEN=true BENCH_KV=true ${CARGO} bench > benchmarks-14-kw.txt
68+
${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=245760 PIR_NUMBER_OF_ELEMENTS_EXP=17 PIR_PLAINTEXT_BITS=10 BENCH_DB_GEN=true BENCH_KV=true ${CARGO} bench > benchmarks-17-kw.txt
69+
${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=2048 PIR_NUMBER_OF_ELEMENTS_EXP=20 PIR_PLAINTEXT_BITS=9 BENCH_DB_GEN=true BENCH_KV=true ${CARGO} bench > benchmarks-20-kw.txt
70+
71+
bench-keyword-20:
72+
${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=2048 PIR_NUMBER_OF_ELEMENTS_EXP=20 PIR_PLAINTEXT_BITS=9 BENCH_DB_GEN=false BENCH_KV=true ${CARGO} bench > benchmarks-20-kw.txt
73+
74+
bench-keyword-17:
75+
${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=245760 PIR_NUMBER_OF_ELEMENTS_EXP=17 PIR_PLAINTEXT_BITS=10 BENCH_DB_GEN=false BENCH_KV=true ${CARGO} bench > benchmarks-17-kw.txt
76+
77+
bench-keyword-14:
78+
${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=819200 PIR_NUMBER_OF_ELEMENTS_EXP=14 PIR_PLAINTEXT_BITS=10 BENCH_DB_GEN=false BENCH_KV=true ${CARGO} bench > benchmarks-14-kw.txt
79+
80+
bench-index-standard:
81+
${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=8192 PIR_NUMBER_OF_ELEMENTS_EXP=16 PIR_PLAINTEXT_BITS=10 BENCH_DB_GEN=true BENCH_KV=false ${CARGO} bench > benchmarks-i-16-1kb.txt
82+
${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=8192 PIR_NUMBER_OF_ELEMENTS_EXP=17 PIR_PLAINTEXT_BITS=10 BENCH_DB_GEN=true BENCH_KV=false ${CARGO} bench > benchmarks-i-17-1kb.txt
83+
${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=8192 PIR_NUMBER_OF_ELEMENTS_EXP=18 PIR_PLAINTEXT_BITS=10 BENCH_DB_GEN=true BENCH_KV=false ${CARGO} bench > benchmarks-i-18-1kb.txt
84+
${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=8192 PIR_NUMBER_OF_ELEMENTS_EXP=19 PIR_PLAINTEXT_BITS=9 BENCH_DB_GEN=true BENCH_KV=false ${CARGO} bench > benchmarks-19-i-1kb.txt
85+
${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=8192 PIR_NUMBER_OF_ELEMENTS_EXP=20 PIR_PLAINTEXT_BITS=9 BENCH_DB_GEN=true BENCH_KV=false ${CARGO} bench > benchmarks-20-i-1kb.txt
86+
87+
bench-index-all:
88+
${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=819200 PIR_NUMBER_OF_ELEMENTS_EXP=14 PIR_PLAINTEXT_BITS=10 BENCH_DB_GEN=true BENCH_KV=false ${CARGO} bench > benchmarks-14-i.txt
89+
${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=245760 PIR_NUMBER_OF_ELEMENTS_EXP=17 PIR_PLAINTEXT_BITS=10 BENCH_DB_GEN=true BENCH_KV=false ${CARGO} bench > benchmarks-17-i.txt
90+
${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=2048 PIR_NUMBER_OF_ELEMENTS_EXP=20 PIR_PLAINTEXT_BITS=9 BENCH_DB_GEN=true BENCH_KV=false ${CARGO} bench > benchmarks-20-i.txt
91+
92+
bench-index-20:
93+
${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=2048 PIR_NUMBER_OF_ELEMENTS_EXP=20 PIR_PLAINTEXT_BITS=9 BENCH_DB_GEN=false BENCH_KV=false ${CARGO} bench > benchmarks-20-kw.txt
94+
95+
bench-index-17:
96+
${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=245760 PIR_NUMBER_OF_ELEMENTS_EXP=17 PIR_PLAINTEXT_BITS=10 BENCH_DB_GEN=false BENCH_KV=false ${CARGO} bench > benchmarks-17-kw.txt
97+
98+
bench-index-14:
99+
${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=819200 PIR_NUMBER_OF_ELEMENTS_EXP=14 PIR_PLAINTEXT_BITS=10 BENCH_DB_GEN=false BENCH_KV=false ${CARGO} bench > benchmarks-14-kw.txt
100+

README.md

Lines changed: 98 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ In order to natively build, run, test and benchmark the library, you will need t
1818
Python3 >= 3.9.7
1919
```
2020

21-
To obtain our performance numbers as reported in our paper, we run our benchmarks in AWS EC2 ``t2.t2xlarge`` and ``c5.9xlarge`` machines.
22-
2321
Note that we internally use the [xorf](https://github.com/ayazhafiz/xorf) library, but we modify it as seen [here](https://github.com/claucece/chalamet/tree/main/bff-modp).
2422

23+
To obtain our performance numbers as reported in Table 2 of our paper, we run our benchmarks in AWS EC2 ``t2.t2xlarge`` and ``c5.9xlarge`` machines, as reported.
24+
25+
2526
## Quickstart
2627

2728
### Local
@@ -65,38 +66,127 @@ To view documentation (in a web browser manner):
6566

6667
#### Benchmarking
6768

68-
To run a specific set of benchmarks, run (note the this process is slow. On average, it takes 12 minutes):
69+
There are several parameters that you can pass as flag to the `cargo bench` command, so that you can test the scheme.
70+
These are (with their default values):
71+
72+
```
73+
NUMBER_OF_ELEMENTS_EXP=16 (the m value of a DB: the number of rows)
74+
LWE_DIMENSION=1774 (The LWE dimension)
75+
ELEMENT_SIZE_BITS=8192 # 2**13 (the size of each element in bits)
76+
PLAINTEXT_SIZE_EXP=10 (the size of each plaintext element: determines w of a DB: the size of the rows)
77+
NUM_SHARDS=8
78+
DB=true (if the offline steps will be bechmarked: these steps are very slow)
79+
KV=true (if you want to execute the keyword-based PIR or else the index-based)
80+
81+
```
82+
83+
These can also be found on the Makefile (lines 9-14).
84+
85+
---
86+
87+
To run a simple benchmark (for a DB of 2^16 x 1024B) with offline steps, run (note the this process is slow. On average, it takes 12 minutes):
6988

7089
```
7190
make bench
7291
```
7392

7493
This command will execute client query benchmarks and Database generation benchmarks (for more details, see the `benches/bench.rs` file).
7594

76-
To run all benchmarks (note that this process is very slow, it takes around 30 minutes):
95+
---
96+
To run all benchmarks as reported in lines 1-10 of Table 2 of our paper (note that this process is very slow, it takes around 30 minutes):
7797

7898
```
79-
make bench-standard
99+
make bench-keyword-standard
80100
```
81101

82102
This command will execute client query benchmarks and Database generation benchmarks for 16, 17, 18, 19 and 20 Number of DB items (log(m)). The results of these benchmarks can be found on Table 2 of our paper.
83103

84104
In order to see the results of the benchmarks, navigate to the `benchmarks-x-x.txt` file.
85105

86-
You can also run:
106+
---
107+
To run all benchmarks as reported in lines 11-13 of Table 2 of our paper and of Table 3 (note that this process is significantly slow):
108+
109+
```
110+
make bench-keyword-all
111+
```
112+
113+
In order to see the results of the benchmarks, navigate to the `benchmarks-x-x.txt` file.
114+
115+
In order to make the results of lines 11-13 of Table 2 of our paper and of Table 3 of our paper easier to reproduce, we have made available these three commands:
116+
117+
118+
```
119+
make bench-keyword-20
120+
make bench-keyword-14
121+
make bench-keyword-17
122+
```
123+
124+
which omit any offline steps, and can be run independently for 2^20 x 256B, 2^17 x 30kB and 2^14 x 100kB.
125+
126+
---
127+
128+
In order to run the benchmarks for Table 4 (index-based PIR with FrodoPIR), one can run:
87129

88130
```
89-
make bench-keyword
131+
make bench-index-standard #For lines 1-10
132+
make bench-index-all #For lines 11-13
90133
```
91134

92-
to reproduce the results of Table 3 of our paper.
135+
Note that those directions take a long time as they execute the offline steps as well.
136+
137+
One can run the following to omit the offline steps:
138+
139+
```
140+
make bench-index-20
141+
make bench-index-14
142+
make bench-index-17
143+
```
144+
145+
---
93146

94147
If all benches build and run correctly, you should see an `Finished ... benchmarks` under them.
95148
We use [Criterion](https://bheisler.github.io/criterion.rs/book/index.html) for benchmarking.
96149
If you want to see and have explanations of the benchmarks, you can locally open `target/criterion/report/index.html` in your browser.
97150

98151
**Note**: When running the benches, a warning might appear ``Warning: Unable to complete 10 samples in 100.0s. You may wish to increase target time to 486.6s.``. If you want to silence the warning, you can change line 30 of `benches/bech.rs` file to 500 or more. Note that this will make the running of benches slower.
99152

153+
In order to interpret the `benchmarks-x-x.txt` files, we provide some guidance here:
154+
155+
156+
First, we have the initial lines describing the parameters for the benchmark.
157+
158+
```
159+
[KV] Starting benches for keyword PIR.
160+
[KV] Setting up DB for benchmarking. This might take a while...
161+
[KV] The params are: m: 65536, lwe_dim: 1774, elem_size: 8192, plaintext-bits: 10
162+
[KV] Are we benchmarking offline steps? true
163+
```
164+
165+
These simply describe the LWE parameters for running the PIR interaction, note that the [KV] part here shows that we are running the keyword PIR benchmarks. This part can take a while, as the database and the public parameters are being generated for the interaction. It also states if we are running any offline steps, which can be omitted as they are significantly slow.
166+
167+
Once this setup has completed, we see the following.
168+
169+
```
170+
[KV] Setup complete, starting benchmarks...
171+
[KV] Filter Params: segment-len: 2048, segment-len-mask: 2047, segment-count-len: 73728
172+
[KV] Starting client query benchmarks
173+
```
174+
175+
This describes the individual filter parameters for the filters being used, and informs us that the benchmarks will now be computed for each piece of functionality.
176+
177+
Each individual benchmark is then displayed in the following way.
178+
179+
```
180+
Benchmarking lwe/[KV] server response, lwe_dim: 1774, matrix_height: 77824, omega: 820: Collecting 100 samples in estimated 5.2698 s (300 iterations)
181+
Benchmarking lwe/[KV] server response, lwe_dim: 1774, matrix_height: 77824, omega: 820: Analyzing
182+
lwe/[KV] server response, lwe_dim: 1774, matrix_height: 77824, omega: 820
183+
time: [17.566 ms 17.670 ms 17.789 ms]
184+
```
185+
186+
The middle time here is the average taken over the number of samples displayed. The name of the benchmark in this case is "server response", which took 17.67ms, and this is the value that we used in the paper.
187+
188+
In terms of Table 2, the key benchmarks are "create client query prepare" (Query), "server response" (Response), and "client parse server response" (Parsing), as these are the main online operations in the protocol.
189+
100190
### Tests
101191

102192
We have two big tests that the library executes:

benches/bench.rs

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,24 @@ use std::time::Duration;
1010
use keyword_pir_lwe::db::FilterParams;
1111

1212
const BENCH_KV: bool = true;
13-
const BENCH_ONLINE: bool = true;
14-
const BENCH_DB_GEN: bool = true;
1513

1614
fn criterion_benchmark(c: &mut Criterion) {
1715
let CLIFlags {
1816
m,
1917
lwe_dim,
2018
elem_size,
2119
plaintext_bits,
20+
offline,
21+
keyword,
2222
..
2323
} = parse_from_env();
2424
let mut lwe_group = c.benchmark_group("lwe");
2525

26-
if BENCH_KV {
26+
if keyword {
27+
println!("[KV] Starting benches for keyword PIR.");
2728
println!("[KV] Setting up DB for benchmarking. This might take a while...");
2829
println!("[KV] The params are: m: {}, lwe_dim: {}, elem_size: {}, plaintext-bits: {}", m, lwe_dim, elem_size, plaintext_bits);
30+
println!("[KV] Are we benchmarking offline steps? {}", offline);
2931

3032
let kv_db_eles = bench_utils::generate_kv_db_elems(m, (elem_size + 7) / 8);
3133
let keys: Vec<String> = kv_db_eles.iter().map(|e| e.0.clone()).collect();
@@ -41,22 +43,23 @@ fn criterion_benchmark(c: &mut Criterion) {
4143
.unwrap();
4244
println!("[KV] Setup complete, starting benchmarks...");
4345

44-
if BENCH_ONLINE {
45-
_bench_client_kv_query(
46-
&mut lwe_group,
47-
&shard,
48-
(keys[0].clone(), values[0].clone()),
49-
);
50-
}
46+
println!("[KV] Benchmarking online steps...");
47+
_bench_client_kv_query(
48+
&mut lwe_group,
49+
&shard,
50+
(keys[0].clone(), values[0].clone()),
51+
);
5152

52-
if BENCH_DB_GEN {
53+
if offline {
54+
println!("[KV] Benchmarking offline steps...");
5355
lwe_group.sample_size(10);
5456
lwe_group.measurement_time(Duration::from_secs(100)); // To remove a warning, you can increase this to 500 or more.
5557
_bench_kv_db_generation(&mut lwe_group, &shard, &keys, &values);
5658
}
5759
} else {
60+
println!("[I] Starting benches for index PIR.");
5861
let db_eles = bench_utils::generate_db_eles(m, (elem_size + 7) / 8);
59-
println!("Setting up DB for benchmarking. This might take a while...");
62+
println!("[I] Setting up DB for benchmarking. This might take a while...");
6063
let shard = Shard::from_base64_strings(
6164
&db_eles,
6265
lwe_dim,
@@ -65,11 +68,13 @@ fn criterion_benchmark(c: &mut Criterion) {
6568
plaintext_bits,
6669
)
6770
.unwrap();
68-
println!("Setup complete, starting benchmarks");
69-
if BENCH_ONLINE {
70-
_bench_client_query(&mut lwe_group, &shard);
71-
}
72-
if BENCH_DB_GEN {
71+
println!("[I] Setup complete, starting benchmarks");
72+
73+
println!("[I] Benchmarking online steps...");
74+
_bench_client_query(&mut lwe_group, &shard);
75+
76+
if offline {
77+
println!("[I] Benchmarking offline steps...");
7378
lwe_group.sample_size(10);
7479
lwe_group.measurement_time(Duration::from_secs(100)); // To remove a warning, you can increase this to 500 or more.
7580
_bench_db_generation(&mut lwe_group, &shard, &db_eles);

pi-rs-cli-utils/src/lib.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ pub struct CLIFlags {
66
pub lwe_dim: usize,
77
pub plaintext_bits: usize,
88
pub elem_size: usize,
9+
pub offline: bool,
10+
pub keyword: bool,
911
}
1012

1113
pub fn parse_cli_flags() -> CLIFlags {
@@ -64,20 +66,27 @@ pub fn parse_cli_flags() -> CLIFlags {
6466
lwe_dim,
6567
plaintext_bits,
6668
elem_size,
69+
offline: true,
70+
keyword: true,
6771
}
6872
}
6973

7074
pub fn parse_from_env() -> CLIFlags {
71-
let elem_size: usize = env::var("PIR_ELEM_SIZE_BITS").unwrap().parse().unwrap();
75+
let elem_size: usize =
76+
env::var("PIR_ELEM_SIZE_BITS").unwrap().parse().unwrap();
7277
let lwe_dim: usize = env::var("PIR_LWE_DIM").unwrap().parse().unwrap();
7378
let plaintext_bits: usize =
7479
env::var("PIR_PLAINTEXT_BITS").unwrap().parse().unwrap();
7580
let m = parse_exp_to_usize(env::var("PIR_NUMBER_OF_ELEMENTS_EXP").unwrap());
81+
let offline = parse_val_to_bool(env::var("BENCH_DB_GEN").unwrap());
82+
let keyword = parse_val_to_bool(env::var("BENCH_KV").unwrap());
7683
CLIFlags {
7784
m,
7885
lwe_dim,
7986
plaintext_bits,
8087
elem_size,
88+
offline,
89+
keyword,
8190
}
8291
}
8392

@@ -86,3 +95,8 @@ pub fn parse_exp_to_usize(v: String) -> usize {
8695
let res = 2_u32.pow(exp) as usize;
8796
res
8897
}
98+
99+
pub fn parse_val_to_bool(v: String) -> bool {
100+
let res: bool = v.parse().unwrap();
101+
res
102+
}

src/api.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ impl Shard {
6666
Ok(())
6767
}
6868

69-
// Produces a serialized response (base64-encoded) to a serialized
70-
// client query
69+
/// Produces a serialized response (base64-encoded) to a serialized
70+
/// client query
7171
pub fn respond(&self, q: &Query) -> ResultBoxedError<Vec<u8>> {
7272
let q = q.as_slice();
7373
let resp = Response(
@@ -98,6 +98,7 @@ impl Shard {
9898
}
9999
}
100100

101+
/// EncodeKV represents an encoded key-value struct.
101102
#[derive(Clone, Debug, Serialize, Deserialize)]
102103
pub struct EncodedKV {
103104
key: String,
@@ -212,8 +213,8 @@ impl KVShard {
212213
Ok(())
213214
}
214215

215-
// Produces a serialized response (base64-encoded) to a serialized
216-
// client query
216+
/// Produces a serialized response (base64-encoded) to a serialized
217+
/// client query
217218
pub fn respond(&self, q: &Query) -> ResultBoxedError<Vec<u8>> {
218219
let resp = Response(
219220
(0..self.db.get_row_width_self())

0 commit comments

Comments
 (0)