signify-ts 0.3.0-rc2 → 0.4.0
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/dist/keri/app/aiding.d.ts +20 -4
- package/dist/keri/app/aiding.js +27 -2
- package/dist/keri/app/clienting.d.ts +2 -0
- package/dist/keri/app/clienting.js +1 -1
- package/dist/keri/app/contacting.d.ts +9 -14
- package/dist/keri/app/contacting.js +2 -2
- package/dist/keri/app/controller.js +2 -2
- package/dist/keri/app/coring.d.ts +119 -25
- package/dist/keri/app/coring.js +40 -13
- package/dist/keri/app/credentialing.d.ts +10 -10
- package/dist/keri/app/didwebing.d.ts +146 -0
- package/dist/keri/app/didwebing.js +359 -0
- package/dist/keri/app/escrowing.d.ts +4 -2
- package/dist/keri/app/escrowing.js +1 -1
- package/dist/keri/app/exchanging.d.ts +238 -7
- package/dist/keri/app/exchanging.js +102 -3
- package/dist/keri/app/grouping.d.ts +10 -8
- package/dist/keri/app/grouping.js +4 -4
- package/dist/keri/app/signaling.d.ts +50 -0
- package/dist/keri/app/signaling.js +52 -0
- package/dist/keri/app/w3cing.d.ts +137 -0
- package/dist/keri/app/w3cing.js +337 -0
- package/dist/keri/core/eventing.d.ts +2 -2
- package/dist/keri/core/eventing.js +7 -18
- package/dist/keri/core/keeping.d.ts +111 -8
- package/dist/keri/core/keeping.js +133 -54
- package/dist/keri/core/keyState.d.ts +84 -70
- package/dist/keri/core/keyState.js +1 -1
- package/dist/keri/core/manager.d.ts +1 -1
- package/dist/keri/core/manager.js +3 -3
- package/dist/keri/core/number.d.ts +1 -1
- package/dist/keri/core/number.js +7 -4
- package/dist/keri/core/salter.d.ts +2 -9
- package/dist/keri/core/salter.js +2 -9
- package/dist/types/keria-api-schema.d.ts +889 -35
- package/dist/types/keria-api-schema.js +34 -2
- package/package.json +3 -5
|
@@ -46,7 +46,18 @@ export interface IdentifierManager<T extends IdentifierManagerParams = Identifie
|
|
|
46
46
|
params(): T;
|
|
47
47
|
incept(transferable: boolean): Promise<IdentifierManagerResult>;
|
|
48
48
|
rotate(ncodes: string[], transferable: boolean, states?: KeyState[], rstates?: KeyState[]): Promise<IdentifierManagerResult>;
|
|
49
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Sign serialized bytes.
|
|
51
|
+
*
|
|
52
|
+
* `rotated` is meaningful for group identifiers only. Callers building a
|
|
53
|
+
* group rotation must pass `rotated=true` so the group signature exposes
|
|
54
|
+
* prior-next `ondex`; non-rotation calls leave it false/current-only.
|
|
55
|
+
*
|
|
56
|
+
* `ondices === undefined` uses the default dual-index behavior where each
|
|
57
|
+
* `ondex` matches its `index`. `ondices[j] === undefined` is the explicit
|
|
58
|
+
* current-only case for that signature, so no `ondex` is emitted.
|
|
59
|
+
*/
|
|
60
|
+
sign(ser: Uint8Array, indexed?: boolean, indices?: number[], ondices?: Array<number | undefined>, rotated?: boolean): Promise<SignResult>;
|
|
50
61
|
}
|
|
51
62
|
/**
|
|
52
63
|
* Creates IdentifierManager instances based on the algorithm and key indexes.
|
|
@@ -102,7 +113,7 @@ export declare class SaltyIdentifierManager implements IdentifierManager {
|
|
|
102
113
|
params(): SaltyManagerParams;
|
|
103
114
|
incept(transferable: boolean): Promise<IdentifierManagerResult>;
|
|
104
115
|
rotate(ncodes: string[], transferable: boolean): Promise<[string[], string[]]>;
|
|
105
|
-
sign(ser: Uint8Array, indexed?: boolean, indices?: number[] | undefined, ondices?: number
|
|
116
|
+
sign(ser: Uint8Array, indexed?: boolean, indices?: number[] | undefined, ondices?: Array<number | undefined> | undefined, _rotated?: boolean): Promise<SignResult>;
|
|
106
117
|
}
|
|
107
118
|
export declare class RandyIdentifierManager implements IdentifierManager {
|
|
108
119
|
private salter;
|
|
@@ -126,29 +137,121 @@ export declare class RandyIdentifierManager implements IdentifierManager {
|
|
|
126
137
|
params(): RandyManagerParams;
|
|
127
138
|
incept(transferable: boolean): Promise<IdentifierManagerResult>;
|
|
128
139
|
rotate(ncodes: string[], transferable: boolean): Promise<IdentifierManagerResult>;
|
|
129
|
-
sign(ser: Uint8Array, indexed?: boolean, indices?: number[] | undefined, ondices?: number
|
|
140
|
+
sign(ser: Uint8Array, indexed?: boolean, indices?: number[] | undefined, ondices?: Array<number | undefined> | undefined, _rotated?: boolean): Promise<SignResult>;
|
|
130
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Identifier manager for group identifiers.
|
|
144
|
+
*
|
|
145
|
+
* A group identifier does not have its own private signing keys. Instead, this
|
|
146
|
+
* manager maps group event signing indexes onto the local member AID (`mhab`)
|
|
147
|
+
* and delegates actual signing to that member's key manager.
|
|
148
|
+
*
|
|
149
|
+
* The central invariant is that indexed rotation signatures carry two
|
|
150
|
+
* positions:
|
|
151
|
+
*
|
|
152
|
+
* - `index` points to the signer's current key in the event's current key list
|
|
153
|
+
* (`k`), which SignifyTS derives from `states`.
|
|
154
|
+
* - `ondex` points to the prior establishment event's next digest list (`n`),
|
|
155
|
+
* proving that the current key was a precommitted key.
|
|
156
|
+
*
|
|
157
|
+
* `rstates` are the proposed next digest source for the new event. They are not
|
|
158
|
+
* the signer authorization set for the event being signed.
|
|
159
|
+
*/
|
|
131
160
|
export declare class GroupIdentifierManager implements IdentifierManager {
|
|
161
|
+
/** Factory used to recover the local member keeper that performs signing. */
|
|
132
162
|
private manager;
|
|
163
|
+
/** Local member AID whose private key signs on behalf of the group. */
|
|
133
164
|
private mhab;
|
|
165
|
+
/**
|
|
166
|
+
* Current group signing public keys for the event being built. During
|
|
167
|
+
* rotation these come from `states[*].k[0]` and define signature `index`.
|
|
168
|
+
*/
|
|
134
169
|
private gkeys;
|
|
170
|
+
/**
|
|
171
|
+
* Proposed next digest list for the event being built. During rotation
|
|
172
|
+
* these come from `rstates[*].n[0]`, are returned from `rotate()`, and are
|
|
173
|
+
* serialized as `group.ndigs`.
|
|
174
|
+
*/
|
|
135
175
|
private gdigs;
|
|
176
|
+
/**
|
|
177
|
+
* Prior next digest list from the current group establishment event. For
|
|
178
|
+
* rotations, this is the authorization commitment set used to derive
|
|
179
|
+
* `ondex`; it must remain separate from proposed next digests in `gdigs`.
|
|
180
|
+
*/
|
|
181
|
+
private gpndigs;
|
|
136
182
|
algo: Algos;
|
|
183
|
+
/**
|
|
184
|
+
* Retained for the `IdentifierManager` interface. Group signing delegates
|
|
185
|
+
* to the local member AID keeper instead of storing signers here.
|
|
186
|
+
*/
|
|
137
187
|
signers: Signer[];
|
|
188
|
+
/**
|
|
189
|
+
* Creates a manager for either a new group event or an existing group AID.
|
|
190
|
+
*
|
|
191
|
+
* `states` and `rstates` are app-level key state records used when creating
|
|
192
|
+
* a new group event. `keys` and `ndigs` are persisted group manager params
|
|
193
|
+
* used when loading an existing group. For an existing group, `ndigs` is
|
|
194
|
+
* expected to be the current establishment event's next digest list.
|
|
195
|
+
*
|
|
196
|
+
* During group inception there is no separate prior establishment event, so
|
|
197
|
+
* `gpndigs` starts as the same digest list as `gdigs`. During rotation,
|
|
198
|
+
* `gdigs` changes to the proposed next digests, while `gpndigs` stays
|
|
199
|
+
* fixed for `ondex` derivation.
|
|
200
|
+
*/
|
|
138
201
|
constructor(manager: IdentifierManagerFactory, mhab: HabState, states?: KeyState[] | undefined, rstates?: KeyState[] | undefined, keys?: string[], ndigs?: string[]);
|
|
202
|
+
/**
|
|
203
|
+
* Returns the inception key material for the group event.
|
|
204
|
+
*
|
|
205
|
+
* Inception has no prior group establishment event. The current keys and
|
|
206
|
+
* proposed next digests are therefore returned directly from the manager's
|
|
207
|
+
* configured `states` and `rstates`.
|
|
208
|
+
*/
|
|
139
209
|
incept(): Promise<IdentifierManagerResult>;
|
|
140
210
|
/**
|
|
141
|
-
* Performs a multisig rotation
|
|
211
|
+
* Performs a multisig rotation.
|
|
212
|
+
*
|
|
213
|
+
* `states` supplies the current group signing keys for the event being
|
|
214
|
+
* signed. `rstates` supplies the proposed next key digests to put in the
|
|
215
|
+
* new event. The prior next digests used for rotation `ondex` lookup stay
|
|
216
|
+
* unchanged until KERIA accepts the new establishment event and returns an
|
|
217
|
+
* updated group state.
|
|
218
|
+
*
|
|
142
219
|
* @param _ncodes
|
|
143
220
|
* @param _transferable
|
|
144
221
|
* @param states
|
|
145
|
-
* @param rstates
|
|
146
|
-
* You should pass in the current key
|
|
222
|
+
* @param rstates
|
|
147
223
|
*/
|
|
148
224
|
rotate(_ncodes: string[], _transferable: boolean, states: KeyState[], rstates: KeyState[]): Promise<IdentifierManagerResult>;
|
|
149
|
-
|
|
225
|
+
/**
|
|
226
|
+
* Signs for the group by delegating to the local member keeper.
|
|
227
|
+
*/
|
|
228
|
+
sign(ser: Uint8Array, indexed?: boolean, _indices?: number[] | undefined, _ondices?: Array<number | undefined> | undefined, rotated?: boolean): Promise<SignResult>;
|
|
229
|
+
/**
|
|
230
|
+
* Finds the prior next digest position that precommitted the current key.
|
|
231
|
+
*
|
|
232
|
+
* This mirrors KERIpy's exposed-prior-next behavior: for each prior next
|
|
233
|
+
* digest, hash the current verifier key using that digest's code and compare
|
|
234
|
+
* the result to the digest at that position. A match means the signer has
|
|
235
|
+
* exposed that precommitted key, and the matching position is the `ondex`.
|
|
236
|
+
*/
|
|
237
|
+
private priorNextIndexForKey;
|
|
150
238
|
params(): {
|
|
151
|
-
mhab:
|
|
239
|
+
mhab: {
|
|
240
|
+
name: string;
|
|
241
|
+
prefix: string;
|
|
242
|
+
icp_dt: string;
|
|
243
|
+
state: import("../../types/keria-api-schema.ts").components["schemas"]["KeyStateRecord"];
|
|
244
|
+
transferable: boolean;
|
|
245
|
+
windexes: string[];
|
|
246
|
+
} & ({
|
|
247
|
+
salty: import("../../types/keria-api-schema.ts").components["schemas"]["SaltyState"];
|
|
248
|
+
} | {
|
|
249
|
+
randy: import("../../types/keria-api-schema.ts").components["schemas"]["RandyKeyState"];
|
|
250
|
+
} | {
|
|
251
|
+
group: import("../../types/keria-api-schema.ts").components["schemas"]["GroupKeyState"];
|
|
252
|
+
} | {
|
|
253
|
+
extern: import("../../types/keria-api-schema.ts").components["schemas"]["ExternState"];
|
|
254
|
+
});
|
|
152
255
|
keys: string[];
|
|
153
256
|
ndigs: string[];
|
|
154
257
|
};
|
|
@@ -7,6 +7,7 @@ import { b } from "./core.js";
|
|
|
7
7
|
import { Cipher } from "./cipher.js";
|
|
8
8
|
import { Diger } from "./diger.js";
|
|
9
9
|
import { Prefixer } from "./prefixer.js";
|
|
10
|
+
import { Verfer } from "./verfer.js";
|
|
10
11
|
/**
|
|
11
12
|
* Creates IdentifierManager instances based on the algorithm and key indexes.
|
|
12
13
|
*/
|
|
@@ -57,45 +58,27 @@ export class IdentifierManagerFactory {
|
|
|
57
58
|
* @returns IdentifierManager instance
|
|
58
59
|
*/
|
|
59
60
|
get(aid) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
: aid[Algos.randy]
|
|
63
|
-
? Algos.randy
|
|
64
|
-
: aid[Algos.group]
|
|
65
|
-
? Algos.group
|
|
66
|
-
: aid[Algos.extern]
|
|
67
|
-
? Algos.extern
|
|
68
|
-
: undefined;
|
|
69
|
-
if (!algo) {
|
|
70
|
-
throw new Error('No algo specified');
|
|
61
|
+
if (Algos.salty in aid) {
|
|
62
|
+
return new SaltyIdentifierManager(this.salter, aid.salty.pidx, aid.salty.kidx, aid.salty.tier, aid.salty.transferable, aid.salty.stem, undefined, undefined, aid.salty.icodes, undefined, undefined, aid.salty.ncodes, aid.salty.dcode, undefined, aid.salty.sxlt);
|
|
71
63
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
throw new Error('No kargs found in HabState');
|
|
64
|
+
else if (Algos.randy in aid) {
|
|
65
|
+
return new RandyIdentifierManager(this.salter, undefined, undefined, undefined, new Prefixer({ qb64: aid['prefix'] }).transferable, undefined, undefined, [], undefined, aid.randy.prxs, aid.randy.nxts);
|
|
75
66
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
kargs = kargs;
|
|
85
|
-
return new GroupIdentifierManager(this, kargs.mhab, undefined, undefined, kargs.keys, kargs.ndigs);
|
|
86
|
-
case Algos.extern: {
|
|
87
|
-
kargs = kargs;
|
|
88
|
-
const typ = kargs.extern_type;
|
|
89
|
-
if (typ in this.modules) {
|
|
90
|
-
const mod = new this.modules[typ](kargs.pidx, kargs);
|
|
91
|
-
return mod;
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
throw new Error(`unsupported external module type ${typ}`);
|
|
95
|
-
}
|
|
67
|
+
else if (Algos.group in aid) {
|
|
68
|
+
return new GroupIdentifierManager(this, aid.group.mhab, undefined, undefined, aid.group.keys, aid.group.ndigs);
|
|
69
|
+
}
|
|
70
|
+
else if (Algos.extern in aid) {
|
|
71
|
+
const typ = aid.extern.extern_type;
|
|
72
|
+
if (typ in this.modules) {
|
|
73
|
+
const mod = new this.modules[typ](aid.extern.pidx, aid.extern);
|
|
74
|
+
return mod;
|
|
96
75
|
}
|
|
97
|
-
|
|
98
|
-
throw new Error(
|
|
76
|
+
else {
|
|
77
|
+
throw new Error(`unsupported external module type ${typ}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
throw new Error('No algo specified');
|
|
99
82
|
}
|
|
100
83
|
}
|
|
101
84
|
}
|
|
@@ -173,7 +156,7 @@ export class SaltyIdentifierManager {
|
|
|
173
156
|
const digers = nsigners.signers.map((nsigner) => new Diger({ code: this.dcode }, nsigner.verfer.qb64b).qb64);
|
|
174
157
|
return [verfers, digers];
|
|
175
158
|
}
|
|
176
|
-
async sign(ser, indexed = true, indices = undefined, ondices = undefined) {
|
|
159
|
+
async sign(ser, indexed = true, indices = undefined, ondices = undefined, _rotated) {
|
|
177
160
|
const signers = this.creator.create(this.icodes, this.ncount, this.ncode, this.transferable, this.pidx, 0, this.kidx, false);
|
|
178
161
|
if (indexed) {
|
|
179
162
|
const sigers = [];
|
|
@@ -191,17 +174,14 @@ export class SaltyIdentifierManager {
|
|
|
191
174
|
let o = 0;
|
|
192
175
|
if (ondices != undefined) {
|
|
193
176
|
o = ondices[j];
|
|
194
|
-
if (
|
|
195
|
-
(typeof o == 'number' &&
|
|
196
|
-
typeof o != 'number' &&
|
|
197
|
-
o >= 0))) {
|
|
177
|
+
if (o !== undefined && (!Number.isInteger(o) || o < 0)) {
|
|
198
178
|
throw new Error(`Invalid ondex = ${o}, not whole number.`);
|
|
199
179
|
}
|
|
200
180
|
}
|
|
201
181
|
else {
|
|
202
182
|
o = i;
|
|
203
183
|
}
|
|
204
|
-
sigers.push(signer.sign(ser, i, o
|
|
184
|
+
sigers.push(signer.sign(ser, i, o === undefined ? true : false, o));
|
|
205
185
|
}
|
|
206
186
|
return sigers.map((siger) => siger.qb64);
|
|
207
187
|
}
|
|
@@ -269,7 +249,7 @@ export class RandyIdentifierManager {
|
|
|
269
249
|
const digers = nsigners.signers.map((nsigner) => new Diger({ code: this.dcode }, nsigner.verfer.qb64b).qb64);
|
|
270
250
|
return [verfers, digers];
|
|
271
251
|
}
|
|
272
|
-
async sign(ser, indexed = true, indices = undefined, ondices = undefined) {
|
|
252
|
+
async sign(ser, indexed = true, indices = undefined, ondices = undefined, _rotated) {
|
|
273
253
|
const signers = this.prxs.map((prx) => this.decrypter.decrypt(new Cipher({ qb64: prx }).qb64b, undefined, this.transferable));
|
|
274
254
|
if (indexed) {
|
|
275
255
|
const sigers = [];
|
|
@@ -287,17 +267,14 @@ export class RandyIdentifierManager {
|
|
|
287
267
|
let o = 0;
|
|
288
268
|
if (ondices != undefined) {
|
|
289
269
|
o = ondices[j];
|
|
290
|
-
if (
|
|
291
|
-
(typeof o == 'number' &&
|
|
292
|
-
typeof o != 'number' &&
|
|
293
|
-
o >= 0))) {
|
|
270
|
+
if (o !== undefined && (!Number.isInteger(o) || o < 0)) {
|
|
294
271
|
throw new Error(`Invalid ondex = ${o}, not whole number.`);
|
|
295
272
|
}
|
|
296
273
|
}
|
|
297
274
|
else {
|
|
298
275
|
o = i;
|
|
299
276
|
}
|
|
300
|
-
sigers.push(signer.sign(ser, i, o
|
|
277
|
+
sigers.push(signer.sign(ser, i, o === undefined ? true : false, o));
|
|
301
278
|
}
|
|
302
279
|
return sigers.map((siger) => siger.qb64);
|
|
303
280
|
}
|
|
@@ -310,11 +287,57 @@ export class RandyIdentifierManager {
|
|
|
310
287
|
}
|
|
311
288
|
}
|
|
312
289
|
}
|
|
290
|
+
/**
|
|
291
|
+
* Identifier manager for group identifiers.
|
|
292
|
+
*
|
|
293
|
+
* A group identifier does not have its own private signing keys. Instead, this
|
|
294
|
+
* manager maps group event signing indexes onto the local member AID (`mhab`)
|
|
295
|
+
* and delegates actual signing to that member's key manager.
|
|
296
|
+
*
|
|
297
|
+
* The central invariant is that indexed rotation signatures carry two
|
|
298
|
+
* positions:
|
|
299
|
+
*
|
|
300
|
+
* - `index` points to the signer's current key in the event's current key list
|
|
301
|
+
* (`k`), which SignifyTS derives from `states`.
|
|
302
|
+
* - `ondex` points to the prior establishment event's next digest list (`n`),
|
|
303
|
+
* proving that the current key was a precommitted key.
|
|
304
|
+
*
|
|
305
|
+
* `rstates` are the proposed next digest source for the new event. They are not
|
|
306
|
+
* the signer authorization set for the event being signed.
|
|
307
|
+
*/
|
|
313
308
|
export class GroupIdentifierManager {
|
|
309
|
+
/**
|
|
310
|
+
* Creates a manager for either a new group event or an existing group AID.
|
|
311
|
+
*
|
|
312
|
+
* `states` and `rstates` are app-level key state records used when creating
|
|
313
|
+
* a new group event. `keys` and `ndigs` are persisted group manager params
|
|
314
|
+
* used when loading an existing group. For an existing group, `ndigs` is
|
|
315
|
+
* expected to be the current establishment event's next digest list.
|
|
316
|
+
*
|
|
317
|
+
* During group inception there is no separate prior establishment event, so
|
|
318
|
+
* `gpndigs` starts as the same digest list as `gdigs`. During rotation,
|
|
319
|
+
* `gdigs` changes to the proposed next digests, while `gpndigs` stays
|
|
320
|
+
* fixed for `ondex` derivation.
|
|
321
|
+
*/
|
|
314
322
|
constructor(manager, mhab, states = undefined, rstates = undefined, keys = [], ndigs = []) {
|
|
315
323
|
var _a, _b;
|
|
324
|
+
/**
|
|
325
|
+
* Current group signing public keys for the event being built. During
|
|
326
|
+
* rotation these come from `states[*].k[0]` and define signature `index`.
|
|
327
|
+
*/
|
|
316
328
|
this.gkeys = [];
|
|
329
|
+
/**
|
|
330
|
+
* Proposed next digest list for the event being built. During rotation
|
|
331
|
+
* these come from `rstates[*].n[0]`, are returned from `rotate()`, and are
|
|
332
|
+
* serialized as `group.ndigs`.
|
|
333
|
+
*/
|
|
317
334
|
this.gdigs = [];
|
|
335
|
+
/**
|
|
336
|
+
* Prior next digest list from the current group establishment event. For
|
|
337
|
+
* rotations, this is the authorization commitment set used to derive
|
|
338
|
+
* `ondex`; it must remain separate from proposed next digests in `gdigs`.
|
|
339
|
+
*/
|
|
340
|
+
this.gpndigs = [];
|
|
318
341
|
this.algo = Algos.group;
|
|
319
342
|
this.manager = manager;
|
|
320
343
|
if (states != undefined) {
|
|
@@ -325,36 +348,92 @@ export class GroupIdentifierManager {
|
|
|
325
348
|
}
|
|
326
349
|
this.gkeys = (_a = states === null || states === void 0 ? void 0 : states.map((state) => state['k'][0])) !== null && _a !== void 0 ? _a : keys;
|
|
327
350
|
this.gdigs = (_b = rstates === null || rstates === void 0 ? void 0 : rstates.map((state) => state['n'][0])) !== null && _b !== void 0 ? _b : ndigs;
|
|
351
|
+
this.gpndigs = this.gdigs;
|
|
328
352
|
this.mhab = mhab;
|
|
329
353
|
this.signers = [];
|
|
330
354
|
}
|
|
355
|
+
/**
|
|
356
|
+
* Returns the inception key material for the group event.
|
|
357
|
+
*
|
|
358
|
+
* Inception has no prior group establishment event. The current keys and
|
|
359
|
+
* proposed next digests are therefore returned directly from the manager's
|
|
360
|
+
* configured `states` and `rstates`.
|
|
361
|
+
*/
|
|
331
362
|
async incept() {
|
|
332
363
|
return [this.gkeys, this.gdigs];
|
|
333
364
|
}
|
|
334
365
|
/**
|
|
335
|
-
* Performs a multisig rotation
|
|
366
|
+
* Performs a multisig rotation.
|
|
367
|
+
*
|
|
368
|
+
* `states` supplies the current group signing keys for the event being
|
|
369
|
+
* signed. `rstates` supplies the proposed next key digests to put in the
|
|
370
|
+
* new event. The prior next digests used for rotation `ondex` lookup stay
|
|
371
|
+
* unchanged until KERIA accepts the new establishment event and returns an
|
|
372
|
+
* updated group state.
|
|
373
|
+
*
|
|
336
374
|
* @param _ncodes
|
|
337
375
|
* @param _transferable
|
|
338
376
|
* @param states
|
|
339
|
-
* @param rstates
|
|
340
|
-
* You should pass in the current key
|
|
377
|
+
* @param rstates
|
|
341
378
|
*/
|
|
342
379
|
async rotate(_ncodes, _transferable, states, rstates) {
|
|
343
380
|
this.gkeys = states.map((state) => state['k'][0]);
|
|
344
381
|
this.gdigs = rstates.map((state) => state['n'][0]);
|
|
345
382
|
return [this.gkeys, this.gdigs];
|
|
346
383
|
}
|
|
347
|
-
|
|
384
|
+
/**
|
|
385
|
+
* Signs for the group by delegating to the local member keeper.
|
|
386
|
+
*/
|
|
387
|
+
async sign(ser, indexed = true, _indices = undefined, _ondices = undefined, rotated = false) {
|
|
348
388
|
if (!this.mhab.state) {
|
|
349
389
|
throw new Error(`No state in mhab`);
|
|
350
390
|
}
|
|
351
391
|
const key = this.mhab['state']['k'][0];
|
|
352
|
-
|
|
392
|
+
// The event's current key list authorizes the signature's `index`.
|
|
353
393
|
const csi = this.gkeys.indexOf(key); // csi = current signing index (from current rotation event)
|
|
354
|
-
|
|
394
|
+
if (csi < 0) {
|
|
395
|
+
throw new Error(`Group signing key ${key} is not present in current group signing keys.`);
|
|
396
|
+
}
|
|
397
|
+
let pni; // prior next index exposed as signature `ondex`
|
|
398
|
+
if (rotated) {
|
|
399
|
+
// Rotation call sites must explicitly request prior-next exposure,
|
|
400
|
+
// dual indexed signatures with both an index (csi) and an ondex (pni)
|
|
401
|
+
pni = this.priorNextIndexForKey(key);
|
|
402
|
+
}
|
|
403
|
+
else {
|
|
404
|
+
// Inception and non-rotation signatures satisfy only the current
|
|
405
|
+
// signing threshold. The event's `n` field is a precommitment for a
|
|
406
|
+
// future rotation, not an `ondex` source.
|
|
407
|
+
pni = undefined;
|
|
408
|
+
}
|
|
409
|
+
if (pni !== undefined && pni < 0) {
|
|
410
|
+
throw new Error(`Group signing key ${key} cannot derive ondex from prior next digest list.`);
|
|
411
|
+
}
|
|
412
|
+
// Delegate the actual signature to the local member AID keeper while
|
|
413
|
+
// supplying group-level index and ondex positions.
|
|
355
414
|
const mkeeper = this.manager.get(this.mhab);
|
|
356
415
|
return await mkeeper.sign(ser, indexed, [csi], [pni]);
|
|
357
416
|
}
|
|
417
|
+
/**
|
|
418
|
+
* Finds the prior next digest position that precommitted the current key.
|
|
419
|
+
*
|
|
420
|
+
* This mirrors KERIpy's exposed-prior-next behavior: for each prior next
|
|
421
|
+
* digest, hash the current verifier key using that digest's code and compare
|
|
422
|
+
* the result to the digest at that position. A match means the signer has
|
|
423
|
+
* exposed that precommitted key, and the matching position is the `ondex`.
|
|
424
|
+
*/
|
|
425
|
+
priorNextIndexForKey(key) {
|
|
426
|
+
const verfer = new Verfer({ qb64: key });
|
|
427
|
+
for (const [index, ndig] of this.gpndigs.entries()) {
|
|
428
|
+
const priorDiger = new Diger({ qb64: ndig });
|
|
429
|
+
const keyDigest = new Diger({ code: priorDiger.code }, verfer.qb64b)
|
|
430
|
+
.qb64;
|
|
431
|
+
if (keyDigest === priorDiger.qb64) {
|
|
432
|
+
return index;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
return -1;
|
|
436
|
+
}
|
|
358
437
|
params() {
|
|
359
438
|
return {
|
|
360
439
|
mhab: this.mhab,
|
|
@@ -1,85 +1,99 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
vn: [number, number];
|
|
5
|
-
i: string;
|
|
6
|
-
s: string;
|
|
7
|
-
p?: string;
|
|
8
|
-
d: string;
|
|
9
|
-
f: string;
|
|
10
|
-
dt: string;
|
|
11
|
-
et: string;
|
|
12
|
-
kt: string | string[];
|
|
13
|
-
k: string[];
|
|
14
|
-
nt: string | string[];
|
|
15
|
-
n: string[];
|
|
16
|
-
bt: string;
|
|
17
|
-
b: string[];
|
|
18
|
-
c: string[];
|
|
19
|
-
ee: EstablishmentState;
|
|
20
|
-
di?: string;
|
|
21
|
-
}
|
|
22
|
-
export interface EstablishmentState {
|
|
23
|
-
d: string;
|
|
24
|
-
s: string;
|
|
25
|
-
}
|
|
1
|
+
import { components } from '../../types/keria-api-schema.ts';
|
|
2
|
+
export type KeyState = components['schemas']['KeyStateRecord'];
|
|
3
|
+
export type EstablishmentState = components['schemas']['StateEERecord'];
|
|
26
4
|
/**
|
|
27
5
|
* Marker interface for state configuring an IdentifierManager.
|
|
28
6
|
*/
|
|
29
7
|
export interface IdentifierManagerState {
|
|
30
8
|
}
|
|
31
9
|
/**
|
|
32
|
-
*
|
|
10
|
+
* Defining configuration parameters for a specified, deterministic salt of an IdentifierManager.
|
|
33
11
|
*/
|
|
34
|
-
export
|
|
35
|
-
/**
|
|
36
|
-
* Encrypted
|
|
37
|
-
*/
|
|
38
|
-
sxlt: string;
|
|
39
|
-
pidx: number;
|
|
40
|
-
kidx: number;
|
|
41
|
-
stem: string;
|
|
42
|
-
tier: Tier;
|
|
43
|
-
dcode: string;
|
|
44
|
-
icodes: string[];
|
|
45
|
-
ncodes: string[];
|
|
46
|
-
transferable: boolean;
|
|
47
|
-
}
|
|
12
|
+
export type SaltyKeyState = components['schemas']['SaltyState'];
|
|
48
13
|
/**
|
|
49
|
-
*
|
|
14
|
+
* Defining configuration parameters for a random seed identifier manager.
|
|
50
15
|
*/
|
|
51
|
-
export
|
|
52
|
-
prxs: string[];
|
|
53
|
-
nxts: string[];
|
|
54
|
-
}
|
|
16
|
+
export type RandyKeyState = components['schemas']['RandyKeyState'];
|
|
55
17
|
/**
|
|
56
|
-
*
|
|
18
|
+
* Defining properties a multi-signature group identifier manager.
|
|
57
19
|
*/
|
|
58
|
-
export
|
|
59
|
-
mhab: HabState;
|
|
60
|
-
keys: string[];
|
|
61
|
-
ndigs: string[];
|
|
62
|
-
}
|
|
20
|
+
export type GroupKeyState = components['schemas']['GroupKeyState'];
|
|
63
21
|
/**
|
|
64
|
-
*
|
|
22
|
+
* Defining properties for an external module identifier manager that uses externally managed keys such as in an HSM or a KMS system.
|
|
65
23
|
*/
|
|
66
|
-
export
|
|
67
|
-
extern_type: string;
|
|
68
|
-
pidx: number;
|
|
69
|
-
[key: string]: unknown;
|
|
70
|
-
}
|
|
24
|
+
export type ExternState = components['schemas']['ExternState'];
|
|
71
25
|
/**
|
|
72
|
-
*
|
|
26
|
+
* Defining properties of an identifier habitat, know as a Hab in KERIpy.
|
|
73
27
|
*/
|
|
74
|
-
export
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
28
|
+
export type HabState = components['schemas']['HabState'];
|
|
29
|
+
export type Icp = components['schemas']['ICP_V_1'] | components['schemas']['ICP_V_2'];
|
|
30
|
+
export type Ixn = components['schemas']['IXN_V_1'] | components['schemas']['IXN_V_2'];
|
|
31
|
+
export type ExnV1 = components['schemas']['EXN_V_1'];
|
|
32
|
+
export type Dip = components['schemas']['DIP_V_1'] | components['schemas']['DIP_V_2'];
|
|
33
|
+
export type Rot = components['schemas']['ROT_V_1'] | components['schemas']['ROT_V_2'];
|
|
34
|
+
export type ExnEmbeds = components['schemas']['ExnEmbeds'];
|
|
35
|
+
export type MultisigRpyEmbeds = components['schemas']['MultisigRpyEmbeds'];
|
|
36
|
+
/**
|
|
37
|
+
* Defining Operation types
|
|
38
|
+
*/
|
|
39
|
+
export type OOBIOperation = components['schemas']['OOBIOperation'];
|
|
40
|
+
export type QueryOperation = components['schemas']['QueryOperation'];
|
|
41
|
+
export type EndRoleOperation = components['schemas']['EndRoleOperation'];
|
|
42
|
+
export type WitnessOperation = components['schemas']['WitnessOperation'];
|
|
43
|
+
export type DelegationOperation = components['schemas']['DelegationOperation'];
|
|
44
|
+
export type RegistryOperation = components['schemas']['RegistryOperation'];
|
|
45
|
+
export type LocSchemeOperation = components['schemas']['LocSchemeOperation'];
|
|
46
|
+
export type ChallengeOperation = components['schemas']['ChallengeOperation'];
|
|
47
|
+
export type ExchangeOperation = components['schemas']['ExchangeOperation'];
|
|
48
|
+
export type SubmitOperation = components['schemas']['SubmitOperation'];
|
|
49
|
+
export type DoneOperation = components['schemas']['DoneOperation'];
|
|
50
|
+
export type CredentialOperation = components['schemas']['CredentialOperation'];
|
|
51
|
+
export type GroupOperation = components['schemas']['GroupOperation'];
|
|
52
|
+
export type DelegatorOperation = components['schemas']['DelegatorOperation'];
|
|
53
|
+
export type PendingOOBIOperation = components['schemas']['PendingOOBIOperation'];
|
|
54
|
+
export type PendingQueryOperation = components['schemas']['PendingQueryOperation'];
|
|
55
|
+
export type PendingEndRoleOperation = components['schemas']['PendingEndRoleOperation'];
|
|
56
|
+
export type PendingWitnessOperation = components['schemas']['PendingWitnessOperation'];
|
|
57
|
+
export type PendingDelegationOperation = components['schemas']['PendingDelegationOperation'];
|
|
58
|
+
export type PendingRegistryOperation = components['schemas']['PendingRegistryOperation'];
|
|
59
|
+
export type PendingLocSchemeOperation = components['schemas']['PendingLocSchemeOperation'];
|
|
60
|
+
export type PendingChallengeOperation = components['schemas']['PendingChallengeOperation'];
|
|
61
|
+
export type PendingExchangeOperation = components['schemas']['PendingExchangeOperation'];
|
|
62
|
+
export type PendingSubmitOperation = components['schemas']['PendingSubmitOperation'];
|
|
63
|
+
export type PendingDoneOperation = components['schemas']['PendingDoneOperation'];
|
|
64
|
+
export type PendingCredentialOperation = components['schemas']['PendingCredentialOperation'];
|
|
65
|
+
export type PendingGroupOperation = components['schemas']['PendingGroupOperation'];
|
|
66
|
+
export type PendingDelegatorOperation = components['schemas']['PendingDelegatorOperation'];
|
|
67
|
+
export type PendingOperation = PendingOOBIOperation | PendingQueryOperation | PendingEndRoleOperation | PendingWitnessOperation | PendingDelegationOperation | PendingRegistryOperation | PendingLocSchemeOperation | PendingChallengeOperation | PendingExchangeOperation | PendingSubmitOperation | PendingDoneOperation | PendingCredentialOperation | PendingGroupOperation | PendingDelegatorOperation;
|
|
68
|
+
export type CompletedWitnessOperation = components['schemas']['CompletedWitnessOperation'];
|
|
69
|
+
export type CompletedEndRoleOperation = components['schemas']['CompletedEndRoleOperation'];
|
|
70
|
+
export type CompletedOOBIOperation = components['schemas']['CompletedOOBIOperation'];
|
|
71
|
+
export type CompletedDelegationOperation = components['schemas']['CompletedDelegationOperation'];
|
|
72
|
+
export type CompletedRegistryOperation = components['schemas']['CompletedRegistryOperation'];
|
|
73
|
+
export type CompletedLocSchemeOperation = components['schemas']['CompletedLocSchemeOperation'];
|
|
74
|
+
export type CompletedChallengeOperation = components['schemas']['CompletedChallengeOperation'];
|
|
75
|
+
export type CompletedExchangeOperation = components['schemas']['CompletedExchangeOperation'];
|
|
76
|
+
export type CompletedSubmitOperation = components['schemas']['CompletedSubmitOperation'];
|
|
77
|
+
export type CompletedDoneOperation = components['schemas']['CompletedDoneOperation'];
|
|
78
|
+
export type CompletedCredentialOperation = components['schemas']['CompletedCredentialOperation'];
|
|
79
|
+
export type CompletedGroupOperation = components['schemas']['CompletedGroupOperation'];
|
|
80
|
+
export type CompletedDelegatorOperation = components['schemas']['CompletedDelegatorOperation'];
|
|
81
|
+
export type CompletedQueryOperation = components['schemas']['CompletedQueryOperation'];
|
|
82
|
+
export type CompletedOperation = CompletedOOBIOperation | CompletedEndRoleOperation | CompletedWitnessOperation | CompletedDelegationOperation | CompletedRegistryOperation | CompletedLocSchemeOperation | CompletedChallengeOperation | CompletedExchangeOperation | CompletedSubmitOperation | CompletedDoneOperation | CompletedCredentialOperation | CompletedGroupOperation | CompletedDelegatorOperation | CompletedQueryOperation;
|
|
83
|
+
export type FailedOOBIOperation = components['schemas']['FailedOOBIOperation'];
|
|
84
|
+
export type FailedQueryOperation = components['schemas']['FailedQueryOperation'];
|
|
85
|
+
export type FailedEndRoleOperation = components['schemas']['FailedEndRoleOperation'];
|
|
86
|
+
export type FailedWitnessOperation = components['schemas']['FailedWitnessOperation'];
|
|
87
|
+
export type FailedDelegationOperation = components['schemas']['FailedDelegationOperation'];
|
|
88
|
+
export type FailedRegistryOperation = components['schemas']['FailedRegistryOperation'];
|
|
89
|
+
export type FailedLocSchemeOperation = components['schemas']['FailedLocSchemeOperation'];
|
|
90
|
+
export type FailedChallengeOperation = components['schemas']['FailedChallengeOperation'];
|
|
91
|
+
export type FailedExchangeOperation = components['schemas']['FailedExchangeOperation'];
|
|
92
|
+
export type FailedSubmitOperation = components['schemas']['FailedSubmitOperation'];
|
|
93
|
+
export type FailedDoneOperation = components['schemas']['FailedDoneOperation'];
|
|
94
|
+
export type FailedCredentialOperation = components['schemas']['FailedCredentialOperation'];
|
|
95
|
+
export type FailedGroupOperation = components['schemas']['FailedGroupOperation'];
|
|
96
|
+
export type FailedDelegatorOperation = components['schemas']['FailedDelegatorOperation'];
|
|
97
|
+
export type FailedOperation = FailedOOBIOperation | FailedQueryOperation | FailedEndRoleOperation | FailedWitnessOperation | FailedDelegationOperation | FailedRegistryOperation | FailedLocSchemeOperation | FailedChallengeOperation | FailedExchangeOperation | FailedSubmitOperation | FailedDoneOperation | FailedCredentialOperation | FailedGroupOperation | FailedDelegatorOperation;
|
|
98
|
+
export type GenericOperation = OOBIOperation | QueryOperation | EndRoleOperation | WitnessOperation | DelegationOperation | RegistryOperation | LocSchemeOperation | ChallengeOperation | ExchangeOperation | SubmitOperation | DoneOperation | CredentialOperation | GroupOperation | DelegatorOperation;
|
|
99
|
+
export type EndRole = components['schemas']['EndRole'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
@@ -242,7 +242,7 @@ interface SignArgs {
|
|
|
242
242
|
verfers?: Array<Verfer> | undefined;
|
|
243
243
|
indexed?: boolean;
|
|
244
244
|
indices?: Array<number> | undefined;
|
|
245
|
-
ondices?: Array<number> | undefined;
|
|
245
|
+
ondices?: Array<number | undefined> | undefined;
|
|
246
246
|
}
|
|
247
247
|
/**
|
|
248
248
|
* Manages key pair creation, retrieval, and message signing.
|
|
@@ -722,14 +722,14 @@ export class Manager {
|
|
|
722
722
|
let o;
|
|
723
723
|
if (ondices != undefined) {
|
|
724
724
|
o = ondices[idx];
|
|
725
|
-
if (o
|
|
726
|
-
throw new Error(`Invalid other signing index = {o}, not None or not whole number.`);
|
|
725
|
+
if (o !== undefined && (!Number.isInteger(o) || o < 0)) {
|
|
726
|
+
throw new Error(`Invalid other signing index = ${o}, not None or not whole number.`);
|
|
727
727
|
}
|
|
728
728
|
}
|
|
729
729
|
else {
|
|
730
730
|
o = i;
|
|
731
731
|
}
|
|
732
|
-
const only = o
|
|
732
|
+
const only = o === undefined;
|
|
733
733
|
sigers.push(signer.sign(ser, i, only, o));
|
|
734
734
|
});
|
|
735
735
|
return sigers;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Matter, MatterArgs } from './matter.ts';
|
|
2
2
|
export declare class CesrNumber extends Matter {
|
|
3
|
-
constructor({ raw, code, qb64b, qb64, qb2 }: MatterArgs, num?: number | string
|
|
3
|
+
constructor({ raw, code, qb64b, qb64, qb2 }: MatterArgs, num?: number | string);
|
|
4
4
|
get num(): number;
|
|
5
5
|
get numh(): string;
|
|
6
6
|
get positive(): boolean;
|