cloudflare / voprf-ts

A TypeScript library for Oblivious Pseudorandom Functions
BSD 3-Clause "New" or "Revised" License
28 stars 12 forks source link

feat(group): make Oprf.Group pluggable #35

Closed sublimator closed 1 year ago

sublimator commented 1 year ago

Pluggable Group as easily reviewed first step to @noble support

@cloudflare has currently limited attentional bandwidth to comfortably switch out sjcl for (more performant/secure/maintained) @noble/{curves,hashes} and needs time for a review process. There were some concerns about swapping out the Group implementation wholesale, so this attempts as a logical first step to restructure the code to allow plugging in multiple implementations.

Add indirection

The current code makes direct uses of the implementation classes Group/Elt/Scalar everywhere directly. We extract interface for the instances and constructors and place in src/groupTypes.ts.

The Oprf class, already home to many constants and a getGroup(suiteId) is endowed with a getter/setter for a Group property, of type GroupCons.

Set a default Group

Scjl Group will be configured by default. This, of course, would mean bundling (i.e. webpack) sjcl even where it's not used/needed, but at least it's pluggable!

armfazh commented 1 year ago

Thanks @sublimator