Skip to content
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

feat: introduce CommunitiesKeyDistributor #3774

Merged
merged 5 commits into from
Jul 27, 2023

Conversation

osmaczko
Copy link
Contributor

Introduced CommunitiesKeyDistributor

This component decouples key distribution from the Messenger, enhancing code maintainability, extensibility and testability. It also alleviates the need to impact all methods potentially affecting encryption keys.
Moreover, it allows key distribution inspection for integration tests.

part of: status-im/status-desktop#10998

@status-im-auto
Copy link
Member

status-im-auto commented Jul 19, 2023

Jenkins Builds

Click to see older builds (70)
Commit #️⃣ Finished (UTC) Duration Platform Result
✖️ cb62bd0 #1 2023-07-19 10:06:25 ~2 min tests 📄log
✔️ cb62bd0 #1 2023-07-19 10:07:19 ~3 min linux 📦zip
✔️ cb62bd0 #1 2023-07-19 10:09:05 ~5 min android 📦aar
✔️ cb62bd0 #1 2023-07-19 10:09:16 ~5 min ios 📦zip
✔️ a432328 #2 2023-07-19 16:10:51 ~2 min ios 📦zip
✔️ a432328 #2 2023-07-19 16:10:56 ~2 min linux 📦zip
✔️ a432328 #2 2023-07-19 16:12:40 ~4 min android 📦aar
✖️ a432328 #2 2023-07-19 16:34:22 ~26 min tests 📄log
✖️ a432328 #3 2023-07-19 18:15:56 ~23 min tests 📄log
✖️ a432328 #4 2023-07-19 19:39:18 ~21 min tests 📄log
✔️ 47c9869 #3 2023-07-20 06:58:45 ~2 min linux 📦zip
✔️ 47c9869 #3 2023-07-20 06:58:50 ~2 min ios 📦zip
✔️ 47c9869 #3 2023-07-20 07:00:36 ~4 min android 📦aar
✖️ 47c9869 #5 2023-07-20 07:19:50 ~23 min tests 📄log
✔️ 47c9869 #4 2023-07-20 15:21:06 ~2 min linux 📦zip
✔️ 47c9869 #4 2023-07-20 15:22:00 ~3 min ios 📦zip
✔️ 47c9869 #4 2023-07-20 15:22:44 ~4 min android 📦aar
✖️ 47c9869 #6 2023-07-20 15:44:00 ~25 min tests 📄log
197863a #5 2023-07-20 16:07:53 ~21 sec android 📄log
197863a #5 2023-07-20 16:07:55 ~22 sec ios 📄log
✖️ 197863a #7 2023-07-20 16:08:34 ~58 sec tests 📄log
197863a #5 2023-07-20 16:09:05 ~1 min linux 📄log
✔️ e4456da #6 2023-07-20 16:17:01 ~1 min android 📦aar
✔️ e4456da #6 2023-07-20 16:17:13 ~2 min linux 📦zip
✖️ e4456da #8 2023-07-20 16:17:43 ~2 min tests 📄log
✔️ e4456da #6 2023-07-20 16:17:59 ~2 min ios 📦zip
✖️ 9adf7ed #9 2023-07-20 16:19:40 ~1 min tests 📄log
✔️ 9adf7ed #7 2023-07-20 16:19:45 ~1 min android 📦aar
✔️ 9adf7ed #7 2023-07-20 16:19:46 ~1 min linux 📦zip
✔️ 9adf7ed #7 2023-07-20 16:21:04 ~2 min ios 📦zip
✔️ 0cd5c2d #8 2023-07-20 17:03:21 ~1 min linux 📦zip
✔️ 0cd5c2d #8 2023-07-20 17:03:44 ~1 min android 📦aar
✔️ 0cd5c2d #8 2023-07-20 17:05:28 ~3 min ios 📦zip
✔️ 0cd5c2d #10 2023-07-20 17:21:44 ~19 min tests 📄log
✔️ 9a889cc #9 2023-07-21 18:47:45 ~1 min android 📦aar
✔️ 9a889cc #9 2023-07-21 18:48:47 ~2 min linux 📦zip
✔️ 9a889cc #9 2023-07-21 18:49:02 ~3 min ios 📦zip
✔️ 9a889cc #11 2023-07-21 19:05:27 ~19 min tests 📄log
✔️ 5bc5dae #10 2023-07-24 17:09:31 ~1 min linux 📦zip
✔️ 5bc5dae #10 2023-07-24 17:09:55 ~1 min android 📦aar
✔️ 5bc5dae #10 2023-07-24 17:10:57 ~2 min ios 📦zip
✔️ 5bc5dae #12 2023-07-24 17:25:46 ~17 min tests 📄log
✔️ 22b6bb1 #11 2023-07-24 19:15:29 ~1 min linux 📦zip
✔️ 22b6bb1 #11 2023-07-24 19:16:08 ~2 min android 📦aar
✔️ 22b6bb1 #11 2023-07-24 19:17:09 ~3 min ios 📦zip
✖️ 22b6bb1 #13 2023-07-24 19:18:10 ~4 min tests 📄log
✔️ 6a39b6d #12 2023-07-24 19:29:48 ~1 min linux 📦zip
✔️ 6a39b6d #12 2023-07-24 19:30:03 ~1 min android 📦aar
✔️ 6a39b6d #12 2023-07-24 19:31:37 ~3 min ios 📦zip
✔️ 6a39b6d #14 2023-07-24 19:48:26 ~20 min tests 📄log
✔️ 14f6225 #13 2023-07-26 10:26:11 ~1 min linux 📦zip
✔️ 14f6225 #13 2023-07-26 10:26:36 ~1 min android 📦aar
✔️ 14f6225 #13 2023-07-26 10:28:10 ~3 min ios 📦zip
✔️ 14f6225 #15 2023-07-26 10:28:50 ~4 min tests 📄log
✔️ 83332ab #14 2023-07-26 14:22:13 ~1 min android 📦aar
✔️ 83332ab #14 2023-07-26 14:23:14 ~2 min linux 📦zip
✔️ 83332ab #14 2023-07-26 14:23:46 ~3 min ios 📦zip
✔️ 83332ab #16 2023-07-26 14:36:56 ~16 min tests 📄log
✔️ 13ec1ac #15 2023-07-26 16:18:38 ~1 min linux 📦zip
✔️ 13ec1ac #15 2023-07-26 16:19:00 ~1 min android 📦aar
✔️ 13ec1ac #15 2023-07-26 16:20:57 ~3 min ios 📦zip
✔️ 13ec1ac #17 2023-07-26 16:33:29 ~16 min tests 📄log
✔️ cbc2a41 #16 2023-07-26 16:20:06 ~1 min linux 📦zip
✔️ cbc2a41 #16 2023-07-26 16:21:02 ~1 min android 📦aar
✔️ cbc2a41 #16 2023-07-26 16:23:55 ~2 min ios 📦zip
✔️ cbc2a41 #18 2023-07-26 16:55:18 ~21 min tests 📄log
0570a79 #17 2023-07-27 08:42:30 ~16 sec linux 📄log
0570a79 #17 2023-07-27 08:42:31 ~22 sec android 📄log
0570a79 #17 2023-07-27 08:42:36 ~23 sec ios 📄log
✖️ 0570a79 #19 2023-07-27 08:43:16 ~1 min tests 📄log
Commit #️⃣ Finished (UTC) Duration Platform Result
✖️ 85c3705 #20 2023-07-27 08:47:51 ~1 min tests 📄log
✔️ 85c3705 #18 2023-07-27 08:48:09 ~1 min linux 📦zip
✔️ 85c3705 #18 2023-07-27 08:48:27 ~1 min android 📦aar
✔️ 85c3705 #18 2023-07-27 08:49:42 ~3 min ios 📦zip
✔️ 5d901bd #19 2023-07-27 08:58:31 ~1 min linux 📦zip
✔️ 5d901bd #19 2023-07-27 08:58:58 ~1 min android 📦aar
✔️ 5d901bd #19 2023-07-27 08:59:57 ~2 min ios 📦zip
✔️ 5d901bd #21 2023-07-27 09:18:37 ~21 min tests 📄log

