Metadata-Version: 2.4
Name: voprf
Version: 0.2.0
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Rust
Classifier: Topic :: Security :: Cryptography
Classifier: Topic :: Security
Classifier: Operating System :: OS Independent
License-File: LICENSE
Summary: A verifiable OPRF for Python
Keywords: cryptography,ristretto255,oprf,privacypass,rfc9497,rfc9578
Author: asterized
License-Expression: BSD-3-Clause
Requires-Python: >=3.9
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: homepage, https://github.com/asterized/voprf

# voprf

Ristretto255- and NIST P384-based verifiable [oblivious pseudo(r)andom function (VOPRF)](https://datatracker.ietf.org/doc/rfc9497/) 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.

```py
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:
```py
>>> 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.

