-
Notifications
You must be signed in to change notification settings - Fork 87
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
Unclear purpose of commitment id in key commitment endpoint #258
Comments
The interpretation I would like to suggest (and how I've implemented in my demo):
As for the rotation, looking at chrome's implementation, it appears that once the expiration time (in microseconds!) is reached, the tokens and redemption records (which are keyed based on underlying tokens) are expired. This means keeping the other expired commitment ids around is only needed for the +/- 60s caused by usual time drifts. This functionally means that we likely:
Underlying this is a general uncertainty of how long tokens actually live in the browser. |
@colinbendell doesn't this approach contradict the idea that we might use different keys for public metadata transfer? if we use one key at a time (like in privacypass), then we don't have public metadata anymore. What you describe resembles privacypass implementation more than chromium's PST, I believe they are a bit different at this point. |
how do you mean? Just to clarify, my list of options is just my editorial based on the constraints that Chrome's PST has implemented. The issue is that token and Redemption tokens are invalidated if the commitment id has expired (see linked code above).
Agree. The constraint of having an expiration published forces this situation since we will need to handle key rotation at some point. It's also unclear how far into the future a key commitment would be permitted to use. If we can use an infinite date (say: 2999-01-01) then we sidestep the rotation and have retained the public metadata capabilities. |
I am just saying that what you're suggesting is very similar to what we have in privacypass token keys right now (rotate individual keys, keeping current/next/old, and no public metadata). But from what I read about PST, 6 keys are for public metadata, and supposed to be rotated all at once. The same way https://trusttoken.dev/tt/k has expiry of all keys set to the same date And your demo https://private-state-token.colinbendell.dev/ seems to have a strangely large value of btw I can't spot any code that would expire tokens (not redemption records) if the key is expired. Can you please point me there? So, to follow up, given these conditions
this is how I came to the approach that I've outlined in the description. You approach is also good, but it does not allow for public metadata. |
There are two places that I see the pruning / expiration happen:
The net-net is that once the key commitment has expired, all tokens and redemption records are dead. This is clearly not a desired behaviour since it means that steady-state is never achieved.
This is the same test key that is used in the wpt tests. (where d = ORDER -1n and expiration is Friday, December 31, 9999 11:59:59 PM GMT
I'm hoping that this document is only a guidance. The verbiage is also very loose. Terms like "allowed" and "best practices" seem to suggest that this is origin dependent? See:
|
Thanks a lot, got it.
could be, but know knows :)
Well, if this sentence does really mean that we abruptly expire all previous tokens, than this all makes sense, which is aligned with 6 metadata bits. Otherwise what do you think of the approach of having 3 metadata bits + a legacy key for each bit, e.g.
@dvorak42 maybe you could point out if we are looking at the right direction? |
The "key commitment ID" is an integer in the key commitment, it is recommended to change between key rotations, however currently it has no meaning. It is intended for debugging and we may eventually expose the version the client has through DevTools or other UI, though don't currently do so. "key_id" should be unique per key though otherwise doesn't have a particular pattern they need to abide by (other than being a string representing a uint32 number), and may be dependent on your key rotation protocol. For key rotation, the concrete restrictions are you shouldn't change the key commitment (set of keys) you serve more often than 60 days (this is to avoid rapidly shifting key commitments from being used to target specific sets of users. You can have more than six keys (this needs to be fixed up as part of #233) in your key commitment, however the client will only use the six keys soonest to expire for issuing tokens (and will discard tokens/redemption records associated with other keys). So you can have multiple key sets in a key commitment at a time (but only one keyset will be active). This leads to a couple different ways of handling keys:
There are also more complicated schemes where you keep non-overlapping keys for some buckets and overlapping keys for others. We'll try to add some demos/examples on these key rotation schemes. |
Is this correct:
It would be nice to see some WPT tests around this behaviour because it is not intuitive based on the spec descriptions. |
The logic for getting the current key commitments first filters the key commitments received down to the six most recent keys, before it gets applied through the other checks: That runs before both the redemption record and redemption code checks. Yeah, #233 will hopefully clarify the spec description, adding WPT for it is a good idea we'll add to the queue. |
Ok, so because it is based on |
It's sorted first on the expiry, then on the byte value of the body so it will always consistently choose the same set of keys given that the keys themselves haven't changed. Currently the key commitment itself can only change every 60 days. |
@dvorak42 appreciate your quick response, this is really helpful,. thanks |
I think the algorithm for selecting the top 6 public keys in the key commitment should be published as part of the spec. It will be easy for origins to get out of sync with the implementation. If other browser vendors implement slightly different selection algorithms origins will have to resort to UA sniffing. |
Added a comment on #233 to track that. |
|
It is unclear when to increase
id
field in key commitment endpoint. Is it supposed to be increased after every key rotation or per issuer (re)registration?Also, key rotation procedure seems poorly documented. Do we rotate all 6 keys at once while increasing their respective ids? If we had 6 keys with ids 0-5, then when the keys are rotated, we
Is that correct?
The text was updated successfully, but these errors were encountered: