-
Notifications
You must be signed in to change notification settings - Fork 11
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
Implementation of arbitrary batched tokens #46
base: main
Are you sure you want to change the base?
Conversation
Not a new token type, but a new token serialisations. Based off of ietf-wg-privacypass/ietf-draft-privacypass-batched-tokens#13
Generate new tests vectors for arbitrary batched tokens
Have both the public and private key when generating batch tokens In addition, ignore fields which are null in the output json
Test is generated and verified
Arbitrary batched tokens need dictionaries.
this relates to ietf-wg-privacypass/ietf-draft-privacypass-batched-tokens#21 |
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.
- how to handle multiple types within the "arbitrary" batched array. Go does not work well with the generic approach proposed in the draft
For simplicity, you need to start using Go interfaces. Go generics may help, but later, once you have common interfaces for the types/API you want to generalize.
- how to correctly expose internals of other tokens type to arbitrary batched tokens, for testing purposes. Specifically, the test vector require blinds to be exposed, which is not possible at the moment.
here I see two options:
Like in JS/TS implementation, we mock the random number generator, so you can inject the blinding values without exposing internals.
In go, I usually write:
- a private method/function (those with underscore names)
createRequest(blind []byte)
- a public function.
CreateRequest() { createRequest(rand.Reader) } ```
Thus, tests are written to check only internal functions. In each case, you have to refactor the current code.
return nil, fmt.Errorf("invalid Tokens encoding") | ||
} | ||
|
||
respTokens := make([][]byte, 0) |
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.
respTokens := make([][]byte, 0) | |
var respTokens [][]byte |
casted, ok := tokenRequest.(*typeF91A.BatchedPrivateTokenRequest) | ||
if !ok || casted.Type() != typeF91A.BatchedPrivateTokenType { | ||
return nil, fmt.Errorf("invalid token request type") | ||
} |
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.
add a default
case to catch unsupported types.
This is an implementation of draft 3 of arbitrary batched tokens as defined in ietf-draft-privacypass-batched-tokens.
The implementation is short, test is much longer. The goal is not to be exhaustive, the draft suggest only tokens type 1 and token type 2 would be supported first.
For review, I am looking for: