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).
| Type | LEN | Source |
|---|---|---|
SecretKey | 32 (Ns) | server |
PublicKey | 32 (Ne) | server → client |
BlindedElement | 32 (Ne) | client → server |
EvaluatedElement | 32 (Ne) | server → client |
Proof | 64 (2·Ns) | server → client |
PoprfBlindState | 64 (Ns + Ne) | client-internal |
PoprfOutput | 64 (Nh) | client / server |
§Security
- Constant-time discipline.
PoprfClient::finalize,PoprfClient::finalize_batch,PoprfServer::blind_evaluate,PoprfServer::blind_evaluate_batch,PoprfServer::evaluate, andPoprfServer::evaluate_tablesare constant-time in every secret scalar:skS, the clientblind, the DLEQ proof noncer, and the per-infoevaluation scalart = skS + m. The test-vector siblings (PoprfClient::blind_with_scalar,PoprfServer::blind_evaluate_with_proof_scalar,PoprfServer::blind_evaluate_batch_with_proof_scalar) share the same path; the caller supplies the random scalar instead of sampling it from a CSPRNG. DLEQ challenge equality usessubtle::ConstantTimeEq.PoprfOutputequality is constant-time. fast-dleqvartime MSM is used for DLEQ composite computation. This is safe because the per-element scalarsdᵢare derived from a public Fiat-Shamir transcript (RFC 9497 §2.2.1) and contain no secret input.- Secret material.
SecretKeyis server-secret.PoprfBlindStatecontains the client-secret blinding scalar; never transmit it to the server. All secret-bearing types (SecretKey,PoprfServer,PoprfBlindState,PoprfOutput) implementZeroizeOnDropand are wiped automatically when they go out of scope.Proofis wire data with no secret content (see its type-level docs) and is not zeroized; nor isPoprfInputTable(see its docs). infoparameter. Both client and server must agree oninfoout-of-band. A mismatch yieldsError::Verifyon the client (the reconstructedtweakedKeywill not match the server’s), not silent garbage.- Domain separation. Every hash invocation is namespaced with a DST
of the form
<label> || "OPRFV1-" || I2OSP(mode, 1) || "-" || suite_idper RFC 9497 §3.1 / §4.
§Cargo features
| Feature | Default | Description |
|---|---|---|
std | yes | Enables std::error::Error impl on Error. |
alloc | yes | Required by all protocol APIs (implied by std). |
fast-dleq | yes | Vartime Pippenger MSM in DLEQ composite computation. |
precomputed-tables | yes | Windowed fixed-base tables: ~30 KB per live PoprfInputTable. |
serde | no | serde::{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§
- Blinded
Element - A blinded element sent from client to server (RFC 9497 §3.3.3).
- Evaluated
Element - An evaluated element returned from server to client (RFC 9497 §3.3.3).
- Poprf
Blind State - Client-side state kept between
PoprfClient::blindandPoprfClient::finalize. - Poprf
Client - POPRF client.
- Poprf
Input Table - A pre-hashed POPRF input, for repeated offline evaluation of the same
input under different
infovalues (seePoprfServer::evaluate_tables). - Poprf
Output - POPRF output: SHA-512 digest (64 bytes).
- Poprf
Server - POPRF server.
- Proof
- A DLEQ proof: the scalar pair
(c, s)from RFC 9497 §2.2.1. - Public
Key - POPRF server public key
pkS = skS·G(RFC 9497 §3.2). - Secret
Key - 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.