Module BF.Make

Functor building an implementaticon of Bloom filter-based PSI given a Hash implementation.

Parameters

Signature

type t
type elt = Cstruct.t

Plaintext element

type pset = Stdlib.Set.Make(Cstruct).t

Plaintext set

val init : ?⁠salt:Cstruct.t -> ?⁠key_len:int -> ?⁠rng:Nocrypto.Rng.g -> ?⁠error_rate:float -> int -> t

init ?salt ?error_rate ?set size initializes a BF PSI instance.

parameter ?salt

Salt for hashing elements

parameter ?key_len

Byte length of random tokens generated

parameter ?rng

Random number generator; defaults to global generator which must be seeded prior to using this module; see Nocrypto.Rng

parameter ?error_rate

Bloom filter error rate

parameter size

Expected number of elements in Bloom filter; see Bloomf.create

val add : elt -> t -> t

add elem t adds elem to the Bloom filter

val add_set : pset -> t -> t

add_set pset t adds pset of elements to the Bloom filter

val cr_resp : t -> bf:Bitv.t -> Cstruct.t * Cstruct.t * pset * pset

1st step of the challenge-response protocol, run by the responder.

parameter bf

Initiator's Bloom filter

returns

(rrand, ckey, cset, iset)

parameter rrand

Responder's random value

parameter ckey

Challenge HMAC key

parameter cset

Challenge set with HMAC values of candidate intersection elements

parameter iset

Candidate intersection set with plaintext elements

val cr_init : t -> rrand:Cstruct.t -> ckey:Cstruct.t -> cset:pset -> Cstruct.t * pset * pset

2nd step of the challenge-response protocol, run by the initiator.

parameter rrand

Responder's random value

parameter ckey

Challenge HMAC key

parameter cset

Challenge set with HMAC values of candidate intersection elements

returns

(irand, rset, iset)

parameter irand

Initiator's random value

parameter rset

Response set with HMAC values of intersection elements

parameter iset

Final intersection set with plaintext elements

val cr_resp2 : t -> irand:Cstruct.t -> rrand:Cstruct.t -> rset:pset -> iset:pset -> pset

3rd step of the challenge-response protocol, run by the responder.

parameter irand

Initiator's random value

parameter rrand

Responder's random value

parameter rset

Response set with HMAC values of intersection elements

parameter iset

Candidate intersection set returned by cr_resp in the 1st step

returns

Final intersection set with plaintext elements

val priv : t -> pset

priv t returns the set of private, plaintext elements

val pub : t -> Bitv.t

pub t returns the bit vector representation of the Bloom filter with all elements added