Skip to main content

Crate chalametpir_client

Crate chalametpir_client 

Source
Expand description

ChalametPIR: A Rust library implementation of the Chalamet Private Information Retrieval (PIR) protocol, described in https://ia.cr/2024/092.

This crate provides a Rust library implementation of the ChalametPIR Client, enabling efficient and private lookup of value associated with a key, from encoded key-value database, stored PIR server-side. It leverages Binary Fuse Filters for efficient indexing and storage of key-value database and LWE-based encryption for data confidentiality.

§Features

  • Secure Private Information Retrieval: Allows PIR clients to retrieve value from a PIR server without disclosing corresponding key. Server learns neither the value nor the queried key.
  • Error Handling: Comprehensive error handling to catch and report issues during setup, query generation, and response processing.

§Usage

This crate is designed to be used in conjunction with other crates which provides communication mechanism between PIR clients and server. See examples. You’ll typically interact with the Client struct to setup PIR client using server provided seed, hint and filter params. Also for creating PIR queries and processing response received from PIR server. There is also a Query struct, which generally holds the LWE secret vector for a specific queried key and uses it to decode server response.

Add this crate as dependency to your Cargo.toml:

[dependencies]
chalametpir_client = "=0.8.0"

# Or, if you want to run the client on wasm environments.
# chalametpir_client = { version = "=0.8.0", features = "wasm", default-features = false}

Then, you can use it in your code:

use chalametpir_client::{Client, SEED_BYTE_LEN};

fn main() {
    // Assume seed, hint_bytes and filter_param_bytes are received from the PIR server
    let seed_μ = [0u8; SEED_BYTE_LEN];
    let hint_bytes = vec![0u8; 0];
    let filter_param_bytes = vec![0u8; 0];

    match Client::setup(&seed_μ, &hint_bytes, &filter_param_bytes) {
        Ok(mut client) => {
            let key = b"example_key";
            if let Ok(query) = client.query(key) {
                println!("Generated query for key: {:?}", key);
                // Send query to PIR server
                let response = vec![0u8; 0];
                if let Ok(value) = client.process_response(key, &response) {
                    println!("Received response {:?}", response);
                }
            }
        }
        Err(err) => {
            println!("Client setup failed: {}", err);
        }
    };
}

For more see README in ChalametPIR repository @ https://github.com/itzmeanjan/ChalametPIR.

Structs§

Client
Represents a client, performing Chalamet Private Information Retrieval (PIR) queries.
Query
Represents a PIR query. This struct is used to store secret vector c, which is used to recover value from PIR server response.

Enums§

ChalametPIRError
ChalametPIR error codes.

Constants§

SEED_BYTE_LEN