nthparty / oblivious

Python library that serves as an API for common cryptographic primitives used to implement OPRF, OT, and PSI protocols.
https://pypi.org/project/oblivious
MIT License
26 stars 5 forks source link

Multiple curves #5

Closed wyatt-howe closed 2 years ago

wyatt-howe commented 2 years ago

BN254 can be imported by writing from oblivious.bn254 import point, scalar. Likewise, Ristretto255 can be imported by writing from oblivious.ristretto import point, scalar.

>>> import timeit
>>> timeit.timeit('s * p', setup='from oblivious.bn254 import point, scalar; (s, p) = (scalar.random(), point.random())', number=100000)
4.401820125
>>> timeit.timeit('s * p', setup='from oblivious.ristretto import point, scalar; (s, p) = (scalar.random(), point.random())', number=100000)
4.364272208

Encryption performance is almost identical on both curves.

Deterministic scalar/ID synthesis is explained in the doctest below.

https://github.com/nthparty/oblivious/blob/20ac2925d62e755f02fd8c03401033a8e98e2c1a/oblivious/bn254.py#L803-L810