pushNotificationClient: pushNotificationClient,
pushNotificationServer: pushNotificationServer,
communitiesManager: communitiesManager,
communitiesKeyDistributor: &CommunitiesKeyDistributorImpl{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just cosmetics, but we could have a NewKeyDistributor() factory fn for this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was thinking about factory as well, but since this struct doesn't need any special initialization, I left it as is.

}

return result
}()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason this is wrapped in an IIFE? Nothing that needs change, just curious

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It represents the intention a bit better, you can read straight away "this piece of code is responsible for obtaining recentlyPublishedOrgs". Also, this way I don't pollute the scope with unneeded ownedOrgs variable.

@osmaczko osmaczko force-pushed the feat/communities-key-distributor branch from cb62bd0 to a432328 Compare July 19, 2023 16:07
@osmaczko osmaczko force-pushed the feat/encryption-action branch from af9eecd to 9de6436 Compare July 20, 2023 06:55
@osmaczko osmaczko force-pushed the feat/communities-key-distributor branch from a432328 to 47c9869 Compare July 20, 2023 06:55
@osmaczko osmaczko force-pushed the feat/encryption-action branch 3 times, most recently from 7a45373 to 2416ffa Compare July 20, 2023 08:30
Base automatically changed from feat/encryption-action to develop July 20, 2023 15:17
@osmaczko osmaczko force-pushed the feat/communities-key-distributor branch 7 times, most recently from 22b6bb1 to 6a39b6d Compare July 24, 2023 19:27
@osmaczko
Copy link
Contributor Author

