@kumiai/mls 0.12.0 → 0.12.1
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/README.md +2 -1
- package/lib/controller-log.d.ts +2 -0
- package/lib/controller-log.js +12 -0
- package/lib/member-root.js +14 -3
- package/lib/registry.js +5 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -89,7 +89,8 @@ Member roots are supported only in lifecycle groups. Admission refuses removed o
|
|
|
89
89
|
The reset form is `{ reset: true, log }`. Proofs carry `ControllerLog` and exact `EffectClaim` references.
|
|
90
90
|
References identify a chain index, epoch event or reset snapshot.
|
|
91
91
|
Removing an incarnation cascades through its rooted leaves. Valid holder or survivor grants can preserve them until their substitute expiry.
|
|
92
|
-
`
|
|
92
|
+
A settlement that keeps the removed incarnation as a tombstone (`snapshotOf`'s default) proves the removal itself, for receivers on 0.12.1 or later.
|
|
93
|
+
`removalEvidence` captures the removal's epoch proof before settlement. A host needs it when the settlement drops that tombstone, or while any group member runs 0.12.0.
|
|
93
94
|
|
|
94
95
|
Tree time combines a preserved floor, root-issued token times and effective-member attestations over distinct pinned keys.
|
|
95
96
|
The quorum uses the second-highest attestation, or the highest for one effective key.
|
package/lib/controller-log.d.ts
CHANGED
|
@@ -6,5 +6,7 @@ export declare function foldChain(did: string, chain: ReadonlyArray<SignedEvent>
|
|
|
6
6
|
export declare function foldControllerLog(did: string, log: ControllerLog): FoldResult;
|
|
7
7
|
export declare function revokeIndices(did: string, chain: ReadonlyArray<SignedEvent>, subject: string): Array<number>;
|
|
8
8
|
export declare function memberDropIndices(did: string, chain: ReadonlyArray<SignedEvent>, add: string): Array<number>;
|
|
9
|
+
/** Same-generation `rot` indices whose snapshot newly carries `add` as `member`'s removed incarnation. */
|
|
10
|
+
export declare function memberTombstoneIndices(did: string, chain: ReadonlyArray<SignedEvent>, add: string, member: string): Array<number>;
|
|
9
11
|
export declare function closureOf(did: string, log: ControllerLog, targets: ReadonlyArray<string>): ControllerLog | undefined;
|
|
10
12
|
export declare function isDetachedFoldReason(reason: string): boolean;
|
package/lib/controller-log.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { deviceRevokeIndices, digestOf, foldLog, pruneLog } from '@kokuin/controller';
|
|
2
|
+
import { normalizeDID } from '@kokuin/token';
|
|
2
3
|
export const CHAIN_REVOKE_REFUSED = 'chain revoke refused';
|
|
3
4
|
export function asControllerLog(chain) {
|
|
4
5
|
return {
|
|
@@ -48,6 +49,17 @@ export function memberDropIndices(did, chain, add) {
|
|
|
48
49
|
}
|
|
49
50
|
return indices;
|
|
50
51
|
}
|
|
52
|
+
/** Same-generation `rot` indices whose snapshot newly carries `add` as `member`'s removed incarnation. */ export function memberTombstoneIndices(did, chain, add, member) {
|
|
53
|
+
const folded = foldChain(did, chain);
|
|
54
|
+
if (!folded.ok) return [];
|
|
55
|
+
const indices = [];
|
|
56
|
+
for(let index = 1; index < chain.length; index++){
|
|
57
|
+
const state = folded.states[index];
|
|
58
|
+
const prior = folded.states[index - 1];
|
|
59
|
+
if (chain[index]?.event.t === 'rot' && state != null && prior != null && state.gen === prior.gen && prior.tombstones?.has(add) !== true && normalizeDID(state.tombstones?.get(add)?.did ?? '') === normalizeDID(member)) indices.push(index);
|
|
60
|
+
}
|
|
61
|
+
return indices;
|
|
62
|
+
}
|
|
51
63
|
export function closureOf(did, log, targets) {
|
|
52
64
|
const folded = foldControllerLog(did, log);
|
|
53
65
|
if (!folded.ok || folded.head.saturated) return undefined;
|
package/lib/member-root.js
CHANGED
|
@@ -78,6 +78,8 @@ function effectProofs(did, log) {
|
|
|
78
78
|
]
|
|
79
79
|
]);
|
|
80
80
|
const drops = new Map();
|
|
81
|
+
// A settle that carries a removal in snapshot `u` proves it even when no chain state held it live.
|
|
82
|
+
const tombstones = new Map();
|
|
81
83
|
const revokes = new Map();
|
|
82
84
|
const snapshots = new Map();
|
|
83
85
|
const denials = folded.states.map((state)=>new Set([
|
|
@@ -101,6 +103,9 @@ function effectProofs(did, log) {
|
|
|
101
103
|
for (const [add, member] of prior.members){
|
|
102
104
|
if (!member.removed && !state.members.has(add)) append(drops, add, index);
|
|
103
105
|
}
|
|
106
|
+
for (const add of state.tombstones?.keys() ?? []){
|
|
107
|
+
if (!prior.tombstones?.has(add)) append(tombstones, add, index);
|
|
108
|
+
}
|
|
104
109
|
}
|
|
105
110
|
const viewAt = (epoch)=>{
|
|
106
111
|
if (epoch == null) return views.get(folded.head.epoch);
|
|
@@ -123,6 +128,7 @@ function effectProofs(did, log) {
|
|
|
123
128
|
folded,
|
|
124
129
|
events,
|
|
125
130
|
drops,
|
|
131
|
+
tombstones,
|
|
126
132
|
revokes,
|
|
127
133
|
snapshots,
|
|
128
134
|
viewAt
|
|
@@ -160,7 +166,11 @@ function checkEffect(log, claim, genFloor, proofs) {
|
|
|
160
166
|
} else {
|
|
161
167
|
const member = prior.members.get(claim.member.add);
|
|
162
168
|
if (member != null && normalizeDID(member.did) !== normalizeDID(claim.member.did)) throw new RevokeProofError('effects-mismatch');
|
|
163
|
-
if (!proofs.drops.get(claim.member.add)?.includes(index))
|
|
169
|
+
if (!proofs.drops.get(claim.member.add)?.includes(index)) {
|
|
170
|
+
const tombstone = state.tombstones?.get(claim.member.add);
|
|
171
|
+
if (tombstone == null || !proofs.tombstones.get(claim.member.add)?.includes(index)) throw new RevokeProofError('no-rev');
|
|
172
|
+
if (normalizeDID(tombstone.did) !== normalizeDID(claim.member.did)) throw new RevokeProofError('effects-mismatch');
|
|
173
|
+
}
|
|
164
174
|
}
|
|
165
175
|
if (state.gen < genFloor) throw new RevokeProofError('generation-floor');
|
|
166
176
|
}
|
|
@@ -265,8 +275,9 @@ function claimsWithProofs(did, recorded, merged, genFloor, proofs) {
|
|
|
265
275
|
event.claim
|
|
266
276
|
];
|
|
267
277
|
}
|
|
268
|
-
const
|
|
269
|
-
|
|
278
|
+
const atFloor = (index)=>(after.states[index]?.gen ?? -1) >= floor;
|
|
279
|
+
// Drops before tombstones: a 0.12.0 receiver accepts only the drop.
|
|
280
|
+
const index = claim.kind === 'deny' ? proofs.revokes.get(claim.did)?.find(atFloor) : proofs.drops.get(claim.member.add)?.find(atFloor) ?? proofs.tombstones.get(claim.member.add)?.find(atFloor);
|
|
270
281
|
let ref = index == null ? undefined : {
|
|
271
282
|
chainIndex: index
|
|
272
283
|
};
|
package/lib/registry.js
CHANGED
|
@@ -2,7 +2,7 @@ import { digestOf, isControllerLog, resolveBranches } from '@kokuin/controller';
|
|
|
2
2
|
import { normalizeDID } from '@kokuin/token';
|
|
3
3
|
import { readCapability } from './capability.js';
|
|
4
4
|
import { ingestControllerLog } from './controller-ingest.js';
|
|
5
|
-
import { foldChain, foldControllerLog, memberDropIndices, revokeIndices } from './controller-log.js';
|
|
5
|
+
import { foldChain, foldControllerLog, memberDropIndices, memberTombstoneIndices, revokeIndices } from './controller-log.js';
|
|
6
6
|
import { RecoveryKnowledgeError, RevokeProofError } from './errors.js';
|
|
7
7
|
import { authenticateLifecycleProof } from './lifecycle-proof.js';
|
|
8
8
|
import { claimsFor } from './member-root.js';
|
|
@@ -85,9 +85,10 @@ export function isLifecycleDeviceValue(value) {
|
|
|
85
85
|
if (value.op === 'clock') {
|
|
86
86
|
if (value.attest === true) {
|
|
87
87
|
const folded = previous.recordedLog == null ? undefined : foldControllerLog(controller, previous.recordedLog);
|
|
88
|
+
// Only an effective incarnation attests; the head also holds removed and denied ones.
|
|
88
89
|
const member = folded?.ok ? [
|
|
89
90
|
...folded.head.members.values()
|
|
90
|
-
].find((member)=>normalizeDID(member.did) === normalizeDID(verified.issuer)) : undefined;
|
|
91
|
+
].find((member)=>member.effective && normalizeDID(member.did) === normalizeDID(verified.issuer)) : undefined;
|
|
91
92
|
if (member == null) throw new RevokeProofError('effects-mismatch');
|
|
92
93
|
const attestations = new Map(previous.attestations);
|
|
93
94
|
attestations.set(member.key, Math.max(attestations.get(member.key) ?? 0, value.time));
|
|
@@ -155,7 +156,8 @@ export function isLifecycleDeviceValue(value) {
|
|
|
155
156
|
}
|
|
156
157
|
for (const [add, member] of removedMembers){
|
|
157
158
|
if (!('event' in member.proofRef)) continue;
|
|
158
|
-
const
|
|
159
|
+
const chain = effect.recordedLog.chain;
|
|
160
|
+
const index = memberDropIndices(controller, chain, add).at(-1) ?? memberTombstoneIndices(controller, chain, add, member.did).at(-1);
|
|
159
161
|
if (index != null) removedMembers.set(add, {
|
|
160
162
|
...member,
|
|
161
163
|
proofRef: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kumiai/mls",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "E2EE group identity and membership for Enkaku using MLS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mls",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@kokuin/capability": "^0.5.2",
|
|
29
|
-
"@kokuin/controller": "^0.2.
|
|
29
|
+
"@kokuin/controller": "^0.2.5",
|
|
30
30
|
"@kokuin/token": "^0.6.2",
|
|
31
31
|
"@noble/ciphers": "^2.4.0",
|
|
32
32
|
"@noble/curves": "^2.4.0",
|