Skip to main content

Crate poprf_ristretto

Crate poprf_ristretto 

Source
Expand description

§poprf-ristretto

RFC 9497 Partially-Oblivious Pseudorandom Function (POPRF) over the ristretto255-SHA512 ciphersuite.

Implements the POPRF protocol variant from RFC 9497 §3.3.3 with the ristretto255-SHA512 ciphersuite defined in §4.1. All RFC 9497 Appendix A test vectors for POPRF/ristretto255-SHA512 pass.

§Quick start

use poprf_ristretto::{PoprfClient, PoprfServer};
use rand_core::OsRng;

let server = PoprfServer::generate(&mut OsRng);
let client = PoprfClient::new(server.public_key());

let input = b"my secret input";
let info  = b"public context";

let (state, blinded) = client.blind(input, info, &mut OsRng).unwrap();
let (evaluated, proof) = server.blind_evaluate(&mut OsRng, &blinded, info).unwrap();
let output = client
    .finalize(input, &state, &evaluated, &blinded, &proof, info)
    .expect("proof verified");

// Server-side offline evaluation must agree.
assert_eq!(output, server.evaluate(input, info).unwrap());

§Wire format

Every wire-bound type exposes a fixed-size byte serialization (from_bytes / to_bytes / LEN constant). All from_bytes implementations enforce canonical encoding (RFC 9496 §A.2) and reject the identity element on Element types (RFC 9497 §4.1).

TypeLENSource
SecretKey32 (Ns)server
PublicKey32 (Ne)server → client
BlindedElement32 (Ne)client → server
EvaluatedElement32 (Ne)server → client
Proof64 (2·Ns)server → client
PoprfBlindState64 (Ns + Ne)client-internal
PoprfOutput64 (Nh)client / server

§Security

§Cargo features

FeatureDefaultDescription
stdyesEnables std::error::Error impl on Error.
allocyesRequired by all protocol APIs (implied by std).
fast-dleqyesVartime Pippenger MSM in DLEQ composite computation.
precomputed-tablesyesWindowed fixed-base tables: ~30 KB per live PoprfInputTable.
serdenoserde::{Serialize, Deserialize} for wire types.

At least one of std or alloc is required to build — the batched protocol APIs return Vec. The crate is #![no_std]-capable with alloc. ZeroizeOnDrop on secret-bearing types is unconditional; there is no cargo feature to disable it.

Structs§

BlindedElement
A blinded element sent from client to server (RFC 9497 §3.3.3).
EvaluatedElement
An evaluated element returned from server to client (RFC 9497 §3.3.3).
PoprfBlindState
Client-side state kept between PoprfClient::blind and PoprfClient::finalize.
PoprfClient
POPRF client.
PoprfInputTable
A pre-hashed POPRF input, for repeated offline evaluation of the same input under different info values (see PoprfServer::evaluate_tables).
PoprfOutput
POPRF output: SHA-512 digest (64 bytes).
PoprfServer
POPRF server.
Proof
A DLEQ proof: the scalar pair (c, s) from RFC 9497 §2.2.1.
PublicKey
POPRF server public key pkS = skS·G (RFC 9497 §3.2).
SecretKey
POPRF server secret key skS (RFC 9497 §3.2).

Enums§

Error
All errors raised by this crate.

Constants§

MODE_POPRF
Mode identifier for POPRF (RFC 9497 §3.1).
SUITE_ID
RFC 9497 ciphersuite identifier for this crate.

Functions§

derive_key_pair
DeriveKeyPair(seed, info) — RFC 9497 §3.2.1.
generate_key_pair
GenerateKeyPair() — RFC 9497 §3.2.