HomePhabricator
Diffusion Comm 75d0111308c5

[native] update one time keys logic

Description

[native] update one time keys logic

Summary:
A lot of changes here... will annotate all of them inline. Here are the big things:

  • consolidated getPrimaryOneTimeKeys and getNotificationsOneTimeKeys into a single API, getOneTimeKeys
  • make sure we only generate one-time keys if we don't have enough unpublished one-time keys
  • rename CryptoModule::getOneTimeKeys to CryptoModule::getOneTimeKeysForPublishing so that it's clear to the caller that the returned keys should be published immediately

Test Plan:
test patch

  1. Modified getOneTimeKeysForPublishing to generate one unpublished one-time key
  2. called `commCoreModule.getOneTimeKeys(10) twice from JS
  3. confirmed that the one unpublished key appeared in otks but not otks2 (all the keys in otks get marked as published so they are no longer accessible on the second call)
  4. confirmed that otks2 was a brand new set of 10 keys
  5. (not in patch) called commCoreModule.getOneTimeKeys(101) and got an error: {"message": "error generateKeys => invalid amount of one-time keys published. Expected 101, got 100"}. this is expected since the account can only hold 100 one-time keys.

Reviewers: ashoat, kamil, marcin

Reviewed By: ashoat, kamil, marcin

Subscribers: tomek

Differential Revision: https://phab.comm.dev/D10977

Details

Provenance
varunAuthored on Feb 6 2024, 2:47 PM
Reviewer
ashoat
Differential Revision
D10977: [native] update one time keys logic
Parents
rCOMM473d743255ef: [lib/web] lift useSortedENSResolvedUsers into lib
Branches
Unknown
Tags
Unknown