Ristretto255- and NIST P384-based verifiable oblivious pseudo(r)andom function (VOPRF) implementation for Python, based on RFC 9497.
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+.
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 bytesAn 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 proofRistretto255-based VOPRFs can be instantiated using the same API, but importing ristretto instead of p384.
No code nor documentation in this repository is from LLM output.