import { type JsonObject } from '../attestation'; import type { WebCryptoKey } from '../webcrypto'; import { type Bytes, type P256PublicJwk } from './primitives'; /** Domain separation for {@link deriveMemberId}. */ export declare const MEMBER_ID_DOMAIN = "byok-member-id-v1\n"; /** `base64url(sha256(MEMBER_ID_DOMAIN || 0x04 || x || y))`: 43 characters, no padding. */ export declare const MEMBER_ID_PATTERN: RegExp; export declare const MEMBER_CHAIN_VERSION = 1; /** Prepended to the canonical entry bytes, so a chain signature never verifies as another signed object. */ export declare const MEMBER_CHAIN_DOMAIN_PREFIX = "byok-member-chain-v1\n"; export declare const MEMBER_CHAIN_OPS: readonly ['add', 'remove', 'rotate', 'scope-policy', 'shred']; export type MemberChainOp = (typeof MEMBER_CHAIN_OPS)[number]; /** One entry before it is signed. `seq` starts at 1; the first entry, and only it, has `prev: null`. */ export interface UnsignedMemberChainEntryV1 { readonly v: typeof MEMBER_CHAIN_VERSION; readonly tenantId: string; readonly seq: number; /** `sha256:` of the previous entry's signing input. */ readonly prev: string | null; readonly op: MemberChainOp; readonly subject: JsonObject; /** Member id of the signer. */ readonly signer: string; } export interface MemberChainEntryV1 extends UnsignedMemberChainEntryV1 { /** ECDSA P-256 / SHA-256 over the signing input, base64url of the 64-byte P1363 form. */ readonly sig: string; } /** The member id of a signing public key. The key must be a point on P-256. */ export declare function deriveMemberId(signingPublicJwk: P256PublicJwk): Promise; /** `MEMBER_CHAIN_DOMAIN_PREFIX || canonicalJson(entry without sig)`. */ export declare function memberChainSigningInput(entry: UnsignedMemberChainEntryV1): Bytes; /** `sha256:` of the signing input. The signature is not hashed, so the hash names the entry's content. */ export declare function memberChainEntryHash(entry: UnsignedMemberChainEntryV1): Promise; /** * Sign one entry. The signer's public key is required so an entry is never * signed under a member id that is not the signer's own. A private key that * does not pair with that public key throws `sealed_secret_invalid`. */ export declare function signMemberChainEntry(entry: UnsignedMemberChainEntryV1, signer: { readonly publicJwk: P256PublicJwk; readonly privateKey: WebCryptoKey; }): Promise; export type MemberChainEntryVerifyResult = { readonly ok: true; readonly entry: MemberChainEntryV1; readonly hash: string; } | { readonly ok: false; readonly reason: 'member_chain_entry_invalid' | 'member_chain_signature_invalid'; }; /** * Verify one received entry against the signing key the verifier already * pins for `entry.signer`. A malformed entry, or a key whose member id is not * the entry's signer, is `member_chain_entry_invalid`; a bad signature is * `member_chain_signature_invalid`. Nothing here throws for hostile input. */ export declare function verifyMemberChainEntry(entry: unknown, signerPublicJwk: P256PublicJwk): Promise;