From b5c4814b38316c92ec37d66145c4f0f7555315f3 Mon Sep 17 00:00:00 2001 From: Jacob Karlsson Date: Fri, 5 May 2023 14:28:46 +0200 Subject: [PATCH 1/3] Add oldSecrets field to add-member --- group/add-member/v2/schema.js | 6 ++++++ group/add-member/v2/schema.json | 10 ++++++++++ test/add-member.test.js | 9 +++++++++ 3 files changed, 25 insertions(+) diff --git a/group/add-member/v2/schema.js b/group/add-member/v2/schema.js index 8c5533f..3ecec8b 100644 --- a/group/add-member/v2/schema.js +++ b/group/add-member/v2/schema.js @@ -17,6 +17,7 @@ module.exports = { 'type', 'version', 'secret', + 'oldSecrets', 'root', 'creator', 'recps', @@ -32,6 +33,11 @@ module.exports = { pattern: '^v2$' }, secret: { $ref: '#/definitions/secret' }, + oldSecrets: { + type: 'array', + items: [{ $ref: '#/definitions/secret' }], + minItems: 0 + }, root: { $ref: '#/definitions/messageId' }, creator: { $ref: '#/definitions/feedId' }, text: { type: 'string' }, diff --git a/group/add-member/v2/schema.json b/group/add-member/v2/schema.json index e5dca17..af2cd88 100644 --- a/group/add-member/v2/schema.json +++ b/group/add-member/v2/schema.json @@ -5,6 +5,7 @@ "type", "version", "secret", + "oldSecrets", "root", "creator", "recps", @@ -22,6 +23,15 @@ "secret": { "$ref": "#/definitions/secret" }, + "oldSecrets": { + "type": "array", + "items": [ + { + "$ref": "#/definitions/secret" + } + ], + "minItems": 0 + }, "root": { "$ref": "#/definitions/messageId" }, diff --git a/test/add-member.test.js b/test/add-member.test.js index 6cb3346..49bddd8 100644 --- a/test/add-member.test.js +++ b/test/add-member.test.js @@ -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 @@ -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.false(isValid(noOld), 'fails on missing oldSecrets') + + const emptyOld = Mock() + emptyOld.oldSecrets = [] + t.true(isValid(emptyOld), 'allows empty oldSecrets') + t.end() }) From dee5074a2b2016261a805e1053f598b800985887 Mon Sep 17 00:00:00 2001 From: Jacob Karlsson Date: Fri, 5 May 2023 14:49:03 +0200 Subject: [PATCH 2/3] Update readme for oldSecrets --- group/add-member/README.md | 12 ++++++++++-- group/add-member/v2/schema.js | 3 +-- group/add-member/v2/schema.json | 3 +-- test/add-member.test.js | 4 ++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/group/add-member/README.md b/group/add-member/README.md index ecb65de..9749f92 100644 --- a/group/add-member/README.md +++ b/group/add-member/README.md @@ -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 @@ -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. Only there when initially adding someone to a group, it should be undefined 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 diff --git a/group/add-member/v2/schema.js b/group/add-member/v2/schema.js index 3ecec8b..8779ac1 100644 --- a/group/add-member/v2/schema.js +++ b/group/add-member/v2/schema.js @@ -17,7 +17,6 @@ module.exports = { 'type', 'version', 'secret', - 'oldSecrets', 'root', 'creator', 'recps', @@ -36,7 +35,7 @@ module.exports = { oldSecrets: { type: 'array', items: [{ $ref: '#/definitions/secret' }], - minItems: 0 + minItems: 1 }, root: { $ref: '#/definitions/messageId' }, creator: { $ref: '#/definitions/feedId' }, diff --git a/group/add-member/v2/schema.json b/group/add-member/v2/schema.json index af2cd88..18fb215 100644 --- a/group/add-member/v2/schema.json +++ b/group/add-member/v2/schema.json @@ -5,7 +5,6 @@ "type", "version", "secret", - "oldSecrets", "root", "creator", "recps", @@ -30,7 +29,7 @@ "$ref": "#/definitions/secret" } ], - "minItems": 0 + "minItems": 1 }, "root": { "$ref": "#/definitions/messageId" diff --git a/test/add-member.test.js b/test/add-member.test.js index 49bddd8..7ce22ee 100644 --- a/test/add-member.test.js +++ b/test/add-member.test.js @@ -98,11 +98,11 @@ test('is-group-add-member', (t) => { const noOld = Mock() noOld.oldSecrets = undefined - t.false(isValid(noOld), 'fails on missing oldSecrets') + 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.false(isValid(emptyOld), 'disallows empty oldSecrets') t.end() }) From f4d3f27a5128032258af847a6e0f217b3d4ad76d Mon Sep 17 00:00:00 2001 From: Jacob Karlsson Date: Fri, 5 May 2023 17:04:39 +0200 Subject: [PATCH 3/3] Allow empty oldSecrets --- group/add-member/README.md | 2 +- group/add-member/v2/schema.js | 2 +- group/add-member/v2/schema.json | 2 +- test/add-member.test.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/group/add-member/README.md b/group/add-member/README.md index 9749f92..34d1a9f 100644 --- a/group/add-member/README.md +++ b/group/add-member/README.md @@ -44,7 +44,7 @@ var content = { Notes: - `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. Only there when initially adding someone to a group, it should be undefined on re-additions. +- `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` diff --git a/group/add-member/v2/schema.js b/group/add-member/v2/schema.js index 8779ac1..361f933 100644 --- a/group/add-member/v2/schema.js +++ b/group/add-member/v2/schema.js @@ -35,7 +35,7 @@ module.exports = { oldSecrets: { type: 'array', items: [{ $ref: '#/definitions/secret' }], - minItems: 1 + minItems: 0 }, root: { $ref: '#/definitions/messageId' }, creator: { $ref: '#/definitions/feedId' }, diff --git a/group/add-member/v2/schema.json b/group/add-member/v2/schema.json index 18fb215..93cdbc6 100644 --- a/group/add-member/v2/schema.json +++ b/group/add-member/v2/schema.json @@ -29,7 +29,7 @@ "$ref": "#/definitions/secret" } ], - "minItems": 1 + "minItems": 0 }, "root": { "$ref": "#/definitions/messageId" diff --git a/test/add-member.test.js b/test/add-member.test.js index 7ce22ee..f140b0f 100644 --- a/test/add-member.test.js +++ b/test/add-member.test.js @@ -102,7 +102,7 @@ test('is-group-add-member', (t) => { const emptyOld = Mock() emptyOld.oldSecrets = [] - t.false(isValid(emptyOld), 'disallows empty oldSecrets') + t.true(isValid(emptyOld), 'allows empty oldSecrets') t.end() })