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

Add oldSecrets field to add-member #33

Merged
merged 3 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions group/add-member/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@

:warning: schema.json is generated so don't modify it directly

This is about adding people to your group
This is about adding people to your group, or



```js
var content = {
type: "group/add-member",
version: "v2",
secret: "3YUat1ylIUVGaCjotAvof09DhyFxE8iGbF6QxLlCWWc=",
oldSecrets: [
"apple1ylIUVGaCjotAvof09DhyFxE8iGbF6QxLlCWWc=",
"potatoylIUVGaCjotAvof09DhyFxE8iGbF6QxLlCWWc="
],
root: "ssb:message/classic/THxjTGPuXvvxnbnAV7xVuVXdhDcmoNtDDN0j3UTxcd8=",
creator: "ssb:feed/bendybutt-v1/VuVXdhDTHxjTGPuXvvxnbnAV7xcmoNtDDN0j3UTxcd8=",
text: "welcome keks!", // optional
Expand Down Expand Up @@ -37,7 +43,9 @@ var content = {

Notes:

- `secret` is the symmetric key for the group
- `secret` is the symmetric key for this epoch
- `oldSecrets` is an array of all secrets of all predecessor epochs to this epoch, all the way back to the root epoch. Should be undefined or at least empty on re-additions.
- when initially adding someone to a group, there should be one add-member message per tip epoch. this is to make it clear to the people in that epoch what the members of that epoch are. this is also why `oldSecrets` only should contain secrets of predecessor epochs, not of parallel fork epochs
- `root` is the same as `tangles.group.root`
- the redundancy is here to make it more obvious which root you should be using the compute `group_id`
- in the future our tangles may be _cloaked_ which means this key would become more important
Expand Down
5 changes: 5 additions & 0 deletions group/add-member/v2/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ module.exports = {
pattern: '^v2$'
},
secret: { $ref: '#/definitions/secret' },
oldSecrets: {
type: 'array',
items: [{ $ref: '#/definitions/secret' }],
minItems: 0
},
Comment on lines +35 to +39
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mixmix would it make sense to instead put this in the epoch inits? would save a lot of repetition, but would make initial replication of a group slower

(ps our meeting notes for reference ssbc/ssb-tribes2#76 (comment) )

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

might have to add some special logic in tribes2 for this though which would mean more coding

Copy link
Member

Choose a reason for hiding this comment

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

not a bad idea... but would rather not right now - the problem is that the group/init doesn't necessarily know about all past epochs.... oh, well it does actually, just not the parallel ones.

There might be a problem with how many keys you could add to a new init.
I kinda like the idea the more I think about it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since this is coded already and it's not too bad I'm gonna put this in this "stuff we could maybe do if we have more time" issue ssbc/ssb-group-exclusion-spec#30 and just merge

root: { $ref: '#/definitions/messageId' },
creator: { $ref: '#/definitions/feedId' },
text: { type: 'string' },
Expand Down
9 changes: 9 additions & 0 deletions group/add-member/v2/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@
"secret": {
"$ref": "#/definitions/secret"
},
"oldSecrets": {
"type": "array",
"items": [
{
"$ref": "#/definitions/secret"
}
],
"minItems": 0
},
"root": {
"$ref": "#/definitions/messageId"
},
Expand Down
9 changes: 9 additions & 0 deletions test/add-member.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const Mock = (overwrite = {}) => {
type: 'group/add-member',
version: 'v2',
secret: Secret(),
oldSecrets: [Secret(), Secret()],
root: groupRoot,
creator: FeedId(),
text: 'welcome keks!', // optional
Expand Down Expand Up @@ -95,5 +96,13 @@ test('is-group-add-member', (t) => {
'%shGMltJNglMNLpxdnDGz/Y+j6HukBelnCS84D+GR2DM=.sha256'
t.false(isValid(sigilLink), 'fails if a link is a sigil link and not a uri')

const noOld = Mock()
noOld.oldSecrets = undefined
t.true(isValid(noOld), 'can have missing oldSecrets (e.g. on re-additions)')

const emptyOld = Mock()
emptyOld.oldSecrets = []
t.true(isValid(emptyOld), 'allows empty oldSecrets')

t.end()
})