import { Salter } from './salter.ts'; import { Algos } from './manager.ts'; import { Tier } from './salter.ts'; import { Signer } from './signer.ts'; import { HabState, KeyState } from './keyState.ts'; /** External module definition */ export interface ExternalModuleType { new (pidx: number, args: IdentifierManagerParams): IdentifierManager; } export interface ExternalModule { type: string; name: string; module: ExternalModuleType; } export type IdentifierManagerResult = [string[], string[]]; export type SignResult = string[]; export interface IdentifierManagerParams { [key: string]: unknown; } export interface SaltyManagerParams extends IdentifierManagerParams { pidx: number; kidx: number; tier: Tier; transferable: boolean; stem: string | undefined; icodes: string[] | undefined; ncodes: string[] | undefined; dcode: string | undefined; sxlt: string | undefined; } export interface RandyManagerParams extends IdentifierManagerParams { nxts?: string[]; prxs?: string[]; transferable: boolean; } export interface GroupManagerParams extends IdentifierManagerParams { mhab: HabState; } /** * Interface for KERI identifier (prefix) creation, rotation, and signing. * @param T Type of the key keeper */ export interface IdentifierManager { algo: Algos; signers: Signer[]; params(): T; incept(transferable: boolean): Promise; rotate(ncodes: string[], transferable: boolean, states?: KeyState[], rstates?: KeyState[]): Promise; /** * Sign serialized bytes. * * `rotated` is meaningful for group identifiers only. Callers building a * group rotation must pass `rotated=true` so the group signature exposes * prior-next `ondex`; non-rotation calls leave it false/current-only. * * `ondices === undefined` uses the default dual-index behavior where each * `ondex` matches its `index`. `ondices[j] === undefined` is the explicit * current-only case for that signature, so no `ondex` is emitted. */ sign(ser: Uint8Array, indexed?: boolean, indices?: number[], ondices?: Ondex[], rotated?: boolean): Promise; } /** * Creates IdentifierManager instances based on the algorithm and key indexes. */ export declare class IdentifierManagerFactory { private salter; private modules; /** * Creates a factory for generating IdentifierManagers. Requires a salt to be specified. * Allows external key management modules to be configured. * @param salter * @param externalModules */ constructor(salter: Salter, externalModules?: ExternalModule[]); /** * * @param algo * @param pidx * @param kargs */ new(algo: Algos, pidx: number, kargs: any): IdentifierManager | GroupIdentifierManager; /** * Generates an algorithm-specific IdentifierManager instance with correct keys based on * the indexes provided by the HabState. * @param aid HabState with the algorithm and key indexes * @returns IdentifierManager instance */ get(aid: HabState): IdentifierManager; } export declare class SaltyIdentifierManager implements IdentifierManager { private aeid; private encrypter; private decrypter; private salter; private pidx; private kidx; private tier; private transferable; private stem; private code; private count; private icodes; private ncode; private ncount; private ncodes; private dcode; private sxlt; private bran; private creator; algo: Algos; signers: Signer[]; constructor(salter: Salter, pidx: number, kidx?: number, tier?: Tier, transferable?: boolean, stem?: string | undefined, code?: string, count?: number, icodes?: string[] | undefined, ncode?: string, ncount?: number, ncodes?: string[] | undefined, dcode?: string, bran?: string | undefined, sxlt?: string | undefined); params(): SaltyManagerParams; incept(transferable: boolean): Promise; rotate(ncodes: string[], transferable: boolean): Promise<[string[], string[]]>; sign(ser: Uint8Array, indexed?: boolean, indices?: number[] | undefined, ondices?: Ondex[] | undefined, _rotated?: boolean): Promise; } export declare class RandyIdentifierManager implements IdentifierManager { private salter; private code; private count; private icodes; private transferable; private ncount; private ncodes; private ncode; private dcode; private prxs; private nxts; private aeid; private encrypter; private decrypter; private creator; algo: Algos; signers: Signer[]; constructor(salter: Salter, code: string | undefined, count: number | undefined, icodes: string[] | undefined, transferable: boolean | undefined, ncode: string | undefined, ncount: number | undefined, ncodes: string[], dcode?: string, prxs?: string[] | undefined, nxts?: string[] | undefined); params(): RandyManagerParams; incept(transferable: boolean): Promise; rotate(ncodes: string[], transferable: boolean): Promise; sign(ser: Uint8Array, indexed?: boolean, indices?: number[] | undefined, ondices?: Ondex[] | undefined, _rotated?: boolean): Promise; } type Ondex = number | undefined; /** * Identifier manager for group identifiers. * * A group identifier does not have its own private signing keys. Instead, this * manager maps group event signing indexes onto the local member AID (`mhab`) * and delegates actual signing to that member's key manager. * * The central invariant is that indexed rotation signatures carry two * positions: * * - `index` points to the signer's current key in the event's current key list * (`k`), which SignifyTS derives from `states`. * - `ondex` points to the prior establishment event's next digest list (`n`), * proving that the current key was a precommitted key. * * `rstates` are the proposed next digest source for the new event. They are not * the signer authorization set for the event being signed. */ export declare class GroupIdentifierManager implements IdentifierManager { /** Factory used to recover the local member keeper that performs signing. */ private manager; /** Local member AID whose private key signs on behalf of the group. */ private mhab; /** * Current group signing public keys for the event being built. During * rotation these come from `states[*].k[0]` and define signature `index`. */ private gkeys; /** * Proposed next digest list for the event being built. During rotation * these come from `rstates[*].n[0]`, are returned from `rotate()`, and are * serialized as `group.ndigs`. */ private gdigs; /** * Prior next digest list from the current group establishment event. For * rotations, this is the authorization commitment set used to derive * `ondex`; it must remain separate from proposed next digests in `gdigs`. */ private gpndigs; algo: Algos; /** * Retained for the `IdentifierManager` interface. Group signing delegates * to the local member AID keeper instead of storing signers here. */ signers: Signer[]; /** * Creates a manager for either a new group event or an existing group AID. * * `states` and `rstates` are app-level key state records used when creating * a new group event. `keys` and `ndigs` are persisted group manager params * used when loading an existing group. For an existing group, `ndigs` is * expected to be the current establishment event's next digest list. * * During group inception there is no separate prior establishment event, so * `gpndigs` starts as the same digest list as `gdigs`. During rotation, * `gdigs` changes to the proposed next digests, while `gpndigs` stays * fixed for `ondex` derivation. */ constructor(manager: IdentifierManagerFactory, mhab: HabState, states?: KeyState[] | undefined, rstates?: KeyState[] | undefined, keys?: string[], ndigs?: string[]); /** * Returns the inception key material for the group event. * * Inception has no prior group establishment event. The current keys and * proposed next digests are therefore returned directly from the manager's * configured `states` and `rstates`. */ incept(): Promise; /** * Performs a multisig rotation. * * `states` supplies the current group signing keys for the event being * signed. `rstates` supplies the proposed next key digests to put in the * new event. The prior next digests used for rotation `ondex` lookup stay * unchanged until KERIA accepts the new establishment event and returns an * updated group state. * * @param _ncodes * @param _transferable * @param states * @param rstates */ rotate(_ncodes: string[], _transferable: boolean, states: KeyState[], rstates: KeyState[]): Promise; /** * Signs for the group by delegating to the local member keeper. */ sign(ser: Uint8Array, indexed?: boolean, _indices?: number[] | undefined, _ondices?: Ondex[] | undefined, rotated?: boolean): Promise; /** * Finds the prior next digest position that precommitted the current key. * * This mirrors KERIpy's exposed-prior-next behavior: for each prior next * digest, hash the current verifier key using that digest's code and compare * the result to the digest at that position. A match means the signer has * exposed that precommitted key, and the matching position is the `ondex`. */ private priorNextIndexForKey; params(): { mhab: HabState; keys: string[]; ndigs: string[]; }; } export {};