Skip to content

Commit

Permalink
Merge pull request #32 from ssbc/groupkey-to-secret
Browse files Browse the repository at this point in the history
Rename groupKey to secret
  • Loading branch information
Powersource authored May 9, 2023
2 parents c28d995 + 5c9e91d commit d1058a8
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 41 deletions.
4 changes: 2 additions & 2 deletions group/add-member/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This is about adding people to your group
var content = {
type: "group/add-member",
version: "v2",
groupKey: "3YUat1ylIUVGaCjotAvof09DhyFxE8iGbF6QxLlCWWc=",
secret: "3YUat1ylIUVGaCjotAvof09DhyFxE8iGbF6QxLlCWWc=",
root: "ssb:message/classic/THxjTGPuXvvxnbnAV7xVuVXdhDcmoNtDDN0j3UTxcd8=",
creator: "ssb:feed/bendybutt-v1/VuVXdhDTHxjTGPuXvvxnbnAV7xcmoNtDDN0j3UTxcd8=",
text: "welcome keks!", // optional
Expand Down Expand Up @@ -37,7 +37,7 @@ var content = {

Notes:

- `groupKey` is the symmetric key for the group
- `secret` is the symmetric key for the group
- `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
8 changes: 4 additions & 4 deletions group/add-member/v2/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// SPDX-License-Identifier: LGPL-3.0-only

const {
groupKey,
secret,
messageId,
feedId,
groupId,
Expand All @@ -16,7 +16,7 @@ module.exports = {
required: [
'type',
'version',
'groupKey',
'secret',
'root',
'creator',
'recps',
Expand All @@ -31,7 +31,7 @@ module.exports = {
type: 'string',
pattern: '^v2$'
},
groupKey: { $ref: '#/definitions/groupKey' },
secret: { $ref: '#/definitions/secret' },
root: { $ref: '#/definitions/messageId' },
creator: { $ref: '#/definitions/feedId' },
text: { type: 'string' },
Expand All @@ -53,7 +53,7 @@ module.exports = {
},
additionalProperties: false,
definitions: {
...groupKey,
...secret,
...messageId,
...feedId,
...groupId,
Expand Down
8 changes: 4 additions & 4 deletions group/add-member/v2/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"required": [
"type",
"version",
"groupKey",
"secret",
"root",
"creator",
"recps",
Expand All @@ -19,8 +19,8 @@
"type": "string",
"pattern": "^v2$"
},
"groupKey": {
"$ref": "#/definitions/groupKey"
"secret": {
"$ref": "#/definitions/secret"
},
"root": {
"$ref": "#/definitions/messageId"
Expand Down Expand Up @@ -62,7 +62,7 @@
},
"additionalProperties": false,
"definitions": {
"groupKey": {
"secret": {
"type": "string",
"pattern": "^[a-zA-Z0-9\\/+]{42}[AEIMQUYcgkosw048]=$"
},
Expand Down
4 changes: 2 additions & 2 deletions group/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const feedId = {
pattern: '^ssb:feed/bendybutt-v1/[a-zA-Z0-9_\\-]{42}[AEIMQUYcgkosw048]=$'
}

const groupKey = {
const secret = {
type: 'string',
pattern: '^[a-zA-Z0-9\\/+]{42}[AEIMQUYcgkosw048]=$'
}
Expand Down Expand Up @@ -58,7 +58,7 @@ module.exports = {
messageId: { messageId },
groupId: { groupId },
feedId: { feedId },
groupKey: { groupKey },
secret: { secret },
tangle: {
root: {
tangle: {
Expand Down
2 changes: 1 addition & 1 deletion group/initEpoch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const groupId = 'ssb:identity/group/g_JTmMEjG4JP2aQAO0LM8tIoRtNkTq07Se6h1qwnQKb=
var plainText = {
type: 'group/init'
version: 'v2',
groupKey: group_key.toString('base64'),
secret: group_secret.toString('base64'),
tangles: {
group: {
root: groupRoot,
Expand Down
8 changes: 4 additions & 4 deletions group/initEpoch/v2/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
//
// SPDX-License-Identifier: LGPL-3.0-only

const { groupKey, tangle, groupId, feedId } = require('../../definitions')
const { secret, tangle, groupId, feedId } = require('../../definitions')

module.exports = {
type: 'object',
required: ['type', 'version', 'groupKey', 'tangles', 'recps'],
required: ['type', 'version', 'secret', 'tangles', 'recps'],
properties: {
type: {
type: 'string',
Expand All @@ -16,7 +16,7 @@ module.exports = {
type: 'string',
pattern: '^v2$'
},
groupKey: { $ref: '#/definitions/groupKey' },
secret: { $ref: '#/definitions/secret' },
tangles: {
type: 'object',
required: ['group', 'epoch', 'members'],
Expand All @@ -39,7 +39,7 @@ module.exports = {
},
additionalProperties: false,
definitions: {
...groupKey,
...secret,
...groupId,
...feedId,
...tangle.any // this pulls in tangle.root and tangle.update
Expand Down
8 changes: 4 additions & 4 deletions group/initEpoch/v2/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"required": [
"type",
"version",
"groupKey",
"secret",
"tangles",
"recps"
],
Expand All @@ -16,8 +16,8 @@
"type": "string",
"pattern": "^v2$"
},
"groupKey": {
"$ref": "#/definitions/groupKey"
"secret": {
"$ref": "#/definitions/secret"
},
"tangles": {
"type": "object",
Expand Down Expand Up @@ -55,7 +55,7 @@
},
"additionalProperties": false,
"definitions": {
"groupKey": {
"secret": {
"type": "string",
"pattern": "^[a-zA-Z0-9\\/+]{42}[AEIMQUYcgkosw048]=$"
},
Expand Down
4 changes: 2 additions & 2 deletions group/initRoot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var prevMsgId = 'ssb:message/classic/Zz-Inkte70Qz1UVKUHIhOgo16Oj_n37PfgmIzLDBgZw
var feed_id = ... BFE binary encoding of feed_id
var prev_msg_id = ... BFE binary encoding of feed_id

var group_key = {
var group_secret = {
key: group_buffer, // group_buffer is symmetric key as buffer
scheme: 'envelope-large-symmetric-group'
}
Expand All @@ -40,7 +40,7 @@ var msg_key = ... make up a one use key for the msg as a buffer
var plainText = {
type: 'group/init'
version: 'v2',
groupKey: group_key.toString('base64'),
secret: group_secret.toString('base64'),
tangles: {
group: {
root: null,
Expand Down
8 changes: 4 additions & 4 deletions group/initRoot/v2/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
//
// SPDX-License-Identifier: LGPL-3.0-only

const { groupKey, tangle } = require('../../definitions')
const { secret, tangle } = require('../../definitions')

module.exports = {
type: 'object',
required: ['type', 'version', 'groupKey', 'tangles'],
required: ['type', 'version', 'secret', 'tangles'],
properties: {
type: {
type: 'string',
Expand All @@ -16,7 +16,7 @@ module.exports = {
type: 'string',
pattern: '^v2$'
},
groupKey: { $ref: '#/definitions/groupKey' },
secret: { $ref: '#/definitions/secret' },
tangles: {
type: 'object',
required: ['group', 'epoch', 'members'],
Expand All @@ -29,7 +29,7 @@ module.exports = {
},
additionalProperties: false,
definitions: {
...groupKey,
...secret,
...tangle.root
}
}
8 changes: 4 additions & 4 deletions group/initRoot/v2/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"required": [
"type",
"version",
"groupKey",
"secret",
"tangles"
],
"properties": {
Expand All @@ -15,8 +15,8 @@
"type": "string",
"pattern": "^v2$"
},
"groupKey": {
"$ref": "#/definitions/groupKey"
"secret": {
"$ref": "#/definitions/secret"
},
"tangles": {
"type": "object",
Expand All @@ -40,7 +40,7 @@
},
"additionalProperties": false,
"definitions": {
"groupKey": {
"secret": {
"type": "string",
"pattern": "^[a-zA-Z0-9\\/+]{42}[AEIMQUYcgkosw048]=$"
},
Expand Down
4 changes: 2 additions & 2 deletions test/add-member.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

const test = require('tape')
const isValid = require('../').validator.group.addMember
const { GroupKey, GroupId, FeedId, MsgId } = require('./helpers')
const { Secret, GroupId, FeedId, MsgId } = require('./helpers')

const Mock = (overwrite = {}) => {
const groupRoot = MsgId()

const base = {
type: 'group/add-member',
version: 'v2',
groupKey: GroupKey(),
secret: Secret(),
root: groupRoot,
creator: FeedId(),
text: 'welcome keks!', // optional
Expand Down
4 changes: 2 additions & 2 deletions test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ const key = () =>
.replace(/\//g, '_')
.replace(/\+/g, '-')

const GroupKey = () => new SecretKey().toString()
const Secret = () => new SecretKey().toString()

const GroupId = () => `ssb:identity/group/${key()}`
const FeedId = () => `ssb:feed/bendybutt-v1/${key()}`
const MsgId = () => `ssb:message/classic/${key()}`

module.exports = {
key,
GroupKey,
Secret,
GroupId,
FeedId,
MsgId
Expand Down
8 changes: 4 additions & 4 deletions test/initEpoch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

const test = require('tape')
const isValid = require('../').validator.group.initEpoch
const { MsgId, GroupKey, GroupId, FeedId } = require('./helpers')
const { MsgId, Secret, GroupId, FeedId } = require('./helpers')

const Mock = (overwrite = {}) => {
const base = {
type: 'group/init',
version: 'v2',
groupKey: GroupKey(),
secret: Secret(),
tangles: {
group: {
root: MsgId(),
Expand Down Expand Up @@ -65,8 +65,8 @@ test('is-epoch-init', (t) => {
t.false(isValid(badRecps), 'fails if encrypted to several groups, not self')

const badKey = Mock()
badKey.groupKey = 'potato'
t.false(isValid(badKey), 'fails if bad groupKey')
badKey.secret = 'potato'
t.false(isValid(badKey), 'fails if bad secret')

const badRoot = Mock()
badRoot.tangles.group.root = GroupId()
Expand Down
4 changes: 2 additions & 2 deletions test/initRoot.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

const test = require('tape')
const isValid = require('../').validator.group.initRoot
const { GroupKey, MsgId, GroupId } = require('./helpers')
const { Secret, MsgId, GroupId } = require('./helpers')

const Mock = (overwrite = {}) => {
const base = {
type: 'group/init',
version: 'v2',
groupKey: GroupKey(),
secret: Secret(),
tangles: {
group: {
root: null,
Expand Down

0 comments on commit d1058a8

Please sign in to comment.