-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: add @cloudflare/voprf-ts/facade and pass crypto as arg everywhere #49
refactor: add @cloudflare/voprf-ts/facade and pass crypto as arg everywhere #49
Conversation
package.json
Outdated
"examples": "tsx examples/index.ts", | ||
"examples:facade": "tsx examples/facade/index.ts", | ||
"lint": "eslint .", | ||
"bench": "tsx bench/index.ts", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using tsx for examples/bench - CI does build:others
], | ||
"compilerOptions": { | ||
"paths": { | ||
"@cloudflare/voprf-ts": ["../src/index.js"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes examples easily copy/pastable - execute via tsx to support the paths at runtime
return sjcl; | ||
}); | ||
} | ||
// if(typeof module !== 'undefined' && module.exports){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems unneeded - was done to stop tsx complaining
@@ -98,6 +87,8 @@ export interface Group extends SerializationHelpers { | |||
} | |||
|
|||
export interface GroupCons { | |||
fromID(id: GroupID): Group | |||
get(id: GroupID): Group |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idempotent/get/cached semantics
On mobile - I guess using assert means you need a bundler / polyfill
|
src/facade/types.ts
Outdated
// OPRF protocol only specifies encodings for these elements | ||
export type OPRFElement = Elt | Scalar | DLEQProof | ||
|
||
// So we only encode elements, and leave packet encoding to application layer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Key point. Codec class and Server/Client wrappers wouldn't be needed if serialize() serialized objects to objects of same shape, where leaf nodes were Uint8Array(Uint8Array|DLEQProof|Elt|Scalar) | number (ModeID). This would be a more versatile format for a low level library where applications may include elements in their own packet formats.
Ideally it would be possible to only need the facade to implement the privacy pass protocol or similar, so any packets that are going on the wire, will just be an object of serialized elements.
FinalizeData keeps the "wet" EvaluationRequest, so it doesn't need to pointlessly dehydrate/decode serialized blinded Elts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, could you please squash the commits
c6f1f3f
to
53881f1
Compare
Nice! Beginning to feel a lot like xmas! |
Merging now. It should be part of a future release. Thanks for the change @sublimator, and @armfazh for the review! |
Awesome :) |
And indeed, thank you @armfazh |
Supercedes #44
Pass Around Crypto As Arg Everywhere
Toggle this setting here and try the
npm run examples
in both modesFails to build when it's required - added to ci
@cloudflare/voprf-ts/facade, backwards compat impl of #46
See examples
Named imports for examples
Uses tsx to execute examples/bench which supports runtime compilerOptions.paths to provide more readily modifiable examples.
Breaking changes
Minimum changes needed for: cloudflare/privacypass-ts#15
Also see: Port to facade
TODO