@kumiai/mls 0.13.6 → 0.13.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/authentication.js +1 -9
- package/lib/capability.js +3 -2
- package/lib/codec.js +2 -1
- package/lib/crypto.js +1 -9
- package/lib/group-handle.js +3 -7
- package/lib/head.js +2 -12
- package/lib/lifecycle.js +5 -7
- package/lib/policy.js +2 -12
- package/lib/recovery.js +6 -23
- package/lib/sender-data.js +5 -15
- package/package.json +7 -5
package/lib/authentication.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { assertCapabilityToken, assertNonExpired, assertValidDelegation, assertValidIssuedAt, assertValidNotBefore, checkCapability, hasPermission } from '@kokuin/capability';
|
|
2
2
|
import { decodeMultibase, decodePeer4, getAlgorithmAndPublicKey, getSignatureInfo, getVerifier, isPeer4, normalizeDID, verifyToken } from '@kokuin/token';
|
|
3
|
+
import { constantTimeEqual } from '@sozai/bytes';
|
|
3
4
|
import { fromB64U, fromUTF } from '@sozai/codec';
|
|
4
5
|
import { defaultCredentialTypes } from 'ts-mls';
|
|
5
6
|
import { assertCapabilityLifetime, assertControllerGrant, capabilityKey, MAX_LEAF_LIFETIME, MAX_TRUSTED_GRANT_LIFETIME, MLS_LEAF_ACT, MLS_LEAF_RES, readCapability } from './capability.js';
|
|
@@ -14,15 +15,6 @@ export { MLS_LEAF_ACT, MLS_LEAF_RES } from './capability.js';
|
|
|
14
15
|
/** The action a management capability must grant to mutate a profile's device registry. */ export const MLS_DEVICES_ACT = 'manage';
|
|
15
16
|
/** The resource half — kumiai-namespaced and group-independent. */ export const MLS_DEVICES_RES = 'kumiai/devices';
|
|
16
17
|
const EMPTY_DENY = new Set();
|
|
17
|
-
function constantTimeEqual(a, b) {
|
|
18
|
-
if (a.length !== b.length) return false;
|
|
19
|
-
let diff = 0;
|
|
20
|
-
for(let i = 0; i < a.length; i++){
|
|
21
|
-
// biome-ignore lint/style/noNonNullAssertion: index is within bounds
|
|
22
|
-
diff |= a[i] ^ b[i];
|
|
23
|
-
}
|
|
24
|
-
return diff === 0;
|
|
25
|
-
}
|
|
26
18
|
/**
|
|
27
19
|
* Whether `signaturePublicKey` is the key the parsed identity's DID authenticates with — the
|
|
28
20
|
* floating-leaf binding, shared by floating validation and the bound branch (a bound leaf is a
|
package/lib/capability.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { audienceConfirmation, hasPermission } from '@kokuin/capability';
|
|
2
2
|
import { tryDecodeKey } from '@kokuin/controller';
|
|
3
3
|
import { isSignedToken, normalizeDID, stringifyToken } from '@kokuin/token';
|
|
4
|
-
import {
|
|
4
|
+
import { equalBytes } from '@sozai/bytes';
|
|
5
|
+
import { b64uToJSON } from '@sozai/json';
|
|
5
6
|
import { LeafBindingError } from './errors.js';
|
|
6
7
|
/** The action a device capability must grant for a leaf to authenticate as a kumiai MLS leaf. */ export const MLS_LEAF_ACT = 'authenticate';
|
|
7
8
|
/** The resource half of that grant — kumiai-namespaced, group-independent. */ export const MLS_LEAF_RES = 'kumiai/mls-leaf';
|
|
@@ -127,7 +128,7 @@ export async function mintLeafCapability(params) {
|
|
|
127
128
|
throw new LeafBindingError('issuer-mismatch');
|
|
128
129
|
}
|
|
129
130
|
const key = capabilityKey(parent.payload);
|
|
130
|
-
if (!key.publicKey
|
|
131
|
+
if (!equalBytes(key.publicKey, params.signer.publicKey)) {
|
|
131
132
|
throw new LeafBindingError('issuer-mismatch');
|
|
132
133
|
}
|
|
133
134
|
if (payload.exp > parent.payload.exp) throw new LeafBindingError('child-outlives-parent');
|
package/lib/codec.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { equalBytes } from '@sozai/bytes';
|
|
1
2
|
import { clientStateDecoder, clientStateEncoder, encode } from 'ts-mls';
|
|
2
3
|
import { ClientStateReservationError } from './errors.js';
|
|
3
4
|
/** v2: flags, optional reservation, length-prefixed ts-mls body, then sorted leaf-zero refs.
|
|
@@ -52,7 +53,7 @@ export function decodeClientState(encoded) {
|
|
|
52
53
|
const state = result[0];
|
|
53
54
|
// rc.13 accepts invalid optional tags and elements extending past an inner vector boundary.
|
|
54
55
|
const canonicalBody = encode(clientStateEncoder, state);
|
|
55
|
-
if (
|
|
56
|
+
if (!equalBytes(canonicalBody, bodyCopy)) {
|
|
56
57
|
return undefined;
|
|
57
58
|
}
|
|
58
59
|
const textDecoder = new TextDecoder('utf-8', {
|
package/lib/crypto.js
CHANGED
|
@@ -16,19 +16,11 @@ import { expand as hkdfExpand, extract as hkdfExtract } from '@noble/hashes/hkdf
|
|
|
16
16
|
import { hmac } from '@noble/hashes/hmac.js';
|
|
17
17
|
import { sha256, sha384, sha512 } from '@noble/hashes/sha2.js';
|
|
18
18
|
import { concatBytes } from '@noble/hashes/utils.js';
|
|
19
|
+
import { constantTimeEqual } from '@sozai/bytes';
|
|
19
20
|
import { createRuntime } from '@sozai/runtime';
|
|
20
21
|
// ---------------------------------------------------------------------------
|
|
21
22
|
// Helpers
|
|
22
23
|
// ---------------------------------------------------------------------------
|
|
23
|
-
function constantTimeEqual(a, b) {
|
|
24
|
-
if (a.length !== b.length) return false;
|
|
25
|
-
let diff = 0;
|
|
26
|
-
for(let i = 0; i < a.length; i++){
|
|
27
|
-
// biome-ignore lint/style/noNonNullAssertion: index is within bounds
|
|
28
|
-
diff |= a[i] ^ b[i];
|
|
29
|
-
}
|
|
30
|
-
return diff === 0;
|
|
31
|
-
}
|
|
32
24
|
function i2osp(value, w) {
|
|
33
25
|
const result = new Uint8Array(w);
|
|
34
26
|
let n = value;
|
package/lib/group-handle.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { assertTimeClaimsValid, decodeSignedToken, normalizeDID } from '@kokuin/token';
|
|
2
2
|
import { createMutex, maybeYield } from '@sozai/async';
|
|
3
|
+
import { equalBytes } from '@sozai/bytes';
|
|
3
4
|
import { toB64 } from '@sozai/codec';
|
|
4
5
|
import { EventEmitter } from '@sozai/event';
|
|
5
6
|
import { contentTypes, createApplicationMessage, createProposal, decode, defaultCredentialTypes, defaultKeyRetentionConfig, defaultProposalTypes, encode, isDefaultCredential, isDefaultProposal, leafNodeSources, mlsExporter, mlsMessageDecoder, mlsMessageEncoder, processMessage as mlsProcessMessage, nodeTypes, senderTypes, UsageError, wireformats } from 'ts-mls';
|
|
@@ -130,11 +131,6 @@ export function mutexFor(handle) {
|
|
|
130
131
|
throw new UsageError('Cannot send messages after being removed from group');
|
|
131
132
|
}
|
|
132
133
|
}
|
|
133
|
-
/** AAD is not secret, so a length/byte compare is enough — no constant-time need. */ function bytesEqual(a, b) {
|
|
134
|
-
if (a.length !== b.length) return false;
|
|
135
|
-
for(let i = 0; i < a.length; i++)if (a[i] !== b[i]) return false;
|
|
136
|
-
return true;
|
|
137
|
-
}
|
|
138
134
|
/** Thrown by GroupHandle.processMessage when the commit policy rejects an incoming
|
|
139
135
|
* commit. The handle is left at its pre-commit epoch. */ export class CommitRejectedError extends Error {
|
|
140
136
|
#proposals;
|
|
@@ -1359,7 +1355,7 @@ function ledgerLogEntry(entryID, token, verified) {
|
|
|
1359
1355
|
if (pm == null) throw new Error('decrypt: not a PrivateMessage application frame');
|
|
1360
1356
|
// Pre-open: reject a wrong-topic frame from its CLEARTEXT authenticatedData before
|
|
1361
1357
|
// mlsProcessMessage consumes a ratchet generation. Same lane as the sender-leaf read below.
|
|
1362
|
-
if (opts?.expectedAAD != null && !
|
|
1358
|
+
if (opts?.expectedAAD != null && !equalBytes(pm.authenticatedData, opts.expectedAAD)) {
|
|
1363
1359
|
throw new Error('decrypt: frame authenticated data does not match expected AAD');
|
|
1364
1360
|
}
|
|
1365
1361
|
// Read the sender BEFORE opening: the sender-data secret is epoch-level and this
|
|
@@ -1405,7 +1401,7 @@ function ledgerLogEntry(entryID, token, verified) {
|
|
|
1405
1401
|
return mutexFor(this).run(async ()=>{
|
|
1406
1402
|
const pm = readPrivateFrame(decoded, contentTypes.application);
|
|
1407
1403
|
if (pm == null) throw new Error('decryptStaged: not a PrivateMessage application frame');
|
|
1408
|
-
if (opts.expectedAAD != null && !
|
|
1404
|
+
if (opts.expectedAAD != null && !equalBytes(pm.authenticatedData, opts.expectedAAD)) {
|
|
1409
1405
|
throw new Error('decryptStaged: frame authenticated data does not match expected AAD');
|
|
1410
1406
|
}
|
|
1411
1407
|
const historical = this.#state.historicalReceiverData.get(pm.epoch);
|
package/lib/head.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { sha256 } from '@noble/hashes/sha2.js';
|
|
2
2
|
import { concatBytes } from '@noble/hashes/utils.js';
|
|
3
|
+
import { equalBytes } from '@sozai/bytes';
|
|
3
4
|
import { makeCustomExtension } from 'ts-mls';
|
|
4
5
|
import { LEDGER_HEAD_EXTENSION_TYPE } from './anchor.js';
|
|
5
6
|
/** Binary version tag for the encoded ledger-head extension. */ export const LEDGER_HEAD_VERSION = 1;
|
|
@@ -125,23 +126,12 @@ function findHeadExtension(handle) {
|
|
|
125
126
|
}
|
|
126
127
|
return head;
|
|
127
128
|
}
|
|
128
|
-
function bytesEqual(a, b) {
|
|
129
|
-
if (a.length !== b.length) {
|
|
130
|
-
return false;
|
|
131
|
-
}
|
|
132
|
-
for(let i = 0; i < a.length; i++){
|
|
133
|
-
if (a[i] !== b[i]) {
|
|
134
|
-
return false;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return true;
|
|
138
|
-
}
|
|
139
129
|
/**
|
|
140
130
|
* Whether a recomputed head equals the authenticated one — the predicate form of
|
|
141
131
|
* {@link assertHeadMatches}. Two entry points on one comparison: a fail-closed gate
|
|
142
132
|
* throws, a local invariant check reads the boolean.
|
|
143
133
|
*/ export function headsMatch({ expected, actual }) {
|
|
144
|
-
return
|
|
134
|
+
return equalBytes(expected, actual);
|
|
145
135
|
}
|
|
146
136
|
/**
|
|
147
137
|
* Assert a recomputed head matches the authenticated one, or throw
|
package/lib/lifecycle.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { decodeKey } from '@kokuin/controller';
|
|
2
2
|
import { normalizeDID } from '@kokuin/token';
|
|
3
|
+
import { equalBytes } from '@sozai/bytes';
|
|
3
4
|
import { defaultCredentialTypes, defaultProposalTypes, isDefaultCredential, isDefaultProposal, nodeTypes } from 'ts-mls';
|
|
4
5
|
import { LEDGER_HEAD_EXTENSION_TYPE } from './anchor.js';
|
|
5
6
|
import { checkHolderEvidence, verifyLeafCredential } from './authentication.js';
|
|
@@ -154,11 +155,8 @@ export async function leafExpiry({ binding, registry, controller, ...options })
|
|
|
154
155
|
});
|
|
155
156
|
return status.status === 'effective' ? status.lease : undefined;
|
|
156
157
|
}
|
|
157
|
-
function bytesEqual(a, b) {
|
|
158
|
-
return a.length === b.length && a.every((byte, index)=>byte === b[index]);
|
|
159
|
-
}
|
|
160
158
|
function credentialEqual(a, b) {
|
|
161
|
-
return isDefaultCredential(a.credential) && isDefaultCredential(b.credential) && a.credential.credentialType === defaultCredentialTypes.basic && b.credential.credentialType === defaultCredentialTypes.basic &&
|
|
159
|
+
return isDefaultCredential(a.credential) && isDefaultCredential(b.credential) && a.credential.credentialType === defaultCredentialTypes.basic && b.credential.credentialType === defaultCredentialTypes.basic && equalBytes(a.credential.identity, b.credential.identity);
|
|
162
160
|
}
|
|
163
161
|
/**
|
|
164
162
|
* Whether a direct capability from the anchor's controller replaces a leaf whose issuer the group
|
|
@@ -198,7 +196,7 @@ async function checkBinding(group, leaf, previous, /** The leaf arrives in a Wel
|
|
|
198
196
|
if (record != null && (binding == null || normalizeDID(binding.id) !== record.controller)) throw new LeafBindingError('controller-mismatch');
|
|
199
197
|
if (previous != null) {
|
|
200
198
|
const old = identity(previous);
|
|
201
|
-
if (parsed.id !== old.id || parsed.longForm !== old.longForm || !
|
|
199
|
+
if (parsed.id !== old.id || parsed.longForm !== old.longForm || !equalBytes(leaf.signaturePublicKey, previous.signaturePublicKey) || old.controller != null && (binding == null || binding.id !== old.controller.id)) throw new LeafBindingError('identity-change');
|
|
202
200
|
if (binding != null && old.controller != null && bindingIssuedAt(binding) < bindingIssuedAt(old.controller) && !replacesRevokedIssuer(group, binding, old.controller)) throw new LeafBindingError('renewal-order');
|
|
203
201
|
}
|
|
204
202
|
if (binding == null) return;
|
|
@@ -268,7 +266,7 @@ export async function validateEntry(group, leaf, previous, judging = {
|
|
|
268
266
|
}
|
|
269
267
|
/** The same credential and key a tree already holds at that leaf index. */ export function isUnchangedLeaf(tree, index, leaf) {
|
|
270
268
|
const held = leafAt(tree, index);
|
|
271
|
-
return held != null && credentialEqual(held, leaf) &&
|
|
269
|
+
return held != null && credentialEqual(held, leaf) && equalBytes(held.signaturePublicKey, leaf.signaturePublicKey);
|
|
272
270
|
}
|
|
273
271
|
async function checkSurvivors(group, tree, registry, origin, policy) {
|
|
274
272
|
const denied = denySetOf(registry);
|
|
@@ -550,7 +548,7 @@ export async function validateWelcomeTree(group, judging = {
|
|
|
550
548
|
if (!external && senderIndex != null) {
|
|
551
549
|
const next = leafAt(state.ratchetTree, senderIndex);
|
|
552
550
|
const old = leafAt(before, senderIndex);
|
|
553
|
-
if (next != null && old != null && (!credentialEqual(next, old) || !
|
|
551
|
+
if (next != null && old != null && (!credentialEqual(next, old) || !equalBytes(next.signaturePublicKey, old.signaturePublicKey))) {
|
|
554
552
|
if (controller != null && (hasRemoves || proofs.length > 0)) throw new LeafBindingError('identity-change');
|
|
555
553
|
await validateEntry(group, next, old, judging(senderIndex, next));
|
|
556
554
|
}
|
package/lib/policy.js
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
import { normalizeDID } from '@kokuin/token';
|
|
2
|
+
import { equalBytes } from '@sozai/bytes';
|
|
2
3
|
import { defaultProposalTypes, isDefaultProposal } from 'ts-mls';
|
|
3
4
|
import { decodeGroupAnchor, GROUP_ANCHOR_EXTENSION_TYPE, LEDGER_HEAD_EXTENSION_TYPE, RESERVED_EXTENSION_TYPE } from './anchor.js';
|
|
4
5
|
import { didFromCredential } from './credential.js';
|
|
5
|
-
function bytesEqual(a, b) {
|
|
6
|
-
if (a.length !== b.length) {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
for(let i = 0; i < a.length; i++){
|
|
10
|
-
if (a[i] !== b[i]) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
6
|
/**
|
|
17
7
|
* Fail-closed admin check: no DID, a DID absent from the roster, or any role but `admin`, is
|
|
18
8
|
* not admin. An undefined leaf (external commit with no committer) is never admin.
|
|
@@ -86,7 +76,7 @@ function bytesEqual(a, b) {
|
|
|
86
76
|
// external_senders, required_capabilities) fails the instanceof guard and is rejected even
|
|
87
77
|
// if unmodified — fail-closed liveness, not a security gap, since no group here anchors one
|
|
88
78
|
// today. Revisit if one is introduced.
|
|
89
|
-
if (!(got.extensionData instanceof Uint8Array) || !(want.extensionData instanceof Uint8Array) || !
|
|
79
|
+
if (!(got.extensionData instanceof Uint8Array) || !(want.extensionData instanceof Uint8Array) || !equalBytes(got.extensionData, want.extensionData)) {
|
|
90
80
|
return 'reject';
|
|
91
81
|
}
|
|
92
82
|
}
|
package/lib/recovery.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { decodeMultibase, encodeMultibase, isVerifiedToken, normalizeDID, stringifyToken, verifyToken } from '@kokuin/token';
|
|
2
2
|
import { sha256 } from '@noble/hashes/sha2.js';
|
|
3
|
+
import { concatBytes, equalBytes } from '@sozai/bytes';
|
|
3
4
|
import { decode, encode, mlsMessageDecoder, mlsMessageEncoder, wireformats } from 'ts-mls';
|
|
4
5
|
import { LEDGER_HEAD_EXTENSION_TYPE, readGroupAnchorExtension } from './anchor.js';
|
|
5
6
|
import { exportGroupInfo, readGroupInfoBinding } from './group.js';
|
|
@@ -87,24 +88,6 @@ const LEDGER_REPLY = {
|
|
|
87
88
|
framed.set(bytes, 4);
|
|
88
89
|
return framed;
|
|
89
90
|
}
|
|
90
|
-
function concat(parts) {
|
|
91
|
-
let length = 0;
|
|
92
|
-
for (const part of parts)length += part.length;
|
|
93
|
-
const out = new Uint8Array(length);
|
|
94
|
-
let offset = 0;
|
|
95
|
-
for (const part of parts){
|
|
96
|
-
out.set(part, offset);
|
|
97
|
-
offset += part.length;
|
|
98
|
-
}
|
|
99
|
-
return out;
|
|
100
|
-
}
|
|
101
|
-
function bytesEqual(a, b) {
|
|
102
|
-
if (a.length !== b.length) return false;
|
|
103
|
-
for(let i = 0; i < a.length; i++){
|
|
104
|
-
if (a[i] !== b[i]) return false;
|
|
105
|
-
}
|
|
106
|
-
return true;
|
|
107
|
-
}
|
|
108
91
|
/** Lifecycle replies length-frame GroupInfo too, followed by the authenticated ledger. */ function frameAttestedGroupInfo(attestation, groupInfo, ledger) {
|
|
109
92
|
const token = utf8.encode(attestation);
|
|
110
93
|
if (ledger != null) {
|
|
@@ -149,7 +132,7 @@ function unframeAttestedGroupInfo(bytes, lifecycle) {
|
|
|
149
132
|
* its own handle and request id. Any disagreement is an AEAD failure, not a
|
|
150
133
|
* comparison a caller must remember to make.
|
|
151
134
|
*/ function recoveryAAD(kind, groupID, requesterDID, requestID) {
|
|
152
|
-
return
|
|
135
|
+
return concatBytes([
|
|
153
136
|
kind.aadDomain,
|
|
154
137
|
frameField(groupID),
|
|
155
138
|
frameField(normalizeDID(requesterDID)),
|
|
@@ -361,7 +344,7 @@ const GROUP_INFO_TBS_LABEL = utf8.encode('MLS 1.0 GroupInfoTBS');
|
|
|
361
344
|
*/ function decodeCanonicalGroupInfo(bytes) {
|
|
362
345
|
const message = decode(mlsMessageDecoder, bytes);
|
|
363
346
|
if (message?.wireformat !== wireformats.mls_group_info) throw new Error('Invalid GroupInfo');
|
|
364
|
-
if (!
|
|
347
|
+
if (!equalBytes(encode(mlsMessageEncoder, message), bytes)) throw new Error('GroupInfo is not canonically encoded');
|
|
365
348
|
return message.groupInfo;
|
|
366
349
|
}
|
|
367
350
|
/**
|
|
@@ -372,8 +355,8 @@ const GROUP_INFO_TBS_LABEL = utf8.encode('MLS 1.0 GroupInfoTBS');
|
|
|
372
355
|
const tail = varLen(signature);
|
|
373
356
|
if (groupInfo.length < 4 + tail.length) return false;
|
|
374
357
|
const tbsEnd = groupInfo.length - tail.length;
|
|
375
|
-
if (!
|
|
376
|
-
const content =
|
|
358
|
+
if (!equalBytes(groupInfo.subarray(tbsEnd), tail)) return false;
|
|
359
|
+
const content = concatBytes([
|
|
377
360
|
varLen(GROUP_INFO_TBS_LABEL),
|
|
378
361
|
varLen(groupInfo.subarray(4, tbsEnd))
|
|
379
362
|
]);
|
|
@@ -456,7 +439,7 @@ const GROUP_INFO_TBS_LABEL = utf8.encode('MLS 1.0 GroupInfoTBS');
|
|
|
456
439
|
}
|
|
457
440
|
const ownAnchor = readGroupAnchorExtension(group);
|
|
458
441
|
const ownData = ownAnchor?.extensionData instanceof Uint8Array ? ownAnchor.extensionData : null;
|
|
459
|
-
if (ownData == null || binding.anchorExtensionData == null || !
|
|
442
|
+
if (ownData == null || binding.anchorExtensionData == null || !equalBytes(ownData, binding.anchorExtensionData)) {
|
|
460
443
|
throw new SealedGroupInfoError({
|
|
461
444
|
reason: 'group-mismatch',
|
|
462
445
|
message: 'sealed GroupInfo carries a different genesis anchor than the group being healed'
|
package/lib/sender-data.js
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
|
+
import { concatBytes } from '@sozai/bytes';
|
|
1
2
|
const LABEL_PREFIX = new TextEncoder().encode('MLS 1.0 ');
|
|
2
|
-
function concat(parts) {
|
|
3
|
-
let length = 0;
|
|
4
|
-
for (const part of parts)length += part.length;
|
|
5
|
-
const out = new Uint8Array(length);
|
|
6
|
-
let offset = 0;
|
|
7
|
-
for (const part of parts){
|
|
8
|
-
out.set(part, offset);
|
|
9
|
-
offset += part.length;
|
|
10
|
-
}
|
|
11
|
-
return out;
|
|
12
|
-
}
|
|
13
3
|
function uint16(n) {
|
|
14
4
|
return new Uint8Array([
|
|
15
5
|
n >> 8 & 0xff,
|
|
@@ -47,7 +37,7 @@ function uint64(n) {
|
|
|
47
37
|
} else {
|
|
48
38
|
throw new Error('sender-data: length too large to encode');
|
|
49
39
|
}
|
|
50
|
-
return
|
|
40
|
+
return concatBytes([
|
|
51
41
|
prefix,
|
|
52
42
|
data
|
|
53
43
|
]);
|
|
@@ -57,9 +47,9 @@ function uint64(n) {
|
|
|
57
47
|
* struct `{ uint16 length; opaque label<V> = "MLS 1.0 " + Label; opaque context<V> }`.
|
|
58
48
|
* Shared with the sender ratchet advance in `secret-tree.ts`.
|
|
59
49
|
*/ export function expandWithLabel(context, secret, label, labelContext, length) {
|
|
60
|
-
const kdfLabel =
|
|
50
|
+
const kdfLabel = concatBytes([
|
|
61
51
|
uint16(length),
|
|
62
|
-
varLen(
|
|
52
|
+
varLen(concatBytes([
|
|
63
53
|
LABEL_PREFIX,
|
|
64
54
|
new TextEncoder().encode(label)
|
|
65
55
|
])),
|
|
@@ -81,7 +71,7 @@ function uint64(n) {
|
|
|
81
71
|
const key = await expandWithLabel(context, senderDataSecret, 'key', sampled, hpke.keyLength);
|
|
82
72
|
const nonce = await expandWithLabel(context, senderDataSecret, 'nonce', sampled, hpke.nonceLength);
|
|
83
73
|
// SenderDataAAD = { opaque group_id<V>; uint64 epoch; ContentType content_type (uint8) }.
|
|
84
|
-
const aad =
|
|
74
|
+
const aad = concatBytes([
|
|
85
75
|
varLen(pm.groupId),
|
|
86
76
|
uint64(pm.epoch),
|
|
87
77
|
new Uint8Array([
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kumiai/mls",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.7",
|
|
4
4
|
"description": "E2EE group identity and membership for Enkaku using MLS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mls",
|
|
@@ -25,16 +25,18 @@
|
|
|
25
25
|
"lib/*"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@kokuin/capability": "^0.7.
|
|
29
|
-
"@kokuin/controller": "^0.7.
|
|
28
|
+
"@kokuin/capability": "^0.7.3",
|
|
29
|
+
"@kokuin/controller": "^0.7.3",
|
|
30
30
|
"@kokuin/crypto": "^0.7.1",
|
|
31
|
-
"@kokuin/token": "^0.
|
|
31
|
+
"@kokuin/token": "^0.8.1",
|
|
32
32
|
"@noble/ciphers": "^2.4.0",
|
|
33
33
|
"@noble/curves": "^2.4.0",
|
|
34
34
|
"@noble/hashes": "^2.4.0",
|
|
35
35
|
"@sozai/async": "^0.4.6",
|
|
36
|
-
"@sozai/
|
|
36
|
+
"@sozai/bytes": "^0.1.0",
|
|
37
|
+
"@sozai/codec": "^0.5.0",
|
|
37
38
|
"@sozai/event": "^0.1.7",
|
|
39
|
+
"@sozai/json": "^0.4.0",
|
|
38
40
|
"@sozai/runtime": "^0.1.1",
|
|
39
41
|
"ts-mls": "2.0.0-rc.13"
|
|
40
42
|
},
|