Skip to content

Repository files navigation

voprf

Ristretto255- and NIST P384-based verifiable oblivious pseudo(r)andom function (VOPRF) implementation for Python, based on RFC 9497.

Installation

To install, just run:

$ pip install voprf

If a binary is not available, the package will be built if you have a Rust compiler version 1.85+.

Usage

A basic example is shown below.

from voprf import p384
import secrets

server = p384.Evaluator(secrets.token_bytes(32))

client, blinded_input = p384.Client.blind(b"hello!")
blinded_output = server.evaluate(blinded_input)

client.finalize(blinded_output, server.public_key)  # returns a string of bytes

An example of a valid VOPRF output evaluated with the wrong server:

>>> from voprf import p384
>>> import secrets
>>> server1 = p384.Evaluator(secrets.token_bytes(32))
>>> client, blinded_input = p384.Client.blind(b"hello!")
>>> server2 = p384.Evaluator(secrets.token_bytes(32))
>>> blinded_output = server2.evaluate(blinded_input)
>>> client.finalize(blinded_output, server1.public_key)  # server2 evaluates the input but data is verified with server1's public key
Traceback (most recent call last):
  File "<python-input-16>", line 1, in <module>
    client.finalize(blinded_output, server.public_key)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid proof

Ristretto255-based VOPRFs can be instantiated using the same API, but importing ristretto instead of p384.

LLM Disclaimer

No code nor documentation in this repository is from LLM output.

About

A verifiable OPRF implementation for Python

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages