You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -14,10 +14,14 @@ ChalametPIR allows a client to retrieve a specific value from a key-value databa
14
14
The protocol has two participants:
15
15
16
16
**Server:**
17
+
Implemented by [chalametpir_server](./chalametpir_server) crate.
18
+
17
19
***`setup`:** Initializes the server with a seed, a key-value database, generating a public matrix, a hint matrix, and a Binary Fuse Filter (3-wise XOR or 4-wise XOR, configurable at compile time). It returns serialized representations of the hint matrix and filter parameters. This phase can be completed offline and is completely client-agnostic. But it is very compute-intensive, which is why this library allows you to offload expensive matrix multiplication and transposition to a GPU, gated behind the opt-in `gpu` feature. For large key-value databases (e.g., with >= $2^{18}$ entries), I recommend enabling the `gpu` feature, as it can significantly reduce the cost of the server-setup phase.
18
20
***`respond`:** Processes a client's encrypted query, returning an encrypted response vector.
19
21
20
22
**Client:**
23
+
Implemented by [chalametpir_client](./chalametpir_client) crate. PIR clients can run in-browser, by enabling `wasm` (Web Assembly) feature.
24
+
21
25
***`setup`:** Initializes the client using the seed, serialized hint matrix and filter parameters received from the server.
22
26
***`query`:** Generates an encrypted PIR query for a given key, which can be sent to server.
23
27
***`process_response`:** Decrypts the server's response and extracts the requested value.
If you plan to offload server-setup to GPU, you need to install Vulkan drivers and library for your target setup. I followed https://linux.how2shout.com/how-to-install-vulkan-on-ubuntu-24-04-or-22-04-lts-linux on Ubuntu 24.04 LTS, with Nvidia GPUs - it was easy to setup.
83
87
84
88
## Testing
85
-
The `chalamet_pir` library includes comprehensive tests to ensure functional correctness.
89
+
The ChalametPIR library includes comprehensive tests to ensure functional correctness.
86
90
87
91
-**Property -based Tests:** Verify individual components: matrix operations (multiplication, addition), Binary Fuse Filter construction (3-wise and 4-wise XOR, including bits-per-entry (BPE) validation), and serialization/deserialization of `Matrix` and `BinaryFuseFilter`.
88
92
-**Integration Tests:** Cover end-to-end PIR protocol functionality: key-value database encoding/decoding (parameterized by database size, key/value lengths, and filter arity), and client-server interaction to verify correct value retrieval without key disclosure (tested with both 3-wise and 4-wise XOR filters).
@@ -96,6 +100,12 @@ cargo test --profile test-release
96
100
97
101
# For testing if offloading to GPU works as expected.
98
102
cargo test --features gpu --profile test-release
103
+
104
+
# Testing chalametpir-common lib crate on web assembly target, using `wasmtime`.
105
+
# Note, chalametpir-server lib crate is not wasm friendly.
println!("Retrieved value: '{}'", String::from_utf8_lossy(&value)); // Should print "yellow"
178
-
} else {
179
-
println!("Failed to retrieve value.");
180
-
}
181
-
} else {
182
-
println!("Failed to generate query.");
183
-
}
184
-
}
185
-
```
142
+
- For understanding how PIR server library crate `chalametpir_server` can be used, read [this](./chalametpir_server/README.md).
143
+
- While for using PIR client library crate `chalametpir_client`, read [this](./chalametpir_client/README.md).
144
+
145
+
The constant parameter `ARITY` (3 or 4) in `Server::setup` controls the type of Binary Fuse Filter used to encode the KV database, which affects size of the query vector and the encoded database dimensions, stored in-memory server-side.
186
146
187
-
The constant parameter `ARITY` (3 or 4) in `Server::setup` controls the type of Binary Fuse Filter used to encode the KV database, which affects size of the query vector and the encoded database dimensions, stored in-memory server-side. This implementation should allow you to run PIR queries on a KV database with at max 2^42 (~4 trillion) number of entries.
147
+
> [!IMPORTANT]
148
+
> This implementation should allow you to run PIR queries on a KV database with at max 2^42 (~4 trillion) number of entries. There doesn't exist any limit on how large each key or value needs to be. Keys and values can be of variable length. If values have variable length, database encoder routine pads it to the maximum value byte length present in that key-value database.
188
149
189
-
I maintain one example [program](./examples/kw_pir.rs) which demonstrates usage of the ChalametPIR API.
150
+
I maintain two example binaries, implementing PIR server and client execution flow.
190
151
191
152
```bash
192
-
cargo run --example kw_pir --profile optimized
153
+
# First, issue following command on one terminal window.
154
+
$ cargo run --example server --profile optimized
155
+
156
+
PIR Server listening @ 127.0.0.1:8080
157
+
New connection from PIR client @ 127.0.0.1:43322
158
+
Sent setup data to PIR client @ 127.0.0.1:43322
159
+
Received query of length 200B, from PIR client @ 127.0.0.1:43322
160
+
Sent response of length 104B, to PIR client @ 127.0.0.1:43322
0 commit comments