Waits for QA: status-im/status-desktop#11657

@osmaczko osmaczko requested a review from mprakhov July 25, 2023 08:35
Copy link
Member

@Samyoul Samyoul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your patience and your work here with this PR. 🙏

@@ -35,4 +35,5 @@ type RawMessage struct {
CommunityKeyExMsgType CommKeyExMsgType
Ephemeral bool
BeforeDispatch func(*RawMessage) error
HashRatchetGroupID []byte
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice change.

@@ -3447,47 +3447,49 @@ func (s *MessengerCommunitiesSuite) TestStartCommunityRekeyLoop() {
s.Require().False(c.Encrypted())
// TODO some check that there are no keys for the community. Alt for s.Require().Zero(c.RekeyedAt().Unix())

// Update the community to use encryption and check the values
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

were your new changes causing this test to fail?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It didn't compile because I removed UpdateCommunityEncryption. I will address that in follow-up.

@osmaczko osmaczko force-pushed the feat/communities-key-distributor branch 4 times, most recently from 0570a79 to 85c3705 Compare July 27, 2023 08:46
osmaczko added 5 commits July 27, 2023 10:55
This component decouples key distribution from the Messenger, enhancing
code maintainability, extensibility and testability.
It also alleviates the need to impact all methods potentially affecting
encryption keys.
Moreover, it allows key distribution inspection for integration tests.

part of: status-im/status-desktop#10998
- distribute ratchet keys at both community and channel levels
- use explicit `HashRatchetGroupID` in ecryption layer, instead of
  inheriting `groupID` from `CommunityID`
- populate `HashRatchetGroupID` with `CommunityID+ChannelID` for
  channels, and `CommunityID` for whole community
- hydrate channels with members; channel members are now subset of
  community members
- include channel permissions in periodic permissions check

closes: status-im/status-desktop#10998
@osmaczko osmaczko force-pushed the feat/communities-key-distributor branch from 85c3705 to 5d901bd Compare July 27, 2023 08:56
@osmaczko osmaczko merged commit cec8179 into develop Jul 27, 2023
@osmaczko osmaczko deleted the feat/communities-key-distributor branch July 27, 2023 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants