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

Document the purpose of `point.canonical()` #11

Open wyatt-howe opened 5 months ago

wyatt-howe commented 5 months ago

Document the purpose of point.canonical(), performance benefit, equality of the bytes returned by point.to_bytes().

We just need to be clear that the bytes spit out (when you type a point variable into the interpreter, or print .to_bytes()) for p1 and p2 where p1 == p2 are not always the same.

Then, we can have .to_bytes(canonicalize=True) be the default and clarify that .to_bytes(canonicalize=False) is faster if you aren't doing byte-to-byte comparisons or other derivations directly from the bytes spit out.

Users of this library need to know that assert (p1.to_bytes() == p2.to_bytes()) == (p1 == p2) will sometimes fail, depending on how the points were computed (due to algorithms for computing point operations using optimizations such as using Jacobi coordinates x,y,z to represent points vs affine coordinates x,y and so on).