import { … } from '@sloppyvoice/sdk/crypto'

Classes

IdentityCheckError class

A failed identity check (07 §10.6). code is sdk.verification_failed; reason (also in data.reason) is the identity check result the spec names for the failing step, and data.object says which object failed (identityCertificate, deviceCertificate, identityState, revocation, credential).

class IdentityCheckError extends SloppyVoiceError

constructor

new IdentityCheckError(reason: IdentityCheckResult, detail: string, data?: Record<string, unknown>, cause?: unknown)
detail: string
data: Record<string, unknown>

Default: {}

cause?: unknown

reason

readonly reason: IdentityCheckResult

The identity check result (07 §10.6).

Inherited: code, status, title, detail, retryable, retryAfterMs, userAction, data, instance, problem

Source: crypto/identity.ts:56

MemoryPinStore class

An in-memory PinStore.

class MemoryPinStore implements PinStore

constructor

new MemoryPinStore()

get

get(addr: string): PinRecord | undefined

The record for addr (a copy), or undefined.

addr: string

set

set(pin: PinRecord): void

Store a record under its addr.

Source: crypto/identity.ts:1232

MemoryVerifierStore class

An in-memory VerifierStore.

class MemoryVerifierStore implements VerifierStore

constructor

new MemoryVerifierStore()

get

get(sub: string): VerifierStoreEntry | undefined

The entry for sub (a copy), or undefined.

sub: string

set

set(entry: VerifierStoreEntry): void

Replace the entry for entry.sub.

delete

delete(sub: string): void

Remove the entry for sub.

sub: string

subjects

subjects(): string[]

Every subject with an entry.

Source: crypto/identity.ts:510

Svf1Decryptor class

Random-access SVF1 decryption of one blob (04 §10.6): checks the format and the key commitment once, then decrypts any segment on its own, for example one fetched with an HTTP range request.

class Svf1Decryptor

blobBytes

readonly blobBytes: number

Total blob length B.

segments

readonly segments: number

Number of segments n.

padded

readonly padded: number

Padded framed length P.

create

static create(fileKey: Uint8Array, header: Uint8Array, blobBytes: number): Promise<Svf1Decryptor>

Check steps 1 to 3 of 04 §10.6 (length and magic: format; commitment, in constant time and before anything is decrypted: commitment) and prepare to decrypt. header is the blob's first 43 bytes; blobBytes its total length (from Content-Length or the Attachment's blobBytes).

fileKey: Uint8Array
header: Uint8Array
blobBytes: number

segmentRange

segmentRange(i: number): { start: number; end: number }

Byte range [start, end) of segment i's ciphertext in the blob (04 §10.4).

i: number

decryptSegment

decryptSegment(i: number, ciphertext: Uint8Array): Promise<Uint8Array<ArrayBufferLike>>

Decrypt segment i (04 §10.6 step 4), with the final flag set only for the last one. Returns the framed plaintext of that segment (segment 0 starts with the 8-byte length). A tag failure throws crypto.decrypt_failed (tag).

i: number
ciphertext: Uint8Array

fileSize

fileSize(segment0: Uint8Array): number

Read the file size from segment 0's plaintext and check that the blob's padded length is pad(size + 8) (04 §10.6 step 5); throws padding otherwise.

segment0: Uint8Array

Source: crypto/attachments.ts:338

Functions

acceptPinDowngrade function

function acceptPinDowngrade(pin: PinRecord, nowMs?: number): IdentityPinUpdate

The accept action of a blocking downgrade W2 (07 §16.3, 20): downgraded_blocked → downgraded, wasVerified stays true.

nowMs: number

Source: crypto/identity.ts:1517

acceptPinNewKey function

function acceptPinNewKey(pin: PinRecord, nowMs?: number): IdentityPinUpdate

"Accept new key" (07 §16.3): verified_blocked → accepted; prevIk ← ik, ik ← pendingIk; sending unblocks.

nowMs: number

Source: crypto/identity.ts:1499

aeadOpen function

function aeadOpen(key: AeadKey, nonce: Uint8Array, aad: Uint8Array, ciphertext: Uint8Array): Promise<Uint8Array<ArrayBufferLike>>

Decrypt an aeadSeal result (04 §9). Fails with crypto.decrypt_failed (tag) and releases nothing on any authentication failure (04 §9.7).

key: AeadKey
nonce: Uint8Array
aad: Uint8Array
ciphertext: Uint8Array

Source: crypto/aead.ts:104

aeadSeal function

function aeadSeal(key: AeadKey, aad: Uint8Array, plaintext: Uint8Array, random?: RandomSource): Promise<AeadSealed>

Encrypt with AES-256-GCM under a fresh 12-byte nonce from the CSPRNG (04 §9.2 item 1). The AAD MUST be the owner's deterministic, place-binding structure and is never empty (04 §9.4). The caller keeps within the key's usage bound (04 §9.3) and, for single-use keys such as K_msg, encrypts once and stores the result (04 §9.6).

key: AeadKey
aad: Uint8Array
plaintext: Uint8Array
random: RandomSource

Default: cryptoRandomBytes

Source: crypto/aead.ts:93

aesGcmDecrypt function

function aesGcmDecrypt(key: AeadKey, nonce: Uint8Array, aad: Uint8Array, ciphertext: Uint8Array): Promise<Uint8Array<ArrayBufferLike>>

AES-256-GCM decryption with an explicit nonce (04 §9.1). A tag failure releases no plaintext and throws the local diagnostic crypto.decrypt_failed with reason: "tag" (04 §9.7, §15.2).

key: AeadKey
nonce: Uint8Array
aad: Uint8Array
ciphertext: Uint8Array

Source: crypto/aead.ts:59

aesGcmEncrypt function

function aesGcmEncrypt(key: AeadKey, nonce: Uint8Array, aad: Uint8Array, plaintext: Uint8Array): Promise<Uint8Array<ArrayBufferLike>>

AEAD-Encrypt(K, N, A, P): AES-256-GCM with an explicit nonce, returning ciphertext || tag (04 §1.3, §9.1). Only for constructions whose nonce is fixed by their owner: the SVF1 counter nonce (04 §10.4), HPKE's key-schedule nonce (04 §9.8), and test vectors. Everything else uses aeadSeal, which draws a fresh random nonce (04 §9.2).

key: AeadKey
nonce: Uint8Array
aad: Uint8Array
plaintext: Uint8Array

Source: crypto/aead.ts:43

applyIdentityEvidence function

function applyIdentityEvidence(pin: PinRecord, state: VerifiedIdentityState, nowMs?: number, opts?: { kindHint?: IdentityKind }): Promise<IdentityPinUpdate>

OnIdentityEvidence(S) of 07 §16.4 with the transitions of the §16.3 table, for a verified IdentityState S of the pin's address. Returns the updated record and the W2 to raise. kindHint is the account kind from the public profile (05 §17.1) for new-account evidence of an insecure account; it defaults to user.

nowMs: number
opts: { kindHint?: IdentityKind }

Default: {}

Source: crypto/identity.ts:1330

applyServerKeyRevocation function

function applyServerKeyRevocation(store: VerifierStore, kid: string, rvtMs: number): Promise<string[]>

Apply the revoked-server-key rule of 07 §7.5 after the issuer's ServerMetadata (02) lists the sign key kid (domain#keyId) as revoked with revocation time rvtMs (ms). For every subject, a stored state signed by that key is discarded unless the verifier accepted it before rvt − 60 s by its own clock, together with every DeviceRevocation learned only from discarded states. A kept state stays as the ver baseline, also after it expires. Returns the subjects whose state was discarded; the caller refetches their IdentityState before relying on it.

Refusing newly presented objects signed by the revoked key is the key resolver's job (02 §11.7).

kid: string
rvtMs: number

Source: crypto/identity.ts:550

assertEd25519Signature function

function assertEd25519Signature(publicKey: Uint8Array, message: Uint8Array, signature: Uint8Array, context?: { field?: string; data?: Record<string, unknown> } & Ed25519VerifyOptions): Promise<void>

Strict Ed25519 verification (04 §4.3) that throws on failure: crypto.invalid_key (with data.field) for items 1 and 2, crypto.bad_signature (with data, for example { typ } or { label }) for items 3 to 7.

publicKey: Uint8Array
message: Uint8Array
signature: Uint8Array
context: { field?: string; data?: Record<string, unknown> } & Ed25519VerifyOptions

Default: {}

Source: crypto/ed25519.ts:362

assertLabelledSignature function

function assertLabelledSignature(publicKey: Uint8Array, label: string & {} | "test" | "sealed" | "history-share" | "history-link" | "media-attest" | "vault-box-key" | "vault-generation", content: Uint8Array, signature: Uint8Array, opts?: LabelledOptions & Ed25519VerifyOptions): Promise<void>

VerifyLabelled(pub, label, content, sig) with the strict rules of 04 §4.3. Throws crypto.invalid_key (key) or crypto.bad_signature with data.label (04 §15.1).

publicKey: Uint8Array
label: string & {} | "test" | "sealed" | "history-share" | "history-link" | "media-attest" | "vault-box-key" | "vault-generation"
content: Uint8Array
signature: Uint8Array

Source: crypto/labelled.ts:112

assertSealedShape function

function assertSealedShape(s: unknown, opts?: { maxMessageBytes?: number }): asserts s is SealedMessage

Throw sdk.invalid_argument unless s passes checkSealedShape.

s: unknown
opts: { maxMessageBytes?: number }

Default: {}

Source: crypto/sealed.ts:725

bufferSource function

function bufferSource(bytes: Uint8Array): Uint8Array<ArrayBuffer>

WebCrypto wants a BufferSource backed by an ArrayBuffer; copy when a view is backed by something else.

bytes: Uint8Array

Source: crypto/primitives.ts:299

bytesToHex function

function bytesToHex(bytes: Uint8Array): string

Lowercase hexadecimal, two digits per byte, no separators (04 §3.3). For test vectors and diagnostics only.

bytes: Uint8Array

Source: crypto/primitives.ts:267

canonicalAddressProblem function

function canonicalAddressProblem(address: string): NonCanonicalReason | null

01 §7.5 checks 1 to 5 on a canonical address, as 07 §4.2 requires for every sub: the version-stable minimalPrepare test, never the full profile (01 AD-8). Delegates to the address module's checkCanonical. Returns null when the address passes, otherwise the reason.

address: string

Source: crypto/identity.ts:116

checkEd25519PublicKey function

function checkEd25519PublicKey(publicKey: Uint8Array, field?: string): void

Accept an Ed25519 public key at one of the points of 04 §4.5 (server keys, MLS external-sender keys, identity keys, DSKs). Throws crypto.invalid_key with data.field (and data.reason, the Ed25519KeyProblem) when 04 §4.3 item 1 or 2 fails.

publicKey: Uint8Array
field: string

Default: 'key'

Source: crypto/ed25519.ts:235

checkGroupLeafRules function

function checkGroupLeafRules(leaves: readonly GroupLeafIdentity[], opts?: { checkL5?: boolean }): GroupLeafRuleFailure | null

The group-level leaf rules of 07 §10.2 on a whole tree after a commit (07 §10.5): L4 (no two leaves with the same (sub, did): duplicate_device_leaf), L6 (no leaf's signature_key is any leaf's identity key: identity_key_as_leaf) and, when checkL5 is set (DMs and group DMs, where L5 and L8 are a MUST; in channels L5 is only a diagnostic, 07 §13.6 S3), L5 (all leaves of one sub not pending removal carry byte-identical IdentityCertificates: mixed_identity). Returns the first failure, or null. L1 and L2 are validateSvDeviceCredential's; L7 is checkLeafCredentialUnchanged.

leaves: readonly GroupLeafIdentity[]
opts: { checkL5?: boolean }

Default: {}

Source: crypto/identity.ts:1738

checkHistoryShareShape function

function checkHistoryShareShape(share: unknown, opts?: { pathCtx?: string; sessionDid?: string }): string | null

Check a HistoryShare against 14 §7.4 (the server's §7.7 step 5, without the path and session comparisons): every member's type, grammar and length, ct of exactly 5 + 48 × count + 16 bytes, and 1 to 100 key wraps with distinct dids. Returns the first failing member, or null. Pass pathCtx and sessionDid to include the two comparisons as well.

share: unknown
opts: { pathCtx?: string; sessionDid?: string }

Default: {}

Source: crypto/history-share.ts:156

checkKeyCommitment function

function checkKeyCommitment(kMsg: Uint8Array, kc: Uint8Array): Promise<boolean>

Check kc against K_msg in constant time, before any decryption (14 §3.4).

kMsg: Uint8Array
kc: Uint8Array

Source: crypto/sealed.ts:80

checkLeafCredentialUnchanged function

function checkLeafCredentialUnchanged(current: Uint8Array, updated: Uint8Array): void

L7 (07 §10.2): a leaf's credential never changes in place. The LeafNode of an Update proposal or an UpdatePath MUST carry a credential byte-identical to the leaf's current one; otherwise the commit is invalid with credential_changed (07 §14.2 D5). Throws IdentityCheckError.

current: Uint8Array
updated: Uint8Array

Source: crypto/identity.ts:1765

checkSealedShape function

function checkSealedShape(s: unknown, opts?: { maxMessageBytes?: number }): SealedShapeResult

Check a SealedMessage against 14 §4.1 and §4.2: every member's type, grammar and length, canonical base64url, v = 1, and the ref rule of the known kinds. With maxMessageBytes, also the upper bound on ct (roundUp256(maxMessageBytes) + 16; tooLarge is then set, 14 §5.2 step 5). Returns the decoded binary members, or the first failing member.

s: unknown
opts: { maxMessageBytes?: number }

Default: {}

Source: crypto/sealed.ts:220

checkSvf1Blob function

function checkSvf1Blob(blob: Uint8Array): void

The structure check a hosting server SHOULD run on a secure upload without the key (04 §10.7 item 2): the length rules and the SVF1 magic. Throws crypto.malformed with field: "blob" and reason length or structure.

blob: Uint8Array

Source: crypto/attachments.ts:151

checkVerifyQr function

function checkVerifyQr(text: string, ctx: VerifyQrScanContext): VerifyQrResult

The scanning checks of 07 §17.2: (1) prefix, decoding and version; (2) own_address has a pin record (and is the contact the screen was opened for, otherwise other_contact: the code belongs to someone else); (3) own_ik equals the key the scanner trusts for that contact; (4) peer_address is the scanner's own address; (5) peer_ik is the scanner's own identity key. Any failure changes nothing.

text: string

Source: crypto/safety-number.ts:194

compareAddresses function

function compareAddresses(a: string, b: string): number

Compare two canonical addresses in byte-wise order: UTF8(a) and UTF8(b) as unsigned byte strings, lexicographically, a proper prefix sorting first (12 §2.2). Returns a negative number, 0 or a positive number. For NFC strings this equals ordering by Unicode code point, which is not JavaScript's default UTF-16 string order.

a: string
b: string

Source: crypto/dm-id.ts:36

concatBytes function

function concatBytes(...parts: readonly Uint8Array<ArrayBufferLike>[]): Uint8Array

a || b || …: byte concatenation (04 §1.3).

...parts: readonly Uint8Array<ArrayBufferLike>[]

Source: crypto/primitives.ts:222

constantTimeEqual function

function constantTimeEqual(a: Uint8Array, b: Uint8Array): boolean

Compare two byte strings in constant time with respect to their contents (04 §8.2 item 3, §14.4 item 1). Unequal lengths return false immediately; lengths are public.

a: Uint8Array
b: Uint8Array

Source: crypto/primitives.ts:286

contentMatchesRef function

function contentMatchesRef(kind: string, ref: string | undefined, content: Record<string, unknown>): boolean

The consistency rule of 14 §4.3 (and 11 §3.9) between decrypted content and the signed header: if the content names a target (11's target member), it MUST equal ref. For edit, reaction and delete the content's target is required (11 §3.7); a message names none. Unknown kinds are not checked (they are verified and then ignored, 14 §4.3).

kind: string
ref: string | undefined
content: Record<string, unknown>

Source: crypto/sealed.ts:181

createHistoryShare function

function createHistoryShare(p: CreateHistoryShareParams): Promise<HistoryShare>

Build a HistoryShare request body (14 §7.5, §7.6 steps 4 to 6): a fresh K_share and nonce, the Bundle encrypted under the ShareHeader, K_share HPKE-wrapped to each recipient device's box key, and the history-share signature. K_share is erased before returning. Only call this on the user's explicit action (14 §7.1 item 1); bot accounts never share (14 §11).

Source: crypto/history-share.ts:239

createPinRecord function

function createPinRecord(state: VerifiedIdentityState, nowMs?: number): PinRecord

First contact (07 §16.2): a new record in state pinned, created silently, from a verified IdentityState of a secure account (never from a credential alone, never for the own address).

nowMs: number

Source: crypto/identity.ts:1300

cryptoError function

function cryptoError(code: CryptoErrorCode | CryptoLocalErrorCode, detail: string, data?: Record<string, unknown>, override?: Partial<Pick<CryptoErrorInfo, "retryable" | "userAction">> & { retryAfterMs?: number | null }): SloppyVoiceError

Build a SloppyVoiceError for a crypto.* failure detected locally by the SDK, with the status, retryable and userAction of the registry (04 §15). data carries the members the registry lists for the code (field, reason, member, claim, kid, …).

detail: string
data: Record<string, unknown>

Default: {}

override: Partial<Pick<CryptoErrorInfo, "retryable" | "userAction">> & { retryAfterMs?: number | null }

Default: {}

Source: crypto/primitives.ts:142

cryptoRandomBytes function

function cryptoRandomBytes(length: number): Uint8Array

length bytes from the platform CSPRNG (crypto.getRandomValues) (04 §13 item 1). There is no fallback: if the CSPRNG is missing or fails, this throws crypto.rng_failure (04 §13 item 3).

length: number

Source: crypto/primitives.ts:182

decodeBundle function

function decodeBundle(bundle: Uint8Array, count: number): ShareItem[] | null

Decode and check a Bundle (14 §7.8 step 3): version 1, the header's count, the exact length, items strictly ascending by mid16, every mid a valid UUIDv7. Returns null on any failure.

bundle: Uint8Array
count: number

Source: crypto/history-share.ts:63

decodeCryptoField function

function decodeCryptoField(s: unknown, opts?: DecodeFieldOptions): Uint8Array

Decode a cryptographic base64url field with every rule of 04 §3.1: characters, padding, length mod 4, canonical tail bits and the field's required decoded length. Failures are crypto.malformed with reason encoding or length.

s: unknown
opts: DecodeFieldOptions

Default: {}

Source: crypto/primitives.ts:349

decodeJwsUnverified function

function decodeJwsUnverified(compact: string): { header: Record<string, unknown>; payload: Record<string, unknown> }

Decode a compact JWS's header and payload WITHOUT verifying anything. Only for diagnostics and for reading the issuer before key discovery; never act on the result (04 §6.8 item 2).

compact: string

Source: crypto/jws.ts:697

decodeTlsVarint function

function decodeTlsVarint(bytes: Uint8Array, offset?: number): { value: number; length: number } | null

Decode an RFC 9420 §2.1.2 variable-length integer at offset. Rejects the reserved 11 prefix, a truncated value and a non-minimal encoding. Returns null on any error.

bytes: Uint8Array
offset: number

Default: 0

Source: crypto/identity.ts:955

deriveEkid function

function deriveEkid(kHist: Uint8Array): Promise<Uint8Array<ArrayBufferLike>>

ekid(e) = HKDF-Expand(PRK = K_hist(e), info = "sv1 ekid", L = 8) (14 §3.2).

kHist: Uint8Array

Source: crypto/sealed.ts:62

deriveKeyCommitment function

function deriveKeyCommitment(kMsg: Uint8Array): Promise<Uint8Array<ArrayBufferLike>>

kc = HMAC-SHA256(key = K_msg, message = "sv1 kc")[0..16] (14 §3.4).

kMsg: Uint8Array

Source: crypto/sealed.ts:74

deriveMessageKey function

function deriveMessageKey(kHist: Uint8Array, mid: string): Promise<Uint8Array<ArrayBufferLike>>

K_msg(e, mid) = HKDF-Expand(PRK = K_hist(e), info = "sv1 msg" || mid16(mid), L = 32), no separator (14 §3.3).

kHist: Uint8Array
mid: string

Source: crypto/sealed.ts:68

deriveSvf1Keys function

function deriveSvf1Keys(fileKey: Uint8Array): Promise<Svf1Keys>

Derive K_enc and the commitment from a 32-byte K_file (04 §10.2).

fileKey: Uint8Array

Source: crypto/attachments.ts:173

did16 function

function did16(did: string): Uint8Array

did16(d): the 16 bytes of a base64url device ID (14 §1.2, 00 §7.6).

did: string

Source: crypto/sealed.ts:38

dismissPinW2 function

function dismissPinW2(pin: PinRecord, nowMs?: number): IdentityPinUpdate

The user dismisses a non-blocking W2 (07 §16.3): changed and accepted move to pinned; downgraded, new_account and pinned (new-account W2) stay. A blocking W2 has no dismiss action, so verified_blocked and downgraded_blocked are unchanged.

nowMs: number

Source: crypto/identity.ts:1486

dmAddressProblem function

function dmAddressProblem(addr: unknown): string | null

The syntactic checks 1 to 5 of 01 §7.5 (isCanonical without the semantic check 6), which need no network and only version-stable Unicode data: exactly one @ and the canonical-address grammar of 01 §2.2 (the local part is ASCII digits, ASCII lowercase letters and non-ASCII characters only: no ., _, -, + or other ASCII punctuation); a local part of 1 to 64 octets in NFC that minimalPrepare leaves unchanged (full case folding, not just ASCII); no white space, default-ignorable code point or code point of category Cc, Cf, Cs, Co, Zl, Zp or Zs; and a well-formed lowercase A-label domain (at most 253 octets, at least two labels of 1 to 63 octets, LDH rules, no trailing dot, last label not all digits, xn-- labels that decode). Returns the reason, or null if the address passes.

It catches non-canonical input such as V-6's Alice@A.com; it doesn't replace 01's canonicalize(), which callers MUST run first (12 §4.1 item 1, §5.5 V-6), nor check 6 (that the domain is the server's canonical domain, not an alias), which needs discovery (02).

addr: unknown

Source: crypto/dm-id.ts:78

dmContextId function

function dmContextId(a: string, b: string): Promise<`dm:${string}`>

Compute the context reference of the 1:1 DM between two canonical addresses, in either order: "dm:" || base64url(SHA-256(...)[0..16]) (12 §5.2). Anyone can compute it (00 §7.6); the same pair has the same reference on every server.

Throws sdk.invalid_argument if the addresses are equal (reason self) or fail the syntactic canonical check of dmAddressProblem (reason non_canonical; 12 §5.5 V-6).

a: string
b: string

Source: crypto/dm-id.ts:139

dmIdBytes function

function dmIdBytes(a: string, b: string): Promise<Uint8Array<ArrayBufferLike>>

The first 16 bytes of SHA-256(dmIdInput(a, b)): the binary 1:1 DM ID (12 §5.2).

a: string
b: string

Source: crypto/dm-id.ts:126

dmIdInput function

function dmIdInput(a: string, b: string): Uint8Array

The SHA-256 input of a 1:1 DM reference (12 §5.2): UTF8("sv1 dm") || 0x00 || UTF8(P1) || 0x0A || UTF8(P2), with P1 < P2 in byte-wise order. The arguments may come in either order. Both MUST be canonical addresses (01 §7).

a: string
b: string

Source: crypto/dm-id.ts:116

ed25519KeyPairFromSeed function

function ed25519KeyPairFromSeed(seed: Uint8Array, opts?: { extractable?: boolean }): Promise<Ed25519KeyPair>

Import an Ed25519 key pair from its 32-byte RFC 8032 seed (04 §3.4, §4.1). The private key is non-extractable unless extractable is true (04 §14.2: only the identity key needs to be extractable, for pairing and the KeyBackup).

seed: Uint8Array
opts: { extractable?: boolean }

Default: {}

Source: crypto/ed25519.ts:415

ed25519PublicKeyProblem function

function ed25519PublicKeyProblem(publicKey: Uint8Array): Ed25519KeyProblem | null

Check an Ed25519 public key against 04 §4.3 items 1 and 2: exactly 32 bytes, canonical encoding that RFC 8032 decoding accepts, not of small order ([8]A ≠ O) and not of mixed order ([L]A = O). Returns null if the key is acceptable, or the problem. Results are cached per key, as 04 §4.3 item 2 allows.

publicKey: Uint8Array

Source: crypto/ed25519.ts:215

ed25519PublicKeyToJwk function

function ed25519PublicKeyToJwk(publicKey: Uint8Array): Ed25519PublicJwk

The JWK of a raw 32-byte Ed25519 public key (04 §5.1), with canonical x.

publicKey: Uint8Array

Source: crypto/jwk.ts:91

ed25519SelfTest function

function ed25519SelfTest(): Promise<boolean>

The start-up self-test of 04 §4.3 "Web clients": resolves true only if this platform's crypto.subtle.verify accepts V-4a (RFC 8032 test 1) and rejects V-4g (mixed-order R, which only the cofactored equation accepts). Runs once per process; never rejects.

Source: crypto/ed25519.ts:286

ed25519SignerFromCryptoKey function

function ed25519SignerFromCryptoKey(privateKey: CryptoKey, publicKey: Uint8Array): Ed25519KeyPair

Wrap a WebCrypto Ed25519 private key and its public key as a signer (04 §4.2). The public key must be the one that belongs to privateKey; use ed25519KeyPairFromSeed when in doubt.

privateKey: CryptoKey
publicKey: Uint8Array

Source: crypto/ed25519.ts:398

ed25519VerifyResult function

function ed25519VerifyResult(publicKey: Uint8Array, message: Uint8Array, signature: Uint8Array, opts?: Ed25519VerifyOptions): Promise<Ed25519VerifyResult>

Strict Ed25519 verification of 04 §4.3, returning which rule failed. Items 1 and 2 (the key) give crypto.invalid_key; items 3 to 7 give crypto.bad_signature. Pure Ed25519 with no context (RFC 8032 §5.1.7), no batch verification, cofactorless equation.

publicKey: Uint8Array
message: Uint8Array
signature: Uint8Array
opts: Ed25519VerifyOptions

Default: {}

Source: crypto/ed25519.ts:315

effectivePinState function

function effectivePinState(pin: Pick<PinRecord, "state">): PinState

The state a client acts on: an unknown value is verified_blocked (fail safe, 07 §16.1). The caller also sets pendingIk from the newest verified IdentityState it holds (or fetches one, keeping sending blocked and "Accept new key" disabled until it arrives).

pin: Pick<PinRecord, "state">

Source: crypto/identity.ts:1252

encodeBundle function

function encodeBundle(items: readonly ShareItem[]): Uint8Array

Encode a Bundle: u8(1) || u32(count) || count × (mid16 || K_msg), items strictly ascending by mid16 (14 §7.5). The items are sorted first; duplicates are rejected.

items: readonly ShareItem[]

Source: crypto/history-share.ts:46

encodeCryptoField function

function encodeCryptoField(bytes: Uint8Array): string

Canonical unpadded base64url of bytes (04 §3.1, 00 §7.2). Re-exported from core for convenience inside the crypto module.

bytes: Uint8Array

Source: crypto/primitives.ts:369

encodeSealedHeader function

function encodeSealedHeader(f: SealedHeaderFields): Uint8Array

Encode the SealedHeader (14 §4.4): u8(1) || V16(group_id) || V16(sender) || did16 || mid16 || u64(epoch) || ekid || V8(kind) || V8(ref16) || nonce || kc. It is the AEAD associated data exactly, and the start of the signed content.

Source: crypto/sealed.ts:114

encodeShareHeader function

function encodeShareHeader(f: ShareHeaderFields): Uint8Array

Encode the ShareHeader (14 §7.5): u8(1) || V16(host) || V16(ctx) || mid16(shareId) || V16(sharer) || did16(did) || V16(recipient) || u64(fromSeq) || u64(toSeq) || u32(count) || nonce. It is the bundle's AEAD associated data and the start of the signed content.

Source: crypto/history-share.ts:110

encodeSvDeviceCredential function

function encodeSvDeviceCredential(cred: SvDeviceCredential): Uint8Array

Encode the MLS Credential of type sv_device (07 §10.1): credential_type (0xF5A0) followed by the two JWS as opaque <V> vectors, exactly as issued.

Source: crypto/identity.ts:989

encodeTlsVarint function

function encodeTlsVarint(n: number): Uint8Array

Encode n as an RFC 9420 §2.1.2 variable-length integer with the minimum number of bytes (up to 2^30 − 1).

n: number

Source: crypto/identity.ts:944

encodeVerifyQr function

function encodeVerifyQr(p: Omit<VerifyQrPayload, "nonce"> & { nonce?: Uint8Array<ArrayBufferLike> }, random?: RandomSource): string

Encode the VerifyQR struct (07 §17.2: fixed 2-byte length prefixes of RFC 8446 §3.4) and return the QR text SVV1: + base64url without padding. The code is shown in byte mode, error correction M. Omit nonce to draw a fresh one (it is regenerated every time the screen opens).

p: Omit<VerifyQrPayload, "nonce"> & { nonce?: Uint8Array<ArrayBufferLike> }
random: RandomSource

Default: cryptoRandomBytes

Source: crypto/safety-number.ts:113

evaluateOwnIdentity function

function evaluateOwnIdentity(prev: OwnIdentityState | null, state: VerifiedIdentityState, ctx: { ownDid: string; initiatedByThisDevice?: boolean; actorDid?: string; nowMs?: number }): OwnIdentityAlerts

Process a verified own IdentityState under 07 §18.1 and §18.3 (from any source, 07 §18.4). ownDid is this device; initiatedByThisDevice is true when this device received the successful response that created the state's igen; actorDid is the actor.did of the matching identity.changed, if any. Pass prev null at sign-in or enrolment to set the baseline.

prev: OwnIdentityState | null
ctx: { ownDid: string; initiatedByThisDevice?: boolean; actorDid?: string; nowMs?: number }

Source: crypto/identity.ts:1624

exportEd25519Seed function

function exportEd25519Seed(privateKey: CryptoKey): Promise<Uint8Array<ArrayBufferLike>>

Export the 32-byte RFC 8032 seed of an extractable WebCrypto Ed25519 private key, the only form in which a private key travels (04 §3.4; pairing payload and KeyBackup, 08). The caller wipes it after use (04 §14.3).

privateKey: CryptoKey

Source: crypto/ed25519.ts:458

formatSafetyNumber function

function formatSafetyNumber(n: string, rows?: number): string[][]

Split a 60-digit safety number into the 12 groups of 5 digits clients MUST display, never shortened (07 §17.1). rows arranges them as rows of 12 / rows groups (3 rows of 4 by default).

n: string
rows: number

Default: 3

Source: crypto/safety-number.ts:75

generateEd25519KeyPair function

function generateEd25519KeyPair(opts?: { extractable?: boolean; random?: RandomSource }): Promise<Ed25519KeyPair & { seed?: Uint8Array<ArrayBufferLike> }>

Generate a fresh Ed25519 key pair from 32 CSPRNG bytes (04 §4.1 item 1, §13). Returns the seed too when extractable is true (the identity key travels as its seed, 04 §3.4); otherwise the seed is wiped and the private key is non-extractable. Checks that the public key isn't of small order (04 §4.1 item 3).

opts: { extractable?: boolean; random?: RandomSource }

Default: {}

Source: crypto/ed25519.ts:439

generateFileKey function

function generateFileKey(random?: RandomSource): Uint8Array

A fresh 32-byte K_file from the CSPRNG (04 §10.2 item 1). Never reuse one, even for the same file.

random: RandomSource

Default: cryptoRandomBytes

Source: crypto/attachments.ts:185

generateX25519KeyPair function

function generateX25519KeyPair(opts?: { extractable?: boolean }): Promise<X25519KeyPair>

Generate an X25519 key pair from the CSPRNG (04 §13), for a device's box key (08) or an HPKE ephemeral key. The private key is non-extractable unless extractable is set; a box key never leaves its device (04 §14.2 item 4).

opts: { extractable?: boolean }

Default: {}

Source: crypto/hpke.ts:54

hexToBytes function

function hexToBytes(hex: string): Uint8Array

Parse hexadecimal (04 §3.3). White space is ignored so that wrapped vector values paste cleanly.

hex: string

Source: crypto/primitives.ts:274

historyShareInfo function

function historyShareInfo(shareId: string, did: string): Uint8Array

The HPKE info of one key wrap: "sv1 history-share" || 0x00 || mid16(shareId) || did16(d), 50 bytes (14 §7.5).

shareId: string
did: string

Source: crypto/history-share.ts:133

hkdf function

function hkdf(salt: Uint8Array, ikm: Uint8Array, info: Uint8Array, length: number): Promise<Uint8Array<ArrayBufferLike>>

HKDF-Extract then HKDF-Expand (RFC 5869 §2), for owners that define a salt (04 §8.1 items 2 and 3).

salt: Uint8Array
ikm: Uint8Array
info: Uint8Array
length: number

Source: crypto/hkdf.ts:70

hkdfExpand function

function hkdfExpand(prk: Uint8Array, info: Uint8Array, length: number): Promise<Uint8Array<ArrayBufferLike>>

HKDF-Expand(PRK, info, L) of RFC 5869 §2.3 with SHA-256 (04 §1.3, §8.1). A uniformly random key of at least 32 bytes may be the PRK directly (04 §8.1 item 1). L is at most 64 bytes in sv1 (04 §8.1 item 4).

prk: Uint8Array
info: Uint8Array
length: number

Source: crypto/hkdf.ts:52

hkdfExtract function

function hkdfExtract(salt: Uint8Array, ikm: Uint8Array): Promise<Uint8Array<ArrayBufferLike>>

HKDF-Extract(salt, IKM) of RFC 5869 §2.2 with SHA-256 (04 §1.3). An empty salt means 32 zero bytes, as RFC 5869 specifies. Returns the 32-byte PRK.

salt: Uint8Array
ikm: Uint8Array

Source: crypto/hkdf.ts:43

hmacSha256 function

function hmacSha256(key: Uint8Array, message: Uint8Array): Promise<Uint8Array<ArrayBufferLike>>

HMAC(K, m): HMAC-SHA256 (RFC 2104) (04 §1.3, §8.2). Returns 32 bytes.

key: Uint8Array
message: Uint8Array

Source: crypto/hkdf.ts:18

hpkeInfo function

function hpkeInfo(label: "sv1 vault grant" | "sv1 history-share", context: Uint8Array): Uint8Array

Build an HPKE info: label || 0x00 || context (04 §8.3 item 2, §9.8 item 3). context is defined by the owner: 08 §10.3 for sv1 vault grant, 14 §7.5 for sv1 history-share.

label: "sv1 vault grant" | "sv1 history-share"
context: Uint8Array

Source: crypto/hpke.ts:130

hpkeOpen function

function hpkeOpen(recipient: X25519KeyPair, enc: Uint8Array, info: Uint8Array, ciphertext: Uint8Array, aad?: Uint8Array): Promise<Uint8Array<ArrayBufferLike>>

OpenBase(enc, skR, info, aad, ct) of RFC 9180 §6.1 with the sv1 suite (04 §9.8). The recipient passes its box key pair. Any failure is crypto.decrypt_failed (tag, or format for a bad enc) and releases nothing (04 §9.7, §9.8 item 5).

recipient: X25519KeyPair
enc: Uint8Array
info: Uint8Array
ciphertext: Uint8Array
aad: Uint8Array

Source: crypto/hpke.ts:185

hpkeSeal function

function hpkeSeal(recipientPublicKey: Uint8Array, info: Uint8Array, plaintext: Uint8Array, aad?: Uint8Array): Promise<HpkeSealed>

SealBase(pkR, info, aad, pt) of RFC 9180 §6.1 with the sv1 suite and a fresh ephemeral key from the CSPRNG (04 §9.8 items 1 and 2). aad is empty in sv1 (04 §9.4, §9.8 item 3).

Before calling this, the sender MUST have checked the recipient's box key, so that the server can't substitute its own: its vault-box-key labelled signature for a VaultKeyGrant, or its equality with the dbk of a validated DeviceCertificate for a HistoryShare (04 §9.8 item 4).

recipientPublicKey: Uint8Array
info: Uint8Array
plaintext: Uint8Array
aad: Uint8Array

Source: crypto/hpke.ts:175

identityCheckReason function

function identityCheckReason(e: unknown): IdentityCheckResult | null

The identity check result carried by an error thrown from this module, or null for any other error.

e: unknown

Source: crypto/identity.ts:80

importAeadKey function

function importAeadKey(key: Uint8Array, opts?: { extractable?: boolean }): Promise<CryptoKey>

Import 32 raw bytes as a non-extractable WebCrypto AES-256-GCM key (04 §9.1 item 2, §14.2). Lets a caller import once and reuse the key without keeping raw bytes around.

key: Uint8Array
opts: { extractable?: boolean }

Default: {}

Source: crypto/aead.ts:28

importX25519PrivateKey function

function importX25519PrivateKey(privateKey: Uint8Array, opts?: { extractable?: boolean }): Promise<X25519KeyPair>

Import a raw 32-byte X25519 private key (for example one unwrapped from local storage, 04 §14.2) and compute its public key (RFC 7748 §6.1). The imported key is non-extractable unless extractable is set. X25519 private keys never travel (04 §3.4).

privateKey: Uint8Array
opts: { extractable?: boolean }

Default: {}

Source: crypto/hpke.ts:66

isCanonicalAddressSyntax function

function isCanonicalAddressSyntax(address: string): boolean

True if address passes 01 §7.5 checks 1 to 5 (canonicalAddressProblem).

address: string

Source: crypto/identity.ts:122

isCanonicalBase64Url function

function isCanonicalBase64Url(s: string): boolean

True if s is canonical unpadded base64url as 04 §3.1 items 1 to 3 require: only A–Z a–z 0–9 - _, length mod 4 not 1, and zero unused bits in the last character.

s: string

Source: crypto/primitives.ts:327

isCanonicalDomainSyntax function

function isCanonicalDomainSyntax(s: string): boolean

Syntax check of a canonical domain (01 §2.2 ABNF canonical-domain): 3 to 253 octets, at least two labels of lowercase letters, digits and inner hyphens, and -- in positions 3 and 4 only in an xn-- A-label. It doesn't check that an A-label decodes to a valid U-label (01 owns that).

s: string

Source: crypto/jws.ts:102

isDeviceValid function

function isDeviceValid(devcertJws: string, state: VerifiedIdentityState, purpose: FreshnessPurpose, opts?: FreshnessOptions & { storeEntry?: VerifierStoreEntry; isCanonical?: CanonicalAddressCheck }): Promise<DeviceValidity>

IsDeviceValid(sub, devcertJws, state, purpose) of 07 §9, steps 1 to 8: dual control (a DeviceCertificate under the current identity key, and a listing with matching dkf in an accepted, fresh IdentityState) and no covering revocation, whether in state.revoked or among the verifier store's verified DeviceRevocations (opts.storeEntry).

devcertJws: string
opts: FreshnessOptions & { storeEntry?: VerifierStoreEntry; isCanonical?: CanonicalAddressCheck }

Default: {}

Source: crypto/identity.ts:904

isKdfLabel function

function isKdfLabel(label: string): boolean

True if label matches the kdf-label grammar of 04 §8.3, including the 32-character limit.

label: string

Source: crypto/hkdf.ts:81

isMlsExporterLabel function

function isMlsExporterLabel(label: string): label is "sv1 history" | "SFrame 1.0 Base Key"

True if label may be passed to the MLS exporter (04 §8.6 item 1).

label: string

Source: crypto/hkdf.ts:189

isPinBlocking function

function isPinBlocking(pin: Pick<PinRecord, "state">): boolean

True while sending to the contact is blocked (07 §16.5): states verified_blocked and downgraded_blocked.

pin: Pick<PinRecord, "state">

Source: crypto/identity.ts:1257

isStateFresh function

function isStateFresh(claims: Pick<IdentityStateClaims, "iat" | "exp">, purpose: FreshnessPurpose, opts?: FreshnessOptions): boolean

The freshness tests of 07 §7.6: unexpired (exp > now − skew), dm_admission (unexpired and iat ≥ now − 86400 − skew, optionally at time t) and channel_as (unexpired and validated at most 300 s ago).

claims: Pick<IdentityStateClaims, "iat" | "exp">
opts: FreshnessOptions

Default: {}

Source: crypto/identity.ts:883

isStrictDmRef function

function isStrictDmRef(ctx: unknown): ctx is `dm:${string}`

Whether ctx matches dm-ref of 12 §5.1 exactly: lowercase dm: prefix, 22 base64url characters, no padding, and a last character in AQgw (the 4 unused bits are zero; V-7).

ctx: unknown

Source: crypto/dm-id.ts:157

issueDeviceCertificate function

function issueDeviceCertificate(input: IssueDeviceCertificateInput): Promise<string>

Issue this device's DeviceCertificate (07 §6.1, §6.2) with payload members in the order sub, igen, did, dsk, dbk, plat, iat (07 §21.3). Refuses a DSK equal to the identity key (07 §3.4 item 3) and a plat that breaks 07 §6.1's grammar or bot rule.

Source: crypto/identity.ts:1152

issueDeviceRevocation function

function issueDeviceRevocation(input: IssueDeviceRevocationInput): Promise<string>

Issue a DeviceRevocation (07 §8.1) with members sub, igen, did, iat (07 §21.6).

Source: crypto/identity.ts:1185

issueIdentityCertificate function

function issueIdentityCertificate(input: IssueIdentityCertificateInput): Promise<string>

Issue a self-signed IdentityCertificate (07 §5.1, §5.2) with payload members in the order sub, ik, igen, kind, iat (07 §21.2). Issued only when a new identity key is created.

Source: crypto/identity.ts:1118

isSupportedSuite function

function isSupportedSuite(id: string): boolean

True only for sv1-c1. Every other suite identifier, including the reserved sv1-c2, is unsupported in v1 (04 §2.3, §17.4 item 3).

id: string

Source: crypto/primitives.ts:28

isSvf1BlobLength function

function isSvf1BlobLength(blobBytes: number): boolean

Whether blobBytes is a length SVF1 can produce (04 §10.7 item 2, 11 §14.6): at least 4,155, a last segment ciphertext of at least 4,112 bytes, and pad(P) = P. A server refuses other lengths with crypto.malformed (reason: "length").

blobBytes: number

Source: crypto/attachments.ts:140

isThumbprintKid function

function isThumbprintKid(kid: string): boolean

True if kid is a 43-character key thumbprint (04 §6.4 key-thumbprint).

kid: string

Source: crypto/jws.ts:124

isValidEd25519PublicKey function

function isValidEd25519PublicKey(publicKey: Uint8Array): boolean

True if the public key passes 04 §4.3 items 1 and 2.

publicKey: Uint8Array

Source: crypto/ed25519.ts:243

jwkThumbprint function

function jwkThumbprint(publicKey: Uint8Array, crv?: "Ed25519" | "X25519"): Promise<string>

The key ID of an identity key (ikf) or DSK (dkf): base64url of its RFC 7638 SHA-256 thumbprint, 43 characters (04 §5.2). Vector V-2.

publicKey: Uint8Array
crv: "Ed25519" | "X25519"

Default: 'Ed25519'

Source: crypto/jwk.ts:124

jwkThumbprintBytes function

function jwkThumbprintBytes(publicKey: Uint8Array, crv?: "Ed25519" | "X25519"): Promise<Uint8Array<ArrayBufferLike>>

The 32-byte SHA-256 RFC 7638 thumbprint of a public key (04 §5.2). Binary structures that need a key fingerprint use these bytes (04 §5.2 item 3).

publicKey: Uint8Array
crv: "Ed25519" | "X25519"

Default: 'Ed25519'

Source: crypto/jwk.ts:116

jwsSigningInput function

function jwsSigningInput(headerBytes: Uint8Array, payloadBytes: Uint8Array): Uint8Array

The signing input bytes of a header and payload (04 §6.1 item 3); exported for tests of the profile.

headerBytes: Uint8Array
payloadBytes: Uint8Array

Source: crypto/jws.ts:713

labelInput function

function labelInput(label: string, context?: Uint8Array<ArrayBufferLike>): Uint8Array

The info (HKDF, HPKE) or message (HMAC, hashes) for a label (04 §8.3 item 2): label alone when there is no other input, otherwise label || 0x00 || context. The two exceptions of 04 §8.3 item 3 are not built here: sv1 msg uses "sv1 msg" || mid with no separator, and sv1 dm puts 0x0A between its addresses; their owners (14, 12) build those inputs.

label: string
context?: Uint8Array<ArrayBufferLike>

Source: crypto/hkdf.ts:91

labelledSignatureInput function

function labelledSignatureInput(label: string & {} | "test" | "sealed" | "history-share" | "history-link" | "media-attest" | "vault-box-key" | "vault-generation", content: Uint8Array, opts?: LabelledOptions): Uint8Array

The exact bytes a labelled signature signs: "sv1 sig" || 0x00 || label || 0x00 || content (04 §7.1). content is the owner's injective binary encoding, never JSON (04 §7.1 item 2).

label: string & {} | "test" | "sealed" | "history-share" | "history-link" | "media-attest" | "vault-box-key" | "vault-generation"
content: Uint8Array
opts: LabelledOptions

Default: {}

Source: crypto/labelled.ts:89

lvEncode function

function lvEncode(x: string | Uint8Array<ArrayBufferLike>): Uint8Array

lv(x): the TLS encoding of opaque x<V> (08 §1.4, 04 §3.2): a minimal varint length, then x (a string as UTF-8).

x: string | Uint8Array<ArrayBufferLike>

Source: crypto/identity.ts:969

markPinVerified function

function markPinVerified(pin: PinRecord, method: VerifyMethod, nowMs?: number): IdentityPinUpdate

The user verifies the trusted key (07 §16.3, §17): from pinned, changed or accepted to verified; from verified_blocked, ik ← pendingIk and the block ends. method is safety_number or qr.

method: VerifyMethod
nowMs: number

Source: crypto/identity.ts:1455

mergePinRecords function

function mergePinRecords(a: PinRecord, b: PinRecord): PinRecord

Merge two versions of one pin record from different devices (07 §16.6), as 08's vault sync requires on a version conflict (08 §8.9.2). Rule 1 picks the base by (igen, ver), then updatedAt; rules 2 to 5 apply in order, each only when the earlier ones don't; rules 6 and 7 always apply.

Source: crypto/identity.ts:1539

mid16 function

function mid16(mid: string): Uint8Array

mid16(m): the 16 RFC 9562 octets of a lowercase hyphenated UUIDv7 message ID (14 §1.2).

mid: string

Source: crypto/sealed.ts:32

openHistoryShare function

function openHistoryShare(share: HistoryShare, opts: OpenHistoryShareOptions): Promise<OpenHistoryShareResult>

Process a received HistoryShare up to the bundle (14 §7.8 steps 1 to 3): unwrap K_share with HPKE and this device's box key, verify the sharer's history-share signature over the ShareHeader rebuilt with the account's own address as recipient, decrypt and check the bundle. K_share is erased before returning. Each returned key must still pass verifySharedItem before anything is shown or stored (14 §7.8 step 5).

Source: crypto/history-share.ts:329

openSealed function

function openSealed(s: SealedMessage, opts: OpenSealedOptions): Promise<OpenSealedResult>

OpenSealed(S, ctx, host, sender, ts) of 14 §6.3. Content is returned only after the sender's signature verified (14 §6.1); nothing before step 7 discards a key or starts a resync. Deduplication by (ctx, mid) and the edit/delete author check are the caller's (14 §6.3).

Source: crypto/sealed.ts:450

openSecureAttachment function

function openSecureAttachment(blob: Uint8Array, ref: { key?: string; size: number; sha256?: string }): Promise<Uint8Array<ArrayBufferLike>>

Decrypt a downloaded secure attachment with the key of its reference and check it against the reference's size and sha256 (11 §14.3 receiver steps 2 and 3). Any failure is crypto.decrypt_failed, shown as the generic attachment failure, never as a security warning (D-055).

blob: Uint8Array
ref: { key?: string; size: number; sha256?: string }

Source: crypto/attachments.ts:538

orderDmPair function

function orderDmPair(a: string, b: string): [string, string]

Order a 1:1 pair as (P1, P2) with P1 < P2 in byte-wise order (12 §4.2, §5.2). Throws sdk.invalid_argument (data.reason self) when both are the same address, which the hosting server refuses with dm.invalid_participants (12 §4.2, §7.2 step 2).

a: string
b: string

Source: crypto/dm-id.ts:57

ownLeafW4bReason function

function ownLeafW4bReason(leaf: RosterLeafIdentity, own: OwnIdentityForW4b): "key_mismatch" | "device_not_listed" | null

The W4b trigger of 07 §18.2, for an enrolled device: a roster leaf (channel, DM or group DM) that names the own address and either (1) carries another identity key at generation g or higher (key_mismatch), or (2) carries the own key K but a did the latest own IdentityState doesn't list and no known revocation covers (device_not_listed). Leaves of a lower igen are the user's own stale leaves and return null.

A non-null result is not yet the alert: the device MUST first fetch its own IdentityState (IdentityApi.me); if that shows a higher igen it raises W4a instead, and if case 2 now lists the device there is no alert (W4c covers it). W4b is raised once per (context, identity key, did) per device, and reported as an identity diagnostic with the returned reason (07 §13.6 S4).

Source: crypto/identity.ts:1692

padPlaintext function

function padPlaintext(content: Uint8Array): Uint8Array

Pad content JSON with spaces (0x20) to the next multiple of 256 bytes (14 §4.5, 11 §3.8).

content: Uint8Array

Source: crypto/sealed.ts:149

parseDmRef function

function parseDmRef(ctx: string): Uint8Array

Parse a dm: reference into its 16 ID bytes (12 §5.1). Throws sdk.invalid_argument for anything that doesn't match dm-ref (wrong length, padding, characters outside the alphabet, non-zero unused bits as in V-7, or a prefix in another case such as DM:), which a server answers with 400 core.invalid_request. A colon percent-encoded as %3A in a path is not accepted here; decode the path segment first (00 §7.3).

ctx: string

Source: crypto/dm-id.ts:168

parseEd25519Jwk function

function parseEd25519Jwk(jwk: unknown, opts?: ParseJwkOptions): Uint8Array

Parse an Ed25519 public JWK (04 §5.1) into its 32 raw bytes. Rejects a JWK with private members or (unless the owner allows them) any member other than kty, crv, x; requires canonical base64url of exactly 32 bytes (crypto.malformed otherwise); and checks the key with 04 §4.3 items 1 and 2, as every point of 04 §4.5 requires. Key-shape failures are crypto.invalid_key.

jwk: unknown
opts: ParseJwkOptions

Default: {}

Source: crypto/jwk.ts:72

parseSealedPlaintext function

function parseSealedPlaintext(plaintext: Uint8Array): Record<string, unknown> | null

Parse a decrypted plaintext: exactly one JSON object followed only by white space (14 §4.5). Returns null otherwise.

plaintext: Uint8Array

Source: crypto/sealed.ts:159

parseServerKid function

function parseServerKid(kid: string): { domain: string; keyId: string } | null

Parse a server kid (canonical-domain "#" key-id, 04 §6.4) into its parts, or null if malformed.

kid: string

Source: crypto/jws.ts:114

parseStrictJson function

function parseStrictJson(bytes: Uint8Array, field: string, maxDepth?: number): StrictJsonResult

Parse UTF-8 bytes as I-JSON (RFC 7493) as 04 §6.5 requires: fatal on invalid UTF-8, lone surrogates in any string or member name, duplicate member names, numbers that aren't finite doubles, and nesting deeper than maxDepth (the top-level value is depth 1). Throws crypto.malformed with reason json or depth, and data.field.

bytes: Uint8Array
field: string
maxDepth: number

Default: JWS_MAX_PAYLOAD_DEPTH

Source: crypto/jws.ts:167

parseSvDeviceCredential function

function parseSvDeviceCredential(credential: Uint8Array): SvDeviceCredential

Parse an MLS Credential (07 §10.1, §10.4 steps 1 and 2): fails wrong_credential_type unless credential_type is 0xF5A0, and malformed on a non-minimal or out-of-range vector length, a byte outside base64url and ., or trailing bytes.

credential: Uint8Array

Source: crypto/identity.ts:1003

parseVerifyQr function

function parseVerifyQr(text: string): VerifyQrPayload | null

Decode a scanned VerifyQR text (07 §17.2 scanning check 1). Returns null when the text doesn't start with SVV1:, doesn't decode, has a version other than 1, a bad length or trailing bytes, or an address that isn't valid UTF-8.

text: string

Source: crypto/safety-number.ts:127

parseX25519Jwk function

function parseX25519Jwk(jwk: unknown, opts?: ParseJwkOptions): Uint8Array

Parse an X25519 public JWK (the DeviceCertificate dbk claim, 04 §5.1 rule 5, 07 §4.1): exactly kty = "OKP", crv = "X25519" and x, 32 bytes. The Ed25519 checks of 04 §4.3 don't apply.

jwk: unknown
opts: ParseJwkOptions

Default: {}

Source: crypto/jwk.ts:84

pinAcceptsKey function

function pinAcceptsKey(pin: PinRecord, ik: Uint8Array): boolean

The pin check of 07 §14.2 D3, after 07 §16.4 has run on every newer verified state: true when ik (32 bytes) is the pin's key or, in verified_blocked, its pending key.

ik: Uint8Array

Source: crypto/identity.ts:1274

planShareRanges function

function planShareRanges<T extends { seq: number }>(items: readonly T[], maxItems?: number): ({ fromSeq: number; toSeq: number; items: T[] })[]

Split a selection of sealed items into share ranges (14 §7.3): adjacent, non-overlapping ranges of at most maxItems (5,000) selected items each, newest first. The oldest range starts at its oldest item; every newer range starts right after the next older range ends. A range may also hold sealed items that weren't selected; the server counts those too (14 §7.7 step 9), so pass a smaller maxItems when the timeline is sparse in selected items. The caller still splits a share whose body would exceed maxRequestBytes.

items: readonly T[]
maxItems: number

Default: HISTORY_LIMITS.maxShareItems

Source: crypto/history-share.ts:429

precheckSealedPost function

function precheckSealedPost(s: SealedMessage, carrier: SealedCarrier, opts: { sessionDid: string; maxMessageBytes?: number }): SealedPrecheckProblem | null

Mirror the server's local checks of 14 §5.2 before posting: step 5 (shape and size), step 6 (binding to the carrier, naming the first member that differs), step 8 (device), and step 12's kind and ref-presence rules. Returns null when the post would pass them. Membership, freeze, epoch and signature (steps 9 to 11, 13) need server state.

carrier: SealedCarrier
opts: { sessionDid: string; maxMessageBytes?: number }

Source: crypto/sealed.ts:640

removePinVerification function

function removePinVerification(pin: PinRecord, nowMs?: number): IdentityPinUpdate

"Remove verification" (07 §17.3): verified → pinned. Never raises W2.

nowMs: number

Source: crypto/identity.ts:1471

resolveEkidMismatch function

function resolveEkidMismatch(entry: { source: HistoryKeySource; ekid: Uint8Array }, reference: Uint8Array<ArrayBufferLike> | null, ackMatched?: boolean): EkidMismatchAction

The decision table of 14 §6.6 for a SealedMessage whose signature verified but whose ekid differs from the key-store entry's. reference is the settled reference ekid of (gen, epoch), or null when unknown or only provisional; ackMatched is true when this device's epoch-ack for that epoch was answered 200 match (13 §7.8). In every case the client also sends the sealed_verify diagnostic with step ekid (14 §9.4).

entry: { source: HistoryKeySource; ekid: Uint8Array }
reference: Uint8Array<ArrayBufferLike> | null
ackMatched: boolean

Default: false

Source: crypto/sealed.ts:548

roundUp256 function

function roundUp256(n: number): number

The smallest multiple of 256 that is at least n (14 §4.5).

n: number

Source: crypto/sealed.ts:144

safetyFingerprint function

function safetyFingerprint(ik: Uint8Array, addr: string): Promise<string>

Fingerprint(ik, addr) of 07 §17.1: h ← "sv1 safety" || 0x00 || u16(1) || ik || addr, then 5,200 rounds of h ← SHA-512(h || ik), then six 5-digit groups from uint40_be(h[5j..5j+4]) mod 100000. Returns 30 decimal digits. addr is the canonical address (UTF-8).

ik: Uint8Array
addr: string

Source: crypto/safety-number.ts:41

safetyNumber function

function safetyNumber(a: SafetyNumberParty, b: SafetyNumberParty): Promise<string>

SafetyNumber(A, B) of 07 §17.1: the two fingerprints sorted as 30-character strings and concatenated, 60 digits. Both people see the same number. It changes when either identity key changes, never when a device is added or removed.

Source: crypto/safety-number.ts:66

sealedHeaderOf function

function sealedHeaderOf(s: SealedMessage, host: string, sender: string): Uint8Array

Build the SealedHeader of a received SealedMessage for host and sender (14 §4.4, §6.3 step 5).

host: string
sender: string

Source: crypto/sealed.ts:259

sealedSendAction function

function sealedSendAction(error: unknown): SealedSendAction

Map a failed SealedMessage post to the sender's next step (14 §4.7 steps 10 to 13).

error: unknown

Source: crypto/sealed.ts:695

sealedSigContent function

function sealedSigContent(header: Uint8Array, ct: Uint8Array): Uint8Array

SealedSigContent = SealedHeader || u32(len(ct)) || ct (14 §4.6).

header: Uint8Array
ct: Uint8Array

Source: crypto/sealed.ts:132

sealMessage function

function sealMessage(p: SealParams): Promise<SealedMessage>

Seal one piece of content (14 §4.7 steps 3 to 8): derive ekid, K_msg and kc, pad the content JSON to 256 bytes, encrypt with AES-256-GCM under the SealedHeader, and sign with the labelled signature sealed. Never encrypts twice under one K_msg: a retry in the same (gen, epoch) MUST resend the stored result, not call this again (14 §3.3).

Source: crypto/sealed.ts:327

sha256 function

function sha256(data: Uint8Array): Promise<Uint8Array<ArrayBufferLike>>

SHA-256 (FIPS 180-4) (04 §2.1).

data: Uint8Array

Source: crypto/primitives.ts:307

sha256Base64Url function

function sha256Base64Url(bytes: Uint8Array): Promise<string>

base64url SHA-256 of bytes, as AttachmentRef, ThumbnailRef and Attachment sha256 carry it (11 §3.6, §14.1).

bytes: Uint8Array

Source: crypto/attachments.ts:548

sha512 function

function sha512(data: Uint8Array): Promise<Uint8Array<ArrayBufferLike>>

SHA-512 (FIPS 180-4) (04 §2.1).

data: Uint8Array

Source: crypto/primitives.ts:312

sharedKeyParts function

function sharedKeyParts(bundleItems: readonly ShareItem[], verified: ReadonlySet<string>): ({ part: number; items: ShareItem[] })[]

Split a bundle's verified keys into shared_keys record parts (14 §12.7 rule 1): part p holds the verified keys among the bundle's items at positions 32p to 32p + 31, in the bundle's mid16 order. verified holds the mids that passed verifySharedItem. Parts whose keys all failed are omitted.

bundleItems: readonly ShareItem[]
verified: ReadonlySet<string>

Source: crypto/history-share.ts:411

shareSigContent function

function shareSigContent(header: Uint8Array, ct: Uint8Array): Uint8Array

ShareSigContent = ShareHeader || u32(len(ct)) || ct (14 §7.5).

header: Uint8Array
ct: Uint8Array

Source: crypto/history-share.ts:128

signEd25519 function

function signEd25519(signer: Ed25519Signer, message: Uint8Array, opts?: { selfVerify?: boolean }): Promise<Uint8Array<ArrayBufferLike>>

Sign message with pure Ed25519 (04 §4.2 item 1). With selfVerify, the signature is checked with 04 §4.3 before it is returned, as 04 §4.2 item 2 recommends for long-lived objects; a failure throws crypto.bad_signature.

message: Uint8Array
opts: { selfVerify?: boolean }

Default: {}

Source: crypto/ed25519.ts:474

signJws function

function signJws(input: SignJwsInput): Promise<string>

Create a compact JWS of a registered type (04 §6.7). The header is serialized as {"alg":"EdDSA","typ":…,"kid":…} with no white space (04 §6.2 item 3). Before signing, the payload is checked against the profile (I-JSON, iat, exp/nbf rules and lifetime, aud not an array) so that the SDK never produces an object a verifier must reject; afterwards the size limit is checked (04 §6.7 step 5). Violations throw sdk.invalid_argument with the crypto.* code a verifier would give in data.cryptoCode.

Source: crypto/jws.ts:360

signJwsParts function

function signJwsParts(headerBytes: Uint8Array, payloadBytes: Uint8Array, signer: Ed25519Signer, opts?: { selfVerify?: boolean }): Promise<string>

Low-level compact JWS assembly (04 §6.1, §6.7 steps 3 and 4) over exact header and payload bytes, without any profile check. Intended for producing test vectors (for example V-3l and V-3m, which a verifier must reject); protocol objects use signJws.

headerBytes: Uint8Array
payloadBytes: Uint8Array
opts: { selfVerify?: boolean }

Default: {}

Source: crypto/jws.ts:409

signLabelled function

function signLabelled(signer: Ed25519Signer, label: string & {} | "test" | "sealed" | "history-share" | "history-link" | "media-attest" | "vault-box-key" | "vault-generation", content: Uint8Array, opts?: LabelledOptions & { selfVerify?: boolean }): Promise<Uint8Array<ArrayBufferLike>>

SignLabelled(key, label, content) (04 §7.1). Only DSKs make labelled signatures in v1 (04 §7.1 item 4); the caller passes the DSK's signer. Returns the 64-byte signature (base64url of it is the JSON form, 04 §7.1 item 3).

label: string & {} | "test" | "sealed" | "history-share" | "history-link" | "media-attest" | "vault-box-key" | "vault-generation"
content: Uint8Array
opts: LabelledOptions & { selfVerify?: boolean }

Default: {}

Source: crypto/labelled.ts:99

signWithIdentityKey function

function signWithIdentityKey(identityKey: Ed25519Signer, typ: IdentityKeyJwsType, claims: Record<string, unknown>): Promise<string>

The identity-key signing interface of 07 §3.3: it accepts only the three identity-key types and builds the header itself (alg EdDSA, the type, kid = thumb(ik)). Payload members are serialized in the order given. Long-lived objects are self-verified before they are returned (04 §4.2 item 2).

identityKey: Ed25519Signer
claims: Record<string, unknown>

Source: crypto/identity.ts:1092

sortAddresses function

function sortAddresses(addrs: Iterable<string>): string[]

Sort addresses in byte-wise order (12 §2.2), returning a new array.

addrs: Iterable<string>

Source: crypto/dm-id.ts:48

storeCoversDevice function

function storeCoversDevice(entry: VerifierStoreEntry | undefined, did: string): boolean

True if the store holds a verified DeviceRevocation for (sub, did) (07 §9 condition (c)).

entry: VerifierStoreEntry | undefined
did: string

Source: crypto/identity.ts:536

subtleCrypto function

function subtleCrypto(): SubtleCrypto

The platform's crypto.subtle. Throws sdk.not_implemented when the runtime has no WebCrypto (the SDK has no fallback implementations of the 04 §2.1 primitives, 04 §14.6).

Source: crypto/primitives.ts:169

svf1BlobSize function

function svf1BlobSize(fileSize: number): number

The blob size for a file of fileSize bytes: 43 + P + 16·n with P = pad(fileSize + 8) (04 §10.4).

fileSize: number

Source: crypto/attachments.ts:96

svf1Decrypt function

function svf1Decrypt(blob: Uint8Array, fileKey: Uint8Array): Promise<Uint8Array<ArrayBufferLike>>

Decrypt a whole SVF1 blob (04 §10.6) with K_file and return the file. Failures are crypto.decrypt_failed with reason format, commitment, tag or padding; nothing is returned on failure.

blob: Uint8Array
fileKey: Uint8Array

Source: crypto/attachments.ts:504

svf1DecryptStream function

function svf1DecryptStream(source: AsyncIterable<Uint8Array<ArrayBufferLike>, any, any> | Iterable<Uint8Array<ArrayBufferLike>, any, any>, blobBytes: number, fileKey: Uint8Array): AsyncGenerator<Uint8Array<ArrayBufferLike>>

Decrypt an SVF1 blob from a stream of its bytes (04 §10.6), yielding the file's bytes segment by segment as each tag verifies. The padding check of step 6 completes only after the last segment: if the iteration throws, the consumer MUST discard everything it received (04 §10.6), and a saved file is complete only after verifyAttachmentFile also passes.

source: AsyncIterable<Uint8Array<ArrayBufferLike>, any, any> | Iterable<Uint8Array<ArrayBufferLike>, any, any>
blobBytes: number
fileKey: Uint8Array

Source: crypto/attachments.ts:425

svf1Encrypt function

function svf1Encrypt(file: Uint8Array, opts?: Svf1EncryptOptions): Promise<Svf1Encrypted>

Encrypt a whole file with SVF1 (04 §10.5) under a fresh K_file, and hash both the file (for the reference's sha256) and the blob (for the upload's sha256), as 11 §14.3 steps 1 to 4 need.

file: Uint8Array
opts: Svf1EncryptOptions

Default: {}

Source: crypto/attachments.ts:316

svf1EncryptStream function

function svf1EncryptStream(fileSize: number, source: AsyncIterable<Uint8Array<ArrayBufferLike>, any, any> | Iterable<Uint8Array<ArrayBufferLike>, any, any>, opts?: Svf1EncryptOptions): Promise<Svf1EncryptionStream>

Start a streaming SVF1 encryption of a file of fileSize bytes read from source (04 §10.5): the header and each segment ciphertext are produced as soon as their plaintext is available, so upload can start at once (04 §10.8). The source must yield exactly fileSize bytes. The upload request needs the blob's SHA-256 up front (11 §14.2), so a caller that streams must hash the chunks itself; svf1Encrypt does both for a buffer.

fileSize: number
source: AsyncIterable<Uint8Array<ArrayBufferLike>, any, any> | Iterable<Uint8Array<ArrayBufferLike>, any, any>
opts: Svf1EncryptOptions

Default: {}

Source: crypto/attachments.ts:284

svf1Layout function

function svf1Layout(blobBytes: number): Svf1Layout | null

The layout of a blob of blobBytes bytes, or null if it is shorter than a header (04 §10.6).

blobBytes: number

Source: crypto/attachments.ts:122

svf1Nonce function

function svf1Nonce(noncePrefix: Uint8Array, index: number, final: boolean): Uint8Array

N_i = nonce_prefix || u32(i) || u8(f) (04 §10.4).

noncePrefix: Uint8Array
index: number
final: boolean

Source: crypto/attachments.ts:192

svf1Pad function

function svf1Pad(n: number): number

The SVF1 padding function pad(n) (04 §10.3): 4,096 up to 4 KiB; the next power of two up to 64 KiB; above that, eight buckets per doubling (ceil(n / 2^(k−3)) · 2^(k−3) where 2^k < n ≤ 2^(k+1)).

n: number

Source: crypto/attachments.ts:75

svf1SegmentCount function

function svf1SegmentCount(padded: number): number

Number of segments for a padded length P: ceil(P / 65536) (04 §10.4).

padded: number

Source: crypto/attachments.ts:90

svf1Size function

function svf1Size(maxFileBytes: number): number

The largest blob for a plaintext limit M: svf1Size(M) (04 §10.7). A secure-context blob may be up to svf1Size(maxAttachmentBytes) (11 §2.3, §14.6); for the default 25 MiB that is 27,269,675.

maxFileBytes: number

Source: crypto/attachments.ts:107

thumbprintInput function

function thumbprintInput(publicKey: Uint8Array, crv?: "Ed25519" | "X25519"): string

The RFC 7638 thumbprint input of an OKP key: {"crv":…,"kty":"OKP","x":…} with the required members in lexicographic order and no white space (04 §5.2). Built from the raw bytes, never from a received x string (04 §5.2 item 1).

publicKey: Uint8Array
crv: "Ed25519" | "X25519"

Default: 'Ed25519'

Source: crypto/jwk.ts:107

trustedKeyOfPin function

function trustedKeyOfPin(pin: PinRecord): string | undefined

The key the client trusts for the contact (07 §17.1): pendingIk in state verified_blocked, otherwise ik. Used for safety numbers and QR codes. Undefined when the record holds no key.

Source: crypto/identity.ts:1266

u16 function

function u16(n: number): Uint8Array

u16(n): big-endian, 2 bytes (04 §1.3).

n: number

Source: crypto/primitives.ts:241

u32 function

function u32(n: number): Uint8Array

u32(n): big-endian, 4 bytes (04 §1.3).

n: number

Source: crypto/primitives.ts:247

u64 function

function u64(n: number | bigint): Uint8Array

u64(n): big-endian, 8 bytes (04 §1.3). Accepts a safe integer or a bigint below 2^64.

n: number | bigint

Source: crypto/primitives.ts:253

u8 function

function u8(n: number): Uint8Array

u8(n): one byte (04 §1.3).

n: number

Source: crypto/primitives.ts:235

uniformRandomInt function

function uniformRandomInt(n: number, random?: RandomSource): number

Draw an integer uniformly from 0 to n − 1 with the rejection method of 04 §13 item 5 (for example n = 1,000,000 for a pairing code). n must be between 1 and 2^32.

n: number
random: RandomSource

Default: cryptoRandomBytes

Source: crypto/primitives.ts:201

utf8 function

function utf8(s: string): Uint8Array

The UTF-8 bytes of a string (04 §1.3 "text": no terminator and no length prefix).

s: string

Source: crypto/primitives.ts:217

validateSvDeviceCredential function

function validateSvDeviceCredential(credential: Uint8Array<ArrayBufferLike> | SvDeviceCredential, signatureKey: Uint8Array, opts?: IdentityVerifyOptions): Promise<ValidatedSvDeviceCredential>

ValidateSvDeviceCredential(credential, signature_key) of 07 §10.4, the local check that needs no network: credential type, encoding, both certificates and signature_key == dsk. The canonical-address check 6 of sub is completed by the context (07 §4.2).

credential: Uint8Array<ArrayBufferLike> | SvDeviceCredential
signatureKey: Uint8Array
opts: IdentityVerifyOptions

Default: {}

Source: crypto/identity.ts:1048

verifyAttachmentFile function

function verifyAttachmentFile(file: Uint8Array, ref: { size: number; sha256?: string }): Promise<void>

Check a decrypted (or, in an insecure context, downloaded) file against the signed size and sha256 of its AttachmentRef or ThumbnailRef (11 §14.3 receiver step 3). Throws crypto.decrypt_failed with reason: "content_hash" on a mismatch. A missing sha256 (insecure references only) checks the size alone.

file: Uint8Array
ref: { size: number; sha256?: string }

Source: crypto/attachments.ts:520

verifyDeviceCertificate function

function verifyDeviceCertificate(jws: string, idc: IdentityCertificateTuple, opts?: IdentityVerifyOptions): Promise<VerifiedDeviceCertificate>

VerifyDeviceCertificate(jws, idc) of 07 §6.3, steps 1 to 11 in order. Throws IdentityCheckError with malformed, typ_mismatch, key_mismatch, bad_signature, subject_mismatch, generation_mismatch, identity_key_as_leaf or kind_mismatch.

jws: string
opts: IdentityVerifyOptions

Default: {}

Source: crypto/identity.ts:342

verifyDeviceRevocation function

function verifyDeviceRevocation(jws: string, idc: IdentityCertificateTuple, opts?: IdentityVerifyOptions): Promise<VerifiedDeviceRevocation | null>

VerifyDeviceRevocation(jws, idc) of 07 §8.3 with idc from the same IdentityState. Returns null when the revocation's igen differs from idc.igen (step 2: it can't be verified with the current key and is ignored, not an error). Throws IdentityCheckError with malformed, typ_mismatch, key_mismatch, bad_signature or subject_mismatch.

Only a revocation inside a verified IdentityState's revoked[].rev is evidence (07 §8.2 rule 3); verifyIdentityState calls this for each one.

jws: string
opts: IdentityVerifyOptions

Default: {}

Source: crypto/identity.ts:418

verifyDmContextId function

function verifyDmContextId(ctx: string, a: string, b: string): Promise<boolean>

Whether ctx is the dm: reference of the pair a, b (12 §5.2). Hosting servers and recipient homes recompute it on every request (12 §5.2, §8.4 step 3); a client can do the same before trusting a DmIndexEntry or a DmRequest. A malformed ctx gives false.

ctx: string
a: string
b: string

Source: crypto/dm-id.ts:148

verifyEd25519 function

function verifyEd25519(publicKey: Uint8Array, message: Uint8Array, signature: Uint8Array, opts?: Ed25519VerifyOptions): Promise<boolean>

Strict Ed25519 verification (04 §4.3). Resolves true only if every rule holds.

publicKey: Uint8Array
message: Uint8Array
signature: Uint8Array
opts: Ed25519VerifyOptions

Default: {}

Source: crypto/ed25519.ts:348

verifyHmacSha256 function

function verifyHmacSha256(key: Uint8Array, message: Uint8Array, tag: Uint8Array): Promise<boolean>

Check an HMAC-SHA256 tag, possibly truncated (never below 16 bytes, 04 §8.2 item 2), in constant time (04 §8.2 item 3, §14.4).

key: Uint8Array
message: Uint8Array
tag: Uint8Array

Source: crypto/hkdf.ts:27

verifyIdentityCertificate function

function verifyIdentityCertificate(jws: string, opts?: IdentityVerifyOptions): Promise<VerifiedIdentityCertificate>

VerifyIdentityCertificate(jws) of 07 §5.3, steps 1 to 8 in order. The certificate proves nothing alone; it counts when a verified IdentityState names it in idc or a pin holds its key. Throws IdentityCheckError with malformed, typ_mismatch, bad_signature or non_canonical.

jws: string
opts: IdentityVerifyOptions

Default: {}

Source: crypto/identity.ts:267

verifyIdentityState function

function verifyIdentityState(jws: string, opts: VerifyIdentityStateOptions): Promise<VerifiedIdentityState>

VerifyIdentityState(jws, expectedSub) of 07 §7.4, steps 1 to 11 in order, including the comparison with the verifier store (step 9) and its update (step 11) when opts.store is given.

Throws IdentityCheckError with malformed, typ_mismatch, subject_mismatch, non_canonical, issuer_mismatch, bad_signature, state_stale (with data.stale = expired, future or lifetime; an expired state from an event is refetched, 07 §12.3), the IdentityCertificate's result, generation_mismatch, state_rollback or state_equivocation (keep the stored state and report a diagnostic, 07 §13.6).

jws: string

Source: crypto/identity.ts:725

verifyJws function

function verifyJws<P = Record<string, unknown>>(compact: string, opts: VerifyJwsOptions): Promise<VerifiedJws<P>>

Verify a compact JWS that the context expects to be of type opts.typ, with every step of 04 §6.8 (1 to 11) in this order: size before any decoding, three parts, canonical base64url, header (≤ 1,024 bytes, I-JSON, exactly alg/typ/kid as strings), alg = EdDSA, typ, kid form, payload (I-JSON, no duplicates, ≤ 8 levels), key selection from the context only (04 §6.4) with the 04 §4.3 key checks, strict Ed25519 signature, then aud and time claims (04 §6.5 item 4, §6.6). Owner claim checks (step 12) are the caller's.

Failures throw SloppyVoiceError with the crypto.* code of the 04 §6.8 table. Owners that answer with their own codes (06, 07, …) map these.

compact: string

Source: crypto/jws.ts:574

verifyLabelled function

function verifyLabelled(publicKey: Uint8Array, label: string & {} | "test" | "sealed" | "history-share" | "history-link" | "media-attest" | "vault-box-key" | "vault-generation", content: Uint8Array, signature: Uint8Array, opts?: LabelledOptions & Ed25519VerifyOptions): Promise<boolean>

VerifyLabelled (04 §7.1) returning a boolean instead of throwing.

publicKey: Uint8Array
label: string & {} | "test" | "sealed" | "history-share" | "history-link" | "media-attest" | "vault-box-key" | "vault-generation"
content: Uint8Array
signature: Uint8Array

Source: crypto/labelled.ts:127

verifyRevealedKey function

function verifyRevealedKey(s: SealedMessage, kMsg: Uint8Array, opts: { host: string; sender: string; publicKeys: readonly Uint8Array<ArrayBufferLike>[]; checkContent?: (kind: string, ref: string | undefined, content: Record<string, unknown>) => boolean }): Promise<RevealedKeyResult>

Verify a revealed K_msg against a SealedMessage as a report verifier does (14 §13.2 steps 4 to 8), which is also how a HistoryShare recipient verifies each shared key (14 §7.8 step 5): the sealed signature under one of the sender's acceptable DSKs (14 §6.2), then kc in constant time, then AES-256-GCM with the SealedHeader, then the content checks. publicKeys empty gives credential_invalid (step 3 found no acceptable record).

kMsg: Uint8Array
opts: { host: string; sender: string; publicKeys: readonly Uint8Array<ArrayBufferLike>[]; checkContent?: (kind: string, ref: string | undefined, content: Record<string, unknown>) => boolean }

Source: crypto/sealed.ts:575

verifySealedSignature function

function verifySealedSignature(s: SealedMessage, opts: { host: string; sender: string; publicKey: Uint8Array }): Promise<boolean>

Verify a SealedMessage's sealed labelled signature under one DSK, with the SealedHeader built from the hosting server's canonical domain and the sender's canonical address (14 §4.6, §6.3 step 6).

opts: { host: string; sender: string; publicKey: Uint8Array }

Source: crypto/sealed.ts:281

verifySharedItem function

function verifySharedItem(sealed: SealedMessage, kMsg: Uint8Array, opts: { host: string; sender: string; senderKeys: readonly Uint8Array<ArrayBufferLike>[]; checkContent?: (kind: string, ref: string | undefined, content: Record<string, unknown>) => boolean }): Promise<RevealedKeyResult>

Verify one shared key against its stored SealedMessage (14 §7.8 step 5), as a report verifier does (14 §13.2 steps 3 to 7): the sender's signature under one of senderKeys (credential records are allowed here), kc in constant time, AES-256-GCM, and the content checks. An entry that fails is dropped, its item stays unavailable, and the client sends the history_share diagnostic with step item.

kMsg: Uint8Array
opts: { host: string; sender: string; senderKeys: readonly Uint8Array<ArrayBufferLike>[]; checkContent?: (kind: string, ref: string | undefined, content: Record<string, unknown>) => boolean }

Source: crypto/history-share.ts:392

wipe function

function wipe(bytes: Uint8Array<ArrayBufferLike> | null | undefined): void

Best-effort erasure of a secret held in a mutable byte array (04 §14.3 items 1 and 2).

bytes: Uint8Array<ArrayBufferLike> | null | undefined

Source: crypto/primitives.ts:294

withinEpochGrace function

function withinEpochGrace(p: { epoch: number; currentEpoch: number; lastCommitChangedLeaves: boolean; msSinceCommit: number }): boolean

The epoch grace window of 14 §5.3: the server accepts epoch == E, or epoch == E − 1 when the commit that created E neither added nor removed a leaf and at most sealedGraceMs (30 s) have passed since it was sequenced.

p: { epoch: number; currentEpoch: number; lastCommitChangedLeaves: boolean; msSinceCommit: number }

Source: crypto/sealed.ts:660

x25519 function

function x25519(privateKey: CryptoKey, publicKey: Uint8Array): Promise<Uint8Array<ArrayBufferLike>>

X25519(sk, pk) (RFC 7748 §5) through WebCrypto. Rejects an all-zero output, which a small-order peer key produces (RFC 7748 §6.1, RFC 9180 §7.1.4); the failure is crypto.decrypt_failed (format) for HPKE callers.

privateKey: CryptoKey
publicKey: Uint8Array

Source: crypto/hpke.ts:87

x25519PublicKeyToJwk function

function x25519PublicKeyToJwk(publicKey: Uint8Array): X25519PublicJwk

The JWK of a raw 32-byte X25519 public key, for the DeviceCertificate dbk claim (04 §5.1 rule 5).

publicKey: Uint8Array

Source: crypto/jwk.ts:97

Interfaces

AeadSealed interface

A sealed AES-256-GCM message: the random nonce and ciphertext || tag (04 §9.1 item 1).

interface AeadSealed

nonce

nonce: Uint8Array

12 bytes from the CSPRNG (04 §9.2 item 1).

ciphertext

ciphertext: Uint8Array

Ciphertext followed by the 16-byte tag.

Source: crypto/aead.ts:76

CreateHistoryShareParams interface

Inputs of createHistoryShare.

interface CreateHistoryShareParams

host

host: string

Canonical domain of the hosting server.

ctx

ctx: string

sharer

sharer: string

Canonical address of the sharing account.

did

did: string

The sharing device (must have a leaf in the current group).

recipient

recipient: string

Canonical address of the recipient account.

fromSeq

fromSeq: number

toSeq

toSeq: number

items

items: readonly ShareItem[]

The keys of the items the client opened with outcome ok (14 §7.6 step 4).

devices

devices: readonly ShareRecipientDevice[]

Every device of the recipient with a leaf in the current group and a valid dbk (14 §7.6 step 5).

signer

signer: Ed25519Signer

The sharing device's DSK.

shareId?

shareId?: string

UUIDv7; a fresh one is generated when absent (14 §7.6 step 5). A retry resends the kept body instead of calling this again (14 §7.6 step 6); a rebuilt share after an error gets a new one (step 7).

random?

random?: RandomSource

CSPRNG for K_share and the nonce (tests only).

seal?

seal?: (recipientPublicKey: Uint8Array, info: Uint8Array, plaintext: Uint8Array) => Promise<HpkeSealed>

HPKE SealBase with the sv1 suite; injectable so test vectors can fix the ephemeral key.

Source: crypto/history-share.ts:204

CryptoErrorInfo interface

The registry row of a crypto.* code: HTTP status, retryable and userAction (04 §15.1, §15.2).

interface CryptoErrorInfo

title

readonly title: string

status

readonly status: number

HTTP status, or 0 for local diagnostic codes (04 §15.2), which never travel.

retryable

readonly retryable: boolean

userAction

readonly userAction: "none" | "retry" | "update_app"

Source: crypto/primitives.ts:107

DecodedSealed interface

The binary members of a SealedMessage, decoded after the shape check.

interface DecodedSealed

ekid

ekid: Uint8Array

did

did: Uint8Array

nonce

nonce: Uint8Array

kc

kc: Uint8Array

ct

ct: Uint8Array

sig

sig: Uint8Array

Source: crypto/sealed.ts:196

DecodeFieldOptions interface

Options of decodeCryptoField.

interface DecodeFieldOptions

field?

field?: string

The member or object name reported in data.field.

length?

length?: number | readonly [number, number]

Exact decoded length the field requires (04 §3.4), or [min, max] inclusive.

Source: crypto/primitives.ts:337

DomainSeparationInfo interface

One row of the domain-separation registry for hashes, HPKE and CPace (04 §8.5).

interface DomainSeparationInfo

primitive

readonly primitive: "SHA-256" | "SHA-512 iterated" | "HPKE info" | "CPace channel identifier" | "CPace associated data"

input

readonly input: string

use

readonly use: string

owner

readonly owner: string

Source: crypto/hkdf.ts:139

Ed25519KeyPair interface

An Ed25519 key pair whose private key is a WebCrypto key (possibly non-extractable, 04 §14.2).

interface Ed25519KeyPair extends Ed25519Signer

publicKey

readonly publicKey: Uint8Array

The raw 32-byte public key.

privateKey

readonly privateKey: CryptoKey

sign

sign(message: Uint8Array): Promise<Uint8Array<ArrayBufferLike>>

Sign the exact message bytes. Deterministic, no context string (04 §4.2 item 1).

message: Uint8Array

Source: crypto/ed25519.ts:387

Ed25519PublicJwk interface

An Ed25519 public key as an OKP JWK (RFC 7517, RFC 8037) with the members of 04 §5.1.

interface Ed25519PublicJwk

kty

kty: "OKP"

crv

crv: "Ed25519"

x

x: string

base64url of the 32-byte public key, canonical (04 §3.1).

Source: crypto/jwk.ts:10

Ed25519Signer interface

Something that makes pure Ed25519 signatures (RFC 8032 §5.1.6) with one key (04 §4.2).

interface Ed25519Signer

publicKey

readonly publicKey: Uint8Array

The raw 32-byte public key.

sign

sign(message: Uint8Array): Promise<Uint8Array<ArrayBufferLike>>

Sign the exact message bytes. Deterministic, no context string (04 §4.2 item 1).

message: Uint8Array

Source: crypto/ed25519.ts:379

Ed25519VerifyOptions interface

Options of verifyEd25519.

interface Ed25519VerifyOptions

implementation?

implementation?: "auto" | "portable"

Which implementation checks items 3 and 7. 'auto' (the default) uses crypto.subtle.verify only when ed25519SelfTest passed on this platform, and the portable cofactorless check otherwise (04 §4.3 "Web clients"). 'portable' always uses the bundled BigInt equation.

Source: crypto/ed25519.ts:254

FreshnessOptions interface

Options of isStateFresh and isDeviceValid.

interface FreshnessOptions

now?

now?: number | Date

NumericDate seconds or Date; defaults to the system clock.

at?

at?: number | Date

For dm_admission: test freshness at time t instead of now (a commit's server timestamp, 07 §14.2 D4). For unexpired: likewise (a commit's ts, 07 §13.6 S2).

validatedAt?

validatedAt?: number | null

For channel_as: the validated-at time in ms (07 §13.1).

localNowMs?

localNowMs?: number

For channel_as: the verifier's own clock in ms; defaults to Date.now().

Source: crypto/identity.ts:864

GroupLeafIdentity interface

One leaf of an MLS tree for the group-level checks of 07 §10.5.

interface GroupLeafIdentity

sub

sub: string

sub of the leaf's credential.

did

did: string

did of the leaf's DeviceCertificate.

ik

ik: Uint8Array

The identity key of the leaf's IdentityCertificate (32 bytes).

signatureKey

signatureKey: Uint8Array

The leaf's signature_key (32 bytes).

identityCertificate

identityCertificate: string

The leaf's IdentityCertificate JWS, exactly as carried.

pendingRemoval?

pendingRemoval?: boolean

True when the hosting server has proposed to remove this leaf (a Remove proposal pending in the current epoch, or reissued after an external commit); such leaves are exempt from L5.

Source: crypto/identity.ts:1705

GroupLeafRuleFailure interface

A failed group-level leaf rule: the identity check result and the index of the offending leaf.

interface GroupLeafRuleFailure

reason

reason: "identity_key_as_leaf" | "duplicate_device_leaf" | "mixed_identity"

index

index: number

Source: crypto/identity.ts:1724

HistoryKeyRef interface

A history key as the key store returns it (14 §3.7).

interface HistoryKeyRef

key

key: Uint8Array

K_hist, 32 bytes.

ekid?

ekid?: Uint8Array<ArrayBufferLike>

Its ekid; derived from key when absent.

source?

source?: HistoryKeySource

Source: crypto/sealed.ts:379

HpkeSealed interface

The output of hpkeSeal: the 32-byte encapsulated key and ciphertext || tag (04 §9.8 item 5).

interface HpkeSealed

enc

enc: Uint8Array

ciphertext

ciphertext: Uint8Array

Source: crypto/hpke.ts:144

IdentityCertificateTuple interface

The identity-certificate tuple idc = (sub, ik, igen, kind) that device checks run under (07 §6.3).

interface IdentityCertificateTuple

sub

sub: string

ik

ik: Uint8Array

igen

igen: number

kind

kind: IdentityKind

Source: crypto/identity.ts:313

IdentityPinUpdate interface

The result of a pin transition.

interface IdentityPinUpdate

pin

pin: PinRecord

The updated record (a new object; the input is never mutated).

w2

w2: W2Alert | null

The W2 to show, or null.

changed

changed: boolean

True when the record changed and must be written to the vault (07 §16.4 step 4).

Source: crypto/identity.ts:1213

IdentityStateKeyRequest interface

The server key named by an IdentityState kid (07 §7.4 step 6).

interface IdentityStateKeyRequest

kid

kid: string

The full kid, <domain>#<keyId>.

domain

domain: string

keyId

keyId: string

Source: crypto/identity.ts:579

IdentityVerifyOptions interface

Options common to the identity verification functions.

interface IdentityVerifyOptions

now?

now?: number | Date

The verifier's current time: a NumericDate in seconds or a Date, corrected by the clock offset to the home server (04 §6.6). Defaults to the system clock.

isCanonical?

isCanonical?: CanonicalAddressCheck

Override for 01 §7.5 checks 1 to 5 (for example one that also runs check 6); defaults to canonicalAddressProblem.

Source: crypto/identity.ts:135

IgnoredRevocation interface

A diagnostic about a rev that failed and was ignored (07 §7.4 step 10).

interface IgnoredRevocation

did

did: string

reason

reason: IdentityCheckResult

Source: crypto/identity.ts:616

IssueDeviceCertificateInput interface

Input of issueDeviceCertificate.

interface IssueDeviceCertificateInput

identityKey

identityKey: Ed25519Signer

kind

kind: IdentityKind

The identity's kind, which fixes the plat rule (07 §6.1).

sub

sub: string

igen

igen: number

did

did: string

This device's own did (a device certifies only itself, 07 §6.2).

dsk

dsk: Uint8Array

This device's new DSK public key (32 bytes).

dbk

dbk: Uint8Array

This device's new box public key (X25519, 32 bytes).

plat

plat: DevicePlatform

iat

iat: number

Source: crypto/identity.ts:1131

IssueDeviceRevocationInput interface

Input of issueDeviceRevocation.

interface IssueDeviceRevocationInput

identityKey

identityKey: Ed25519Signer

sub

sub: string

igen

igen: number

did

did: string

The revoked device (any device of the account, including this one, 07 §8.2).

iat

iat: number

Source: crypto/identity.ts:1175

IssueIdentityCertificateInput interface

Input of issueIdentityCertificate.

interface IssueIdentityCertificateInput

identityKey

identityKey: Ed25519Signer

The new identity key (07 §3.1).

sub

sub: string

igen

igen: number

kind

kind: IdentityKind

iat

iat: number

NumericDate, from the clock corrected against the server (04 §6.6).

Source: crypto/identity.ts:1104

JwsHeader interface

The JWS protected header of 04 §6.2: exactly these three members.

interface JwsHeader

alg

alg: "EdDSA"

typ

typ: string

kid

kid: string

Source: crypto/jws.ts:84

JwsKeyContext interface

What a key resolver is told when the verifier needs the signing key (04 §6.4, §6.8 step 9).

interface JwsKeyContext

typ

typ: string

kid

kid: string

header

header: JwsHeader

payload

payload: Readonly<Record<string, unknown>>

The unauthenticated payload. Use it only to select the key (the issuer of a server-class type, or ik of an IdentityCertificate, 04 §6.10); never act on it (04 §6.8 item 2).

serverKid

serverKid: { domain: string; keyId: string } | null

For server-class types, the parsed kid; its domain already equals the issuer claim.

Source: crypto/jws.ts:424

JwsTypeInfo interface

One row of the typ registry (04 §6.3).

interface JwsTypeInfo

object

readonly object: string

The object this type carries.

signerClass

readonly signerClass: JwsSignerClass

Signer class, which fixes the kid form and key source (04 §6.4).

issuerClaim

readonly issuerClaim: "iss" | null

The payload claim whose value must equal the domain part of a server kid, or null.

exp

readonly exp: JwsExpRule

The exp rule (04 §6.6).

maxLifetimeSec

readonly maxLifetimeSec: number | null

Maximum exp − iat in seconds, or null where exp is forbidden (04 §6.3).

maxSize

readonly maxSize: number

Maximum length of the whole compact string in bytes (04 §6.3 item 1).

nbf

readonly nbf: boolean

Whether the owner defines nbf for this type (04 §6.6). No sv1 type does.

owner

readonly owner: string

Owning document.

Source: crypto/jws.ts:22

KdfLabelInfo interface

One row of the HKDF and HMAC label registry (04 §8.4).

interface KdfLabelInfo

primitive

readonly primitive: "HKDF-Expand" | "HMAC" | null

inputKey

readonly inputKey: string

The input key.

input

readonly input: string

The exact info or message layout.

outputLength

readonly outputLength: number | null

Output length in bytes before any truncation.

truncateTo?

readonly truncateTo?: number

Truncated length, where the registry allows truncation (04 §8.2 item 2).

use

readonly use: string

owner

readonly owner: string

retired

readonly retired: boolean

Source: crypto/hkdf.ts:103

LabelledOptions interface

Options of the labelled-signature functions.

interface LabelledOptions

allowUnregistered?

allowUnregistered?: boolean

Allow a label that matches the grammar but isn't in SIGNATURE_LABELS, for a label an owner has added in a "Registry additions" subsection before 04's next revision (04 §8.7).

allowTestLabel?

allowTestLabel?: boolean

Required to sign or verify with the test label, which no production verifier accepts (04 §7.3).

Source: crypto/labelled.ts:62

MlsExporterLabelInfo interface

One row of the MLS exporter label registry (04 §8.6).

interface MlsExporterLabelInfo

context

readonly context: "empty"

length

readonly length: number

output

readonly output: string

owner

readonly owner: string

Source: crypto/hkdf.ts:169

OpenHistoryShareOptions interface

Inputs of openHistoryShare.

interface OpenHistoryShareOptions

host

host: string

Canonical domain of the hosting server.

recipient

recipient: string

The recipient account's own canonical address (rebuilt into the ShareHeader, 14 §7.8 step 2).

sharer

sharer: string

The sharer's canonical address (the sharer member the server set).

did

did: string

This device's ID.

boxKey

boxKey: X25519KeyPair

This device's box key pair (08 §10.1).

sharerKeys

sharerKeys: () => readonly Uint8Array<ArrayBufferLike>[] | Promise<readonly Uint8Array<ArrayBufferLike>[]>

Candidate DSKs of (sharer, share.did), gathered as 14 §6.2 gathers a sender's.

Source: crypto/history-share.ts:299

OpenSealedOptions interface

Inputs of openSealed (14 §6.1).

interface OpenSealedOptions

ctx

ctx: string

The carrier's context.

host

host: string

Canonical domain of the hosting server.

sender

sender: string

The sender's canonical address (11's sender.addr).

historyKey?

historyKey?: (gen: number, epoch: number) => HistoryKeyRef | Promise<HistoryKeyRef | null> | null

Step 3: the key store (then the archive) lookup of K_hist for (host, ctx, gen, epoch).

sharedKey?

sharedKey?: (mid: string) => Uint8Array<ArrayBufferLike> | Promise<Uint8Array<ArrayBufferLike> | null> | null

Step 3: a shared message key for (host, ctx, mid), when no history key exists.

senderKeys

senderKeys: () => "pending" | readonly Uint8Array<ArrayBufferLike>[] | Promise<"pending" | readonly Uint8Array<…>[]>

Step 4: the sender's candidate DSK public keys, in the order and under the rules of 14 §6.2 (live leaf, local cache; credential records only for epochs this device wasn't in). Return 'pending' when the records can't be obtained yet.

fetchRecordKeys?

fetchRecordKeys?: () => Promise<"pending" | readonly Uint8Array<ArrayBufferLike>[]>

Step 6: credential-record DSKs to try if no candidate verified and records are allowed but weren't fetched yet. Never called when the history key has source mls: for an epoch this device was itself in, the sender's key MUST come from a leaf it validated (14 §6.2).

checkContent?

checkContent?: (kind: string, ref: string | undefined, content: Record<string, unknown>) => boolean

Step 10: the content checks of 11 for the kind. The SDK always checks that a named target equals ref (contentMatchesRef); this hook adds 11's schema checks (default: none).

Source: crypto/sealed.ts:388

OwnIdentityAlerts interface

The self-alerts one own IdentityState raises (07 §18.1, §18.3).

interface OwnIdentityAlerts

w4a

w4a: boolean

W4a: the identity was reset or turned off from elsewhere. Needs a tap; the device stops using its old keys.

w4c

w4c: DeviceEntry[]

W4c: devices newly listed in the same generation, other than this one and those it approved.

next

next: OwnIdentityState

The new local state to persist.

Source: crypto/identity.ts:1609

OwnIdentityForW4b interface

What a device knows about its own identity when it checks a roster for W4b (07 §18.2).

interface OwnIdentityForW4b

address

address: string

The own canonical address.

ik

ik: Uint8Array

The own current identity key K (32 bytes).

igen

igen: number

Its generation g.

state

state: Pick<IdentityStateClaims, "devices" | "revoked">

The latest own IdentityState the device accepted (07 §18.4).

revokedDids?

revokedDids?: ReadonlySet<string>

dids covered by a revocation the device knows about (verified DeviceRevocations, 07 §7.5).

Source: crypto/identity.ts:1659

OwnIdentityState interface

The local own-identity state each device keeps outside the vault (07 §18.4).

interface OwnIdentityState

ver

ver: number

igen

igen: number

sec

sec: "insecure" | "secure"

devices

devices: DeviceEntry[]

The device set of the last own IdentityState accepted.

approvedDids

approvedDids: ({ did: string; at: number })[]

dids whose pairing this device approved in the last 24 h, with the approval time in ms (07 §18.3).

raised

raised: string[]

W4 alerts already raised, as keys such as W4a:3 or W4c:<did>.

Source: crypto/identity.ts:1596

ParseJwkOptions interface

Options of parseEd25519Jwk.

interface ParseJwkOptions

field?

field?: string

The member name reported in data.field (for example "ik" or "dsk"). Default "jwk".

allowMembers?

allowMembers?: readonly string[] | "any"

Further non-key metadata members the owner allows (04 §5.1 rule 2), for example ['kid', 'purpose'] for a KeyRotation key (02). Omitted: the JWK must contain exactly kty, crv and x, as for ik and dsk (04 §5.1 rule 1). 'any' accepts any non-private member.

Source: crypto/jwk.ts:37

PinStore interface

Persistence for pin records (07 §16.1). Pins live in the AccountVault (08 §8.6.2) so every enrolled device sees the same ones; an implementation writes them as pin vault records.

interface PinStore

get

get(addr: string): PinRecord | Promise<PinRecord | undefined> | undefined
addr: string

set

set(pin: PinRecord): void | Promise<void>

Source: crypto/identity.ts:1226

RevocationCarrier interface

Where a verified DeviceRevocation came from: the IdentityState that carried it (07 §7.5).

interface RevocationCarrier

kid

kid: string

The kid of the IdentityState that carried it.

iat

iat: number

That state's iat.

acceptedAt

acceptedAt: number

The verifier's own clock (ms) when it accepted that state.

Source: crypto/identity.ts:449

RosterLeafIdentity interface

A leaf of a context roster, as validateSvDeviceCredential returns it.

interface RosterLeafIdentity

sub

sub: string

ik

ik: Uint8Array

igen

igen: number

did

did: string

Source: crypto/identity.ts:1673

SafetyNumberParty interface

One person's side of a safety number: the key the client trusts for them and their canonical address.

interface SafetyNumberParty

ik

ik: Uint8Array

For the contact, trustedKeyOfPin(pin) (07 §17.1); for the user, the own current identity key.

addr

addr: string

Source: crypto/safety-number.ts:55

SealedCarrier interface

The cleartext members of 11's posting body that a SealedMessage must match (14 §5.2 step 6).

interface SealedCarrier

ctx

ctx: string

The path's context.

mid

mid: string

kind

kind: string

target?

target?: string

The cleartext target; absent for message.

Source: crypto/sealed.ts:619

SealedHeaderFields interface

The fields of a SealedHeader (14 §4.4).

interface SealedHeaderFields

groupId

groupId: string

The MLS group_id string (sv1:host:ctx:gen, 13 §4.1).

sender

sender: string

Canonical address of the sending account.

did

did: string

mid

mid: string

epoch

epoch: number

ekid

ekid: Uint8Array

8 bytes.

kind

kind: string

ref?

ref?: string

Absent, or the target mid.

nonce

nonce: Uint8Array

12 bytes.

kc

kc: Uint8Array

16 bytes.

Source: crypto/sealed.ts:90

SealedPrecheckProblem interface

A problem the server would answer, as {code, data} (14 §5.2).

interface SealedPrecheckProblem

code

code: "message.too_large" | "sealed.invalid" | "sealed.header_mismatch" | "sealed.device_mismatch" | "sealed.kind_unsupported" | "sealed.ref_invalid"

data?

data?: Record<string, unknown>

Source: crypto/sealed.ts:629

SealParams interface

Inputs of sealMessage (14 §4.7).

interface SealParams

host

host: string

Canonical domain of the hosting server.

ctx

ctx: string

gen

gen: number

sender

sender: string

Canonical address of the sending account.

did

did: string

This device's ID.

mid

mid: string

The UUIDv7 mid, recorded in the outbox before the first attempt and reused for retries.

epoch

epoch: number

The device's current epoch.

kind

kind: string

ref?

ref?: string

Target mid, for edit, delete and reaction.

content

content: unknown

The content object of 11 (serialized as UTF-8 JSON), or its UTF-8 JSON bytes.

kHist

kHist: Uint8Array

K_hist(epoch) from the key store.

signer

signer: Ed25519Signer

The device's DSK.

maxMessageBytes?

maxMessageBytes?: number

maxMessageBytes of the hosting server (11), default 16 KiB.

random?

random?: RandomSource

CSPRNG for the nonce (tests only).

Source: crypto/sealed.ts:293

ShareHeaderFields interface

The fields of a ShareHeader (14 §7.5).

interface ShareHeaderFields

host

host: string

Canonical domain of the hosting server.

ctx

ctx: string

shareId

shareId: string

sharer

sharer: string

Canonical address of the sharing account.

did

did: string

The sharing device.

recipient

recipient: string

Canonical address of the recipient account.

fromSeq

fromSeq: number

toSeq

toSeq: number

count

count: number

nonce

nonce: Uint8Array

12 bytes.

Source: crypto/history-share.ts:82

ShareItem interface

One bundle item: a sealed item's mid and its K_msg (14 §7.5).

interface ShareItem

mid

mid: string

kMsg

kMsg: Uint8Array

K_msg, 32 bytes.

Source: crypto/history-share.ts:31

ShareRecipientDevice interface

A recipient device to wrap K_share to (14 §7.5).

interface ShareRecipientDevice

did

did: string

dbk

dbk: Uint8Array

The device's X25519 box key: the dbk of the DeviceCertificate in its sv_device credential, taken from a leaf of the recipient account in the sharer's own validated MLS state, never from a credential record or 08's BoxKey objects (14 §7.5).

Source: crypto/history-share.ts:193

SignatureLabelInfo interface

One row of the labelled-signature label registry (04 §7.3).

interface SignatureLabelInfo

signedBy

readonly signedBy: "DSK" | "Any" | null

Who signs: a DSK, or anyone for the test label. Null for a retired label.

covers

readonly covers: string

What content covers.

owner

readonly owner: string

Owning document (and section where the content is defined).

retired

readonly retired: boolean

True for a reserved and retired label, which no v1 implementation signs or accepts.

Source: crypto/labelled.ts:14

SignJwsInput interface

Input of signJws.

interface SignJwsInput

typ

typ: "sv-push+jwt" | "sv-relay+jwt" | "sv-keyrot+jwt" | "sv-assert+jwt" | "sv-devproof+jwt" | "sv-s2s+jwt" | "sv-idstate+jwt" | "sv-idcert+jwt" | "sv-devcert+jwt" | "sv-devrevoke+jwt" | "sv-test+jwt"

The registered type (04 §6.3).

kid?

kid?: string

The signing key's ID in the form of the type's signer class (04 §6.4): domain#keyId for server keys, the key's thumbprint for identity keys and DSKs. Omit for identity and device classes to have it computed from the signer's public key.

payload

payload: Uint8Array<ArrayBufferLike> | Record<string, unknown>

The owner's claims, including iat (and exp where required), set from the clock corrected against the server (04 §6.6 clock discipline item 2). An object is serialized with JSON.stringify; bytes are used exactly as given and must be UTF-8 I-JSON.

signer

signer: Ed25519Signer

selfVerify?

selfVerify?: boolean

Verify the new signature with 04 §4.3 before returning it. Defaults to true for the long-lived types (04 §4.2 item 2) and false otherwise.

maxSize?

maxSize?: number

A lower maximum size set by the owner (04 §6.3 item 3).

Source: crypto/jws.ts:327

StoredIdentityState interface

The highest accepted IdentityState of a subject (07 §7.5).

interface StoredIdentityState

compact

compact: string

The exact compact JWS.

claims

claims: IdentityStateClaims

kid

kid: string

The header kid the state was signed with.

acceptedAt

acceptedAt: number

The verifier's own clock (ms) when it accepted the state.

content?

content?: string

The state's content for 07 §7.3 (every payload claim except iat and exp, unknown claims included), as canonical JSON. Compared by 07 §7.4 step 9; absent in entries written before it existed.

Source: crypto/identity.ts:465

StoredRevocation interface

A verified DeviceRevocation kept in the verifier store (07 §7.5).

interface StoredRevocation

did

did: string

carriers

carriers: RevocationCarrier[]

Source: crypto/identity.ts:459

StrictJsonResult interface

Result of parseStrictJson.

interface StrictJsonResult

value

value: unknown

topLevelNumbers

topLevelNumbers: Map<string, string>

The source text of every number that is a direct member of the top-level object, by member name.

Source: crypto/jws.ts:132

SvDeviceCredential interface

The two JWS of an SvDeviceCredential (07 §10.1).

interface SvDeviceCredential

identityCertificate

identityCertificate: string

deviceCertificate

deviceCertificate: string

Source: crypto/identity.ts:978

Svf1Encrypted interface

The result of svf1Encrypt.

interface Svf1Encrypted

blob

blob: Uint8Array

The blob to upload (purpose: "file", mime: "application/octet-stream", 11 §14.3 step 4).

fileKey

fileKey: Uint8Array

K_file, for the AttachmentRef or ThumbnailRef key.

fileSha256

fileSha256: Uint8Array

SHA-256 of the file before encryption, for the reference's sha256.

blobSha256

blobSha256: Uint8Array

SHA-256 of the blob, for the upload's sha256 (11 §14.2).

Source: crypto/attachments.ts:212

Svf1EncryptionStream interface

A streaming SVF1 encryption, from svf1EncryptStream.

interface Svf1EncryptionStream

fileKey

fileKey: Uint8Array

K_file, for the reference's key.

blobBytes

blobBytes: number

The exact blob length, known in advance from the file length.

header

header: Uint8Array

The 43 header bytes (the first chunk chunks yields).

chunks

chunks: AsyncIterable<Uint8Array<ArrayBufferLike>>

The blob: the header, then each C_i as it is sealed.

Source: crypto/attachments.ts:224

Svf1EncryptOptions interface

Options of svf1Encrypt and svf1EncryptStream.

interface Svf1EncryptOptions

fileKey?

fileKey?: Uint8Array<ArrayBufferLike>

K_file; default a fresh one from the CSPRNG. Supply one only for test vectors.

noncePrefix?

noncePrefix?: Uint8Array<ArrayBufferLike>

The 7-byte nonce prefix; default fresh from the CSPRNG. Supply one only for test vectors.

random?

random?: RandomSource

CSPRNG override, for tests.

Source: crypto/attachments.ts:202

Svf1Keys interface

Keys derived from K_file (04 §10.2).

interface Svf1Keys

encKey

encKey: Uint8Array

K_enc = HKDF-Expand(K_file, "sv1 file key", 32). Erase after use (04 §10.5 step 5).

commitment

commitment: Uint8Array

HKDF-Expand(K_file, "sv1 file kc", 32).

Source: crypto/attachments.ts:165

Svf1Layout interface

The layout a blob length implies: segment count, padded length and last segment ciphertext (04 §10.6, §10.7).

interface Svf1Layout

segments

segments: number

n = ceil((B − 43) / 65552).

padded

padded: number

P = B − 43 − 16·n.

lastSegmentCiphertext

lastSegmentCiphertext: number

B − 43 − 65552·(n − 1).

Source: crypto/attachments.ts:112

ValidatedSvDeviceCredential interface

The tuple (sub, ik, igen, kind, did, dsk, dbk, plat) of 07 §10.4.

interface ValidatedSvDeviceCredential

sub

sub: string

ik

ik: Uint8Array

ikf

ikf: string

igen

igen: number

kind

kind: IdentityKind

did

did: string

dsk

dsk: Uint8Array

dkf

dkf: string

dbk

dbk: Uint8Array

The device box key, for sealing HistoryShare keys (14) and grants (08).

plat

plat: DevicePlatform

identityCertificate

identityCertificate: VerifiedIdentityCertificate

deviceCertificate

deviceCertificate: VerifiedDeviceCertificate

Source: crypto/identity.ts:1027

VerifiedDeviceCertificate interface

The result of verifyDeviceCertificate: (did, dsk, dbk, plat) of 07 §6.3 step 11.

interface VerifiedDeviceCertificate

sub

sub: string

igen

igen: number

did

did: string

dsk

dsk: Uint8Array

The 32-byte DSK public key raw(dsk).

dkf

dkf: string

dkf: thumb(dsk).

dbk

dbk: Uint8Array

The 32-byte X25519 box public key raw(dbk).

plat

plat: DevicePlatform

iat

iat: number

compact

compact: string

claims

claims: DeviceCertificateClaims

Source: crypto/identity.ts:321

VerifiedDeviceRevocation interface

A DeviceRevocation that passed 07 §8.3.

interface VerifiedDeviceRevocation

sub

sub: string

igen

igen: number

did

did: string

iat

iat: number

compact

compact: string

claims

claims: DeviceRevocationClaims

Source: crypto/identity.ts:400

VerifiedIdentityCertificate interface

The result of verifyIdentityCertificate: (sub, ik, igen, kind) of 07 §5.3 step 8.

interface VerifiedIdentityCertificate

sub

sub: string

ik

ik: Uint8Array

The 32-byte identity public key raw(ik).

ikf

ikf: string

ikf: thumb(ik), the header kid.

igen

igen: number

kind

kind: IdentityKind

iat

iat: number

compact

compact: string

The exact compact JWS (embed and compare it byte for byte, 07 §5.2).

Source: crypto/identity.ts:247

VerifiedIdentityState interface

An IdentityState that passed 07 §7.4.

interface VerifiedIdentityState

compact

compact: string

claims

claims: IdentityStateClaims

kid

kid: string

The header kid.

identityCertificate

identityCertificate: VerifiedIdentityCertificate | null

The verified IdentityCertificate when sec is secure, else null.

revocations

revocations: VerifiedDeviceRevocation[]

Every rev that verified (07 §7.4 step 10).

ignoredRevocations

ignoredRevocations: IgnoredRevocation[]

Every rev that failed and was ignored, for diagnostics (step 10).

acceptedAt

acceptedAt: number

The verifier's own clock (ms) at acceptance.

validatedAt

validatedAt: number | null

The validated-at time (ms) this acceptance set, or null.

replacedStored

replacedStored: boolean

False when the store already held the same ver with an equal or later exp (nothing replaced).

Source: crypto/identity.ts:622

VerifiedJws interface

A JWS that passed 04 §6.8 steps 1 to 11. Owner claim checks (step 12) remain the caller's.

interface VerifiedJws<P = Record<string, unknown>>

header

header: JwsHeader

payload

payload: P

compact

compact: string

The exact compact string, to store or embed unchanged (04 §6.1 item 4).

signingInput

signingInput: Uint8Array

The ASCII signing input b64-header "." b64-payload (04 §6.1 item 3).

headerBytes

headerBytes: Uint8Array

payloadBytes

payloadBytes: Uint8Array

signature

signature: Uint8Array

publicKey

publicKey: Uint8Array

The 32-byte public key that verified the signature.

Source: crypto/jws.ts:469

VerifierStore interface

Persistence for the verifier store (07 §7.5). A client MAY keep it in local storage only; it isn't synchronized between devices. Implementations may be synchronous or asynchronous.

interface VerifierStore

get

get(sub: string): VerifierStoreEntry | Promise<VerifierStoreEntry | undefined> | undefined
sub: string

set

set(entry: VerifierStoreEntry): void | Promise<void>

delete

delete(sub: string): void | Promise<void>
sub: string

subjects

subjects(): readonly string[] | Promise<readonly string[]>

Every subject with an entry (used when a server key is revoked, 07 §7.5).

Source: crypto/identity.ts:497

VerifierStoreEntry interface

The verifier store's record for one subject (07 §7.5).

interface VerifierStoreEntry

sub

sub: string

state

state: StoredIdentityState | null

The highest accepted IdentityState, or null after a server-key revocation discarded it (07 §7.5).

validatedAt

validatedAt: number | null

The verifier's own clock (ms) of the last validation through an authenticated path (07 §1.4, §13.1), or null.

revocations

revocations: StoredRevocation[]

Verified DeviceRevocations as (sub, did), kept permanently.

replacedIncs

replacedIncs: string[]

Incarnations of the subject that a newer state replaced (07 §7.4 step 11).

Source: crypto/identity.ts:481

VerifyIdentityStateOptions interface

Options of verifyIdentityState.

interface VerifyIdentityStateOptions extends IdentityVerifyOptions

now?

now?: number | Date

The verifier's current time: a NumericDate in seconds or a Date, corrected by the clock offset to the home server (04 §6.6). Defaults to the system clock.

isCanonical?

isCanonical?: CanonicalAddressCheck

Override for 01 §7.5 checks 1 to 5 (for example one that also runs check 6); defaults to canonicalAddressProblem.

expectedSub?

expectedSub?: string

The address the context expects (expectedSub of 07 §7.4).

serverKey

serverKey: IdentityStateKeyResolver

The home server key lookup (07 §7.4 step 6).

store?

store?: VerifierStore

The verifier store to compare with (step 9) and update (step 11). Omit for a stateless check.

validated?

validated?: number | boolean

Whether the state came from an authenticated path that sets the validated-at time (07 §1.4, §13.1): for a client, a GET …/identity it sent to the subject's home server, or its own GET /v1/me/identity. A number gives the validation time in ms (a HomeAssertion's iat).

localNowMs?

localNowMs?: number

The verifier's own clock in ms for acceptedAt (07 §7.4 step 11). Defaults to Date.now().

Source: crypto/identity.ts:598

VerifyJwsOptions interface

Options of verifyJws.

interface VerifyJwsOptions

typ

typ: "sv-push+jwt" | "sv-relay+jwt" | "sv-keyrot+jwt" | "sv-assert+jwt" | "sv-devproof+jwt" | "sv-s2s+jwt" | "sv-idstate+jwt" | "sv-idcert+jwt" | "sv-devcert+jwt" | "sv-devrevoke+jwt" | "sv-test+jwt"

The type this context expects (04 §6.2 item 2, §6.8 step 6).

key

key: JwsVerificationKey

The key the context expects (04 §6.4): for identity and device classes, the key whose thumbprint kid must equal; for server classes, normally a resolver that looks up kid in the issuer's ServerMetadata keys (02). Never taken from the JWS itself.

now?

now?: number | Date

The verifier's current time as a NumericDate (seconds) or a Date, corrected by the clock offset to the home server (04 §6.6 clock discipline item 4). Defaults to the system clock.

maxSize?

maxSize?: number

A lower maximum size set by the owner (04 §6.3 items 2 and 3).

maxLifetimeSec?

maxLifetimeSec?: number

A shorter maximum lifetime set by the owner (04 §6.3 item 2).

allowTestType?

allowTestType?: boolean

Required to verify sv-test+jwt, which no production verifier accepts (04 §6.3 item 4).

ed25519?

ed25519?: { implementation?: "auto" | "portable" }

Passed to the Ed25519 verifier.

Source: crypto/jws.ts:444

VerifyQrPayload interface

The fields of a VerifyQR payload (07 §17.2).

interface VerifyQrPayload

nonce

nonce: Uint8Array

16 fresh random bytes per display.

ownAddress

ownAddress: string

The displayer's canonical address.

ownIk

ownIk: Uint8Array

The displayer's own identity key.

peerAddress

peerAddress: string

The contact's canonical address.

peerIk

peerIk: Uint8Array

The key the displayer trusts for the contact (trustedKeyOfPin, 07 §17.1).

Source: crypto/safety-number.ts:89

VerifyQrScanContext interface

What the scanner knows when it checks a VerifyQR code (07 §17.2).

interface VerifyQrScanContext

ownAddress

ownAddress: string

The scanner's own canonical address.

ownIk

ownIk: Uint8Array

The scanner's own current identity key.

expectedContact?

expectedContact?: string

The contact the user opened the verification screen for, if any.

trustedKeyFor

trustedKeyFor(address: string): Uint8Array<ArrayBufferLike> | undefined

The key the scanner trusts for an address (trustedKeyOfPin of its pin record, 07 §17.1), or undefined when it has no pin record for it.

address: string

Source: crypto/safety-number.ts:168

W2Alert interface

A W2 raised by a pin transition (07 §16.3 "Raise W2").

interface W2Alert

variant

variant: W2Variant

blocking

blocking: boolean

Whether sending is blocked until the user decides (07 §16.5).

changeId

changeId: string

The change's ID; the same changeId never raises W2 twice on any device.

isNew

isNew: boolean

False when the record already carried this changeId (raised before, maybe on another device).

Source: crypto/identity.ts:1202

X25519KeyPair interface

An X25519 key pair: a WebCrypto private key (non-extractable by default) and the raw 32-byte public key.

interface X25519KeyPair

privateKey

readonly privateKey: CryptoKey

publicKey

readonly publicKey: Uint8Array

Source: crypto/hpke.ts:44

X25519PublicJwk interface

An X25519 public key as an OKP JWK. It appears in exactly one place, the dbk claim of a DeviceCertificate (04 §5.1 rule 5, 07 §4.1); everywhere else an X25519 key is raw base64url.

interface X25519PublicJwk

kty

kty: "OKP"

crv

crv: "X25519"

x

x: string

Source: crypto/jwk.ts:21

Types

AeadKey type

An AES-256-GCM key: 32 raw bytes, or a WebCrypto AES-GCM key (for example non-extractable, 04 §14.2).

type AeadKey = Uint8Array | CryptoKey

Source: crypto/aead.ts:22

CanonicalAddressCheck type

A canonical-address check: returns null when address passes 01 §7.5 checks 1 to 5, or the address.non_canonical reason. Check 6 (the domain is the server's canonical domain) is completed by the context (07 §4.2).

type CanonicalAddressCheck = (address: string) => NonCanonicalReason | null

Source: crypto/identity.ts:109

CryptoErrorCode type

HTTP-facing crypto.* error codes (04 §15.1).

type CryptoErrorCode = "crypto.malformed" | "crypto.header_rejected" | "crypto.unsupported_algorithm" | "crypto.wrong_type" | "crypto.unknown_key" | "crypto.invalid_key" | "crypto.bad_signature" | "crypto.invalid_claims" | "crypto.expired" | "crypto.not_yet_valid" | "crypto.kdf_params_rejected"

Source: crypto/primitives.ts:75

CryptoLocalErrorCode type

Local diagnostic codes, never sent over HTTP (04 §15.2).

type CryptoLocalErrorCode = "crypto.decrypt_failed" | "crypto.pake_failed" | "crypto.rng_failure"

Source: crypto/primitives.ts:89

DecryptFailedReason type

reason values of crypto.decrypt_failed (04 §15.2).

type DecryptFailedReason = "tag" | "commitment" | "format" | "padding" | "content_hash"

Source: crypto/primitives.ts:98

DeviceValidity type

The outcome of isDeviceValid.

type DeviceValidity = { valid: true; device: VerifiedDeviceCertificate; entry: DeviceEntry } | { valid: false; reason: IdentityCheckResult; error?: IdentityCheckError }

Source: crypto/identity.ts:894

Ed25519KeyProblem type

Why a public key failed 04 §4.3 items 1 and 2.

type Ed25519KeyProblem = "length" | "non_canonical" | "small_order" | "mixed_order"

Source: crypto/ed25519.ts:204

Ed25519VerifyResult type

Outcome of strict verification: valid, or which code 04 §4.3 assigns to the failure.

type Ed25519VerifyResult = "valid" | "crypto.invalid_key" | "crypto.bad_signature"

Source: crypto/ed25519.ts:251

EkidMismatchAction type

What to do about an ekid mismatch (14 §6.6).

type EkidMismatchAction = { action: "sender_forked"; reportForkSuspected: true } | { action: "self_forked" } | { action: "await_reference" } | { action: "archive_kept"; reportForkSuspected: boolean } | { action: "archive_discard" }

Source: crypto/sealed.ts:529

FreshnessPurpose type

The freshness a use requires (07 §7.6).

type FreshnessPurpose = "unexpired" | "dm_admission" | "channel_as"

Source: crypto/identity.ts:861

HpkeInfoLabel type

An HPKE info label (04 §9.8 item 3).

type HpkeInfoLabel = typeof HPKE_INFO_LABELS[keyof typeof HPKE_INFO_LABELS]

Source: crypto/hkdf.ts:166

IdentityKeyJwsType type

The only JWS types the identity key may sign (07 §3.3).

type IdentityKeyJwsType = "sv-idcert+jwt" | "sv-devcert+jwt" | "sv-devrevoke+jwt"

Source: crypto/identity.ts:1082

IdentityStateKeyResolver type

Looks up the server key an IdentityState names, through discovery (02) or, before a message request is accepted, the serverKeys relayed in the DmRequest (12 §10.1, 07 §14.7). It MUST return only a key whose purpose is sign and whose status makes it valid for verification under 02 (refetching metadata for an unknown kid no more often than 02 allows), and return null (or throw) when there is none: the state then fails bad_signature.

type IdentityStateKeyResolver = (key: IdentityStateKeyRequest) => Uint8Array | Ed25519PublicJwk | null | Promise<Uint8Array | Ed25519PublicJwk | null>

Source: crypto/identity.ts:593

InvalidClaimsReason type

reason values of crypto.invalid_claims (04 §15.1).

type InvalidClaimsReason = "missing" | "type" | "forbidden" | "order" | "lifetime" | "array"

Source: crypto/primitives.ts:95

JwsExpRule type

Whether exp is required, forbidden or optional for a type (04 §6.3, §6.6).

type JwsExpRule = "required" | "forbidden" | "optional"

Source: crypto/jws.ts:19

JwsSignerClass type

Signer classes of 04 §6.4. any exists only for the test type.

type JwsSignerClass = "server" | "identity" | "device" | "any"

Source: crypto/jws.ts:16

JwsType type

A registered typ value (04 §6.3).

type JwsType = keyof typeof JWS_TYPES

Source: crypto/jws.ts:60

JwsVerificationKey type

The verification key: raw 32 bytes, an Ed25519 JWK, or a resolver chosen by the verifying context.

type JwsVerificationKey = Uint8Array | Ed25519PublicJwk | (ctx: JwsKeyContext) => Uint8Array | Ed25519PublicJwk | Promise<Uint8Array | Ed25519PublicJwk>

Source: crypto/jws.ts:438

KdfLabel type

A registered HKDF or HMAC label (04 §8.4).

type KdfLabel = keyof typeof KDF_LABELS

Source: crypto/hkdf.ts:136

MalformedReason type

reason values of crypto.malformed (04 §15.1). Receivers treat unknown reasons as absent.

type MalformedReason = "encoding" | "length" | "json" | "structure" | "size" | "depth"

Source: crypto/primitives.ts:92

MlsExporterLabel type

A registered MLS exporter label (04 §8.6).

type MlsExporterLabel = keyof typeof MLS_EXPORTER_LABELS

Source: crypto/hkdf.ts:186

OpenHistoryShareResult type

The result of openHistoryShare.

type OpenHistoryShareResult = { ok: true; items: ShareItem[] } | { ok: false; step: "no_wrap" } | { ok: false; step: Exclude<HistoryShareStep, "item">; field?: string }

Source: crypto/history-share.ts:315

OpenSealedResult type

The outcome of openSealed (14 §6.3, §6.4).

type OpenSealedResult = { outcome: "ok"; content: Record<string, unknown>; signerKey: Uint8Array; keyType: "history" | "shared"; unknownKind: boolean } | { outcome: "pending_key" } | { outcome: "pending_sender" } | { outcome: "invalid"; step: SealedVerifyStep } | { outcome: "ekid_mismatch"; ownEkid: Uint8Array; messageEkid: Uint8Array; source: HistoryKeySource | undefined; signerKey: Uint8Array }

Source: crypto/sealed.ts:419

PakeFailedReason type

reason values of crypto.pake_failed (04 §15.2).

type PakeFailedReason = "malformed" | "version" | "peer_mismatch" | "identity_element" | "confirmation" | "timeout"

Source: crypto/primitives.ts:101

RandomSource type

A source of cryptographically secure random bytes (04 §13). Injectable for tests only.

type RandomSource = (length: number) => Uint8Array

Source: crypto/primitives.ts:176

RevealedKeyResult type

The result of verifyRevealedKey.

type RevealedKeyResult = { result: "verified"; content: Record<string, unknown>; signerKey: Uint8Array } | { result: Extract<ReportItemResult, "credential_invalid" | "bad_signature" | "bad_key" | "decrypt_failed" | "bad_content"> }

Source: crypto/sealed.ts:564

RngFailureReason type

reason values of crypto.rng_failure (04 §15.2).

type RngFailureReason = "unavailable" | "error"

Source: crypto/primitives.ts:104

SealedSendAction type

What a sender does after a failed post (14 §4.7).

type SealedSendAction = "catch_up_and_reseal" | "commit_and_reseal" | "join_and_reseal" | "bootstrap_and_reseal" | "wait_and_reseal" | "move_generation_and_reseal" | "resync_and_reseal" | "not_secure" | "resend_same" | "not_sent"

Source: crypto/sealed.ts:670

SealedShapeResult type

The result of checkSealedShape.

type SealedShapeResult = { ok: true; decoded: DecodedSealed } | { ok: false; field: string; tooLarge?: boolean; refReason?: "missing" | "forbidden" }

Source: crypto/sealed.ts:206

SignatureLabel type

A registered labelled-signature label (04 §7.3).

type SignatureLabel = keyof typeof SIGNATURE_LABELS

Source: crypto/labelled.ts:53

VerifyQrResult type

Result of checkVerifyQr. On success, mark contact verified with verifyMethod: "qr".

type VerifyQrResult = { ok: true; contact: string } | { ok: false; reason: "malformed" | "other_contact" | "mismatch" }

Source: crypto/safety-number.ts:183

W2Variant type

The W2 variant to show (07 §16.3; 20 owns the copy).

type W2Variant = "key_changed" | "insecure" | "new_account"

Source: crypto/identity.ts:1199

Constants

AEAD_KEY_BYTES const

AES-256 key length in bytes (04 §3.4, §9.1).

const AEAD_KEY_BYTES: 32 = 32

Source: crypto/aead.ts:10

AEAD_MAX_PLAINTEXT_BYTES const

Maximum plaintext bytes per encryption, 2^36 − 32 (04 §9.3).

const AEAD_MAX_PLAINTEXT_BYTES: number

Source: crypto/aead.ts:19

AEAD_NONCE_BYTES const

AES-GCM nonce length in bytes (04 §3.4, §9.1).

const AEAD_NONCE_BYTES: 12 = 12

Source: crypto/aead.ts:12

AEAD_RANDOM_NONCE_MAX_ENCRYPTIONS const

Default per-key bound for random-nonce keys: 2^32 encryptions (04 §9.3, NIST SP 800-38D §8.3).

const AEAD_RANDOM_NONCE_MAX_ENCRYPTIONS: number

Source: crypto/aead.ts:17

AEAD_TAG_BYTES const

AES-GCM tag length in bytes, appended to the ciphertext (04 §3.4, §9.1).

const AEAD_TAG_BYTES: 16 = 16

Source: crypto/aead.ts:14

CRYPTO_ERRORS const

The crypto.* error registry (04 §15.1 and §15.2). crypto.unknown_key is retryable (retry, retryAfterMs 60,000) only for the Server signer class; the row here is the Identity/Device form and cryptoError takes an override.

const CRYPTO_ERRORS: Readonly<Record<CryptoErrorCode | CryptoLocalErrorCode, CryptoErrorInfo>>

Source: crypto/primitives.ts:120

CRYPTO_LENGTHS const

Byte lengths of cryptographic values (04 §3.4).

const CRYPTO_LENGTHS: { readonly ed25519PublicKey: 32; readonly ed25519Seed: 32; readonly ed25519Signature: 64; readonly x25519PublicKey: 32; readonly sha256: 32; readonly thumbprint: 32; readonly aes256Key: 32; readonly aesGcmNonce: 12; readonly aesGcmTag: 16; readonly keyCommitment: 16; readonly ekid: 8; readonly did: 16; readonly jtiMin: 16; readonly jtiMax: 64; readonly argon2idSalt: 16 }

Source: crypto/primitives.ts:53

CRYPTO_SUITE const

The one crypto suite of protocol version 1 (04 §2.1, D-027). Objects never carry it (04 §2.2 item 3).

const CRYPTO_SUITE: "sv1-c1"

Source: crypto/primitives.ts:16

DEFAULT_MAX_MESSAGE_BYTES const

Default maxMessageBytes (11: 16 KiB).

const DEFAULT_MAX_MESSAGE_BYTES: number

Source: crypto/sealed.ts:141

DM_ID_BYTES const

Number of SHA-256 output bytes kept in a dm: reference (12 §5.2).

const DM_ID_BYTES: 16 = 16

Source: crypto/dm-id.ts:20

DM_ID_CHARS const

Length of the base64url part of a dm: reference: 16 bytes unpadded (12 §5.1).

const DM_ID_CHARS: 22 = 22

Source: crypto/dm-id.ts:23

DM_ID_LABEL const

The SHA-256 domain-separation label of the 1:1 DM reference (12 §5.2, 04 §8.5, 00 §7.15).

const DM_ID_LABEL: "sv1 dm"

Source: crypto/dm-id.ts:17

DOMAIN_SEPARATION_LABELS const

Domain-separation strings for hashes, HPKE and CPace (04 §8.5).

const DOMAIN_SEPARATION_LABELS: { readonly sv1 dm: { readonly primitive: "SHA-256"; readonly input: "\"sv1 dm\" || 0x00 || P1 || 0x0A || P2 (P1 < P2 canonical addresses)"; readonly use: "1:1 DM context ID (dm: + base64url of first 16 bytes)"; readonly owner: "12" }; readonly sv1 upgrade plan: { readonly primitive: "SHA-256"; readonly input: "\"sv1 upgrade plan\" || 0x00 || scope || 0x00 || … (09 §10.6)"; readonly use: "Upgrade plan version"; readonly owner: "09" }; readonly sv1 vault grant: { readonly primitive: "HPKE info"; readonly input: "\"sv1 vault grant\" || 0x00 || context (08 §10.3)"; readonly use: "VaultKeyGrant (04 §9.8)"; readonly owner: "08" }; readonly sv1 history-share: { readonly primitive: "HPKE info"; readonly input: "\"sv1 history-share\" || 0x00 || mid16(shareId) || did16(did)"; readonly use: "HistoryShare key wrap (04 §9.8)"; readonly owner: "14" }; readonly sv1 pair ci: { readonly primitive: "CPace channel identifier"; readonly input: "04 §11.3"; readonly use: "Binds the CPace run to the pairing session"; readonly owner: "04" }; readonly sv1 init: { readonly primitive: "CPace associated data"; readonly input: "04 §11.3"; readonly use: "Initiator role label in ADa"; readonly owner: "04" }; readonly sv1 resp: { readonly primitive: "CPace associated data"; readonly input: "04 §11.3"; readonly use: "Responder role label in ADb"; readonly owner: "04" }; readonly sv1 safety: { readonly primitive: "SHA-512 iterated"; readonly input: "\"sv1 safety\" || 0x00 || u16(1) || ik || addr, then 5,200 rounds of h = SHA-512(h || ik)"; readonly use: "Safety-number halves"; readonly owner: "07" } }

Source: crypto/hkdf.ts:148

ED25519_JWK_MEMBERS const

The members an identity-key or DSK JWK (ik, dsk) has, exactly (04 §5.1 rule 1).

const ED25519_JWK_MEMBERS: readonly ["kty", "crv", "x"]

Source: crypto/jwk.ts:34

ED25519_L const

The group order L = 2^252 + 27742317777372353535851937790883648493 (04 §4.3 item 6).

const ED25519_L: bigint

Source: crypto/ed25519.ts:37

ED25519_P const

The field prime p = 2^255 − 19 (04 §4.3 item 1).

const ED25519_P: bigint

Source: crypto/ed25519.ts:34

ED25519_SMALL_ORDER_POINTS const

The canonical encodings of the eight small-order points, hexadecimal as transmitted (04 §4.4).

const ED25519_SMALL_ORDER_POINTS: readonly ["0100000000000000000000000000000000000000000000000000000000000000", "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f", "0000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000080", "c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a", "c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa", "26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05", "26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85"]

Source: crypto/ed25519.ts:189

HKDF_MAX_OUTPUT const

Largest output of any sv1 derivation (04 §8.1 item 4).

const HKDF_MAX_OUTPUT: 64 = 64

Source: crypto/hkdf.ts:37

HPKE_INFO_LABELS const

The HPKE info labels (04 §8.5, §9.8 item 3; 00 §7.15).

const HPKE_INFO_LABELS: { readonly vaultGrant: "sv1 vault grant"; readonly historyShare: "sv1 history-share" }

Source: crypto/hkdf.ts:160

HPKE_MODE_BASE const

HPKE mode mode_base (RFC 9180 §5), the only mode used (04 §9.8 item 1).

const HPKE_MODE_BASE: 0 = 0x00

Source: crypto/hpke.ts:15

HPKE_SIZES const

Lengths of the pinned HPKE suite: Nenc, Npk, Nsecret (KEM), Nk, Nn, Nt (AEAD) (RFC 9180 §7).

const HPKE_SIZES: { readonly enc: 32; readonly publicKey: 32; readonly sharedSecret: 32; readonly key: 32; readonly nonce: 12; readonly tag: 16 }

Source: crypto/hpke.ts:18

IDENTITY_SKEW_SEC const

Clock skew allowance in seconds (07 §1.5, 00 §7.7).

const IDENTITY_SKEW_SEC: 60 = IDENTITY_LIMITS.skewSec

Source: crypto/identity.ts:95

JWS_ABSOLUTE_MAX_SIZE const

No type may exceed this many bytes (04 §6.3 item 3).

const JWS_ABSOLUTE_MAX_SIZE: 65536 = 65536

Source: crypto/jws.ts:78

JWS_CLOCK_SKEW_SEC const

The clock-skew allowance applied once, in the comparisons of 04 §6.6 (00 §7.7).

const JWS_CLOCK_SKEW_SEC: 60 = 60

Source: crypto/jws.ts:69

JWS_FORBIDDEN_HEADER_MEMBERS const

Header members a verifier names in errors when they appear; every non-listed member is rejected too (04 §6.2 item 1).

const JWS_FORBIDDEN_HEADER_MEMBERS: readonly ["jwk", "jku", "x5u", "x5c", "x5t", "x5t#S256", "crit", "b64", "zip", "cty", "enc", "nonce"]

Source: crypto/jws.ts:81

JWS_MAX_HEADER_BYTES const

Maximum decoded header size in bytes (04 §6.2 item 4).

const JWS_MAX_HEADER_BYTES: 1024 = 1024

Source: crypto/jws.ts:72

JWS_MAX_PAYLOAD_DEPTH const

Maximum payload nesting depth (04 §6.5 item 1).

const JWS_MAX_PAYLOAD_DEPTH: 8 = 8

Source: crypto/jws.ts:75

JWS_TYP_PATTERN const

ABNF typ-value = "sv-" typ-name "+jwt" (04 §6.3).

const JWS_TYP_PATTERN: RegExp

Source: crypto/jws.ts:63

JWS_TYPES const

The complete typ registry of 04 §6.3 (00 §7.13 lists the production rows). No owner defines nbf (06 §2, 07 §3), so nbf is false on every row.

const JWS_TYPES: { readonly sv-assert+jwt: { readonly object: "HomeAssertion"; readonly signerClass: "server"; readonly issuerClaim: "iss"; readonly exp: "required"; readonly maxLifetimeSec: 300; readonly maxSize: 4096; readonly nbf: false; readonly owner: "06" }; readonly sv-devproof+jwt: { readonly object: "DeviceProof"; readonly signerClass: "device"; readonly issuerClaim: null; readonly exp: "required"; readonly maxLifetimeSec: 60; readonly maxSize: 1024; readonly nbf: false; readonly owner: "06" }; readonly sv-s2s+jwt: { readonly object: "S2S request token"; readonly signerClass: "server"; readonly issuerClaim: "iss"; readonly exp: "required"; readonly maxLifetimeSec: 60; readonly maxSize: 4096; readonly nbf: false; readonly owner: "06" }; readonly sv-relay+jwt: { readonly object: "RelayTicket"; readonly signerClass: "server"; readonly issuerClaim: "iss"; readonly exp: "required"; readonly maxLifetimeSec: 60; readonly maxSize: 8192; readonly nbf: false; readonly owner: "15" }; readonly sv-push+jwt: { readonly object: "Push gateway request token"; readonly signerClass: "server"; readonly issuerClaim: "iss"; readonly exp: "required"; readonly maxLifetimeSec: 60; readonly maxSize: 4096; readonly nbf: false; readonly owner: "19" }; readonly sv-idstate+jwt: { readonly object: "IdentityState"; readonly signerClass: "server"; readonly issuerClaim: "iss"; readonly exp: "required"; readonly maxLifetimeSec: 86400; readonly maxSize: 32768; readonly nbf: false; readonly owner: "07" }; readonly sv-idcert+jwt: { readonly object: "IdentityCertificate"; readonly signerClass: "identity"; readonly issuerClaim: null; readonly exp: "forbidden"; readonly maxLifetimeSec: null; readonly maxSize: 2048; readonly nbf: false; readonly owner: "07" }; readonly sv-devcert+jwt: { readonly object: "DeviceCertificate"; readonly signerClass: "identity"; readonly issuerClaim: null; readonly exp: "forbidden"; readonly maxLifetimeSec: null; readonly maxSize: 2048; readonly nbf: false; readonly owner: "07" }; readonly sv-devrevoke+jwt: { readonly object: "DeviceRevocation"; readonly signerClass: "identity"; readonly issuerClaim: null; readonly exp: "forbidden"; readonly maxLifetimeSec: null; readonly maxSize: 1024; readonly nbf: false; readonly owner: "07" }; readonly sv-keyrot+jwt: { readonly object: "KeyRotation"; readonly signerClass: "server"; readonly issuerClaim: "iss"; readonly exp: "forbidden"; readonly maxLifetimeSec: null; readonly maxSize: 2048; readonly nbf: false; readonly owner: "02" }; readonly sv-test+jwt: { readonly object: "Test vectors only"; readonly signerClass: "any"; readonly issuerClaim: null; readonly exp: "optional"; readonly maxLifetimeSec: 300; readonly maxSize: 8192; readonly nbf: false; readonly owner: "04" } }

Source: crypto/jws.ts:45

KDF_LABEL_PATTERN const

ABNF kdf-label = "sv1 " word *( " " word ), at most 32 characters (04 §8.3).

const KDF_LABEL_PATTERN: RegExp

Source: crypto/hkdf.ts:78

KDF_LABELS const

The HKDF and HMAC label registry (04 §8.4; 00 §7.15 lists a subset).

const KDF_LABELS: { readonly sv1 ekid: { readonly primitive: "HKDF-Expand"; readonly inputKey: "K_hist(e)"; readonly input: "\"sv1 ekid\""; readonly outputLength: 8; readonly use: "Epoch key ID"; readonly owner: "14"; readonly retired: false }; readonly sv1 msg: { readonly primitive: "HKDF-Expand"; readonly inputKey: "K_hist(e)"; readonly input: "\"sv1 msg\" || mid (16 bytes), no separator"; readonly outputLength: 32; readonly use: "K_msg"; readonly owner: "14"; readonly retired: false }; readonly sv1 kc: { readonly primitive: "HMAC"; readonly inputKey: "K_msg"; readonly input: "\"sv1 kc\""; readonly outputLength: 32; readonly truncateTo: 16; readonly use: "Key commitment kc"; readonly owner: "14"; readonly retired: false }; readonly sv1 link: { readonly primitive: null; readonly inputKey: ""; readonly input: ""; readonly outputLength: null; readonly use: "Reserved and retired (formerly the HistoryLink key, revised D-007)"; readonly owner: "14"; readonly retired: true }; readonly sv1 anchor: { readonly primitive: null; readonly inputKey: ""; readonly input: ""; readonly outputLength: null; readonly use: "Reserved and retired (formerly the AnchorLink key, revised D-007)"; readonly owner: "14"; readonly retired: true }; readonly sv1 vault: { readonly primitive: "HKDF-Expand"; readonly inputKey: "K_vault of one generation"; readonly input: "\"sv1 vault\" || 0x00 || context"; readonly outputLength: 32; readonly use: "Vault record keys, VaultKeyLink keys, key check values (8 bytes)"; readonly owner: "08"; readonly retired: false }; readonly sv1 vault id: { readonly primitive: "HMAC"; readonly inputKey: "K_vid"; readonly input: "\"sv1 vault id\" || 0x00 || context"; readonly outputLength: 32; readonly truncateTo: 16; readonly use: "Vault record IDs and buckets"; readonly owner: "08"; readonly retired: false }; readonly sv1 backup: { readonly primitive: "HKDF-Expand"; readonly inputKey: "Argon2id output (32 bytes) as PRK"; readonly input: "\"sv1 backup\" || 0x00 || lv(addr)"; readonly outputLength: 32; readonly use: "KeyBackup encryption key"; readonly owner: "08"; readonly retired: false }; readonly sv1 pair: { readonly primitive: "HKDF-Expand"; readonly inputKey: "CPace ISK (64 bytes) as PRK"; readonly input: "\"sv1 pair\" || 0x00 || u8(dir)"; readonly outputLength: 32; readonly use: "Pairing payload (dir 0x01) and ack (0x02) keys"; readonly owner: "08"; readonly retired: false }; readonly sv1 file key: { readonly primitive: "HKDF-Expand"; readonly inputKey: "K_file"; readonly input: "\"sv1 file key\""; readonly outputLength: 32; readonly use: "SVF1 encryption key K_enc (04 §10.2)"; readonly owner: "04"; readonly retired: false }; readonly sv1 file kc: { readonly primitive: "HKDF-Expand"; readonly inputKey: "K_file"; readonly input: "\"sv1 file kc\""; readonly outputLength: 32; readonly use: "SVF1 key commitment (04 §10.2)"; readonly owner: "04"; readonly retired: false }; readonly sv1 cpace kc: { readonly primitive: "HKDF-Expand"; readonly inputKey: "CPace ISK"; readonly input: "\"sv1 cpace kc\""; readonly outputLength: 64; readonly use: "Key-confirmation keys K_ca, K_cb (04 §11.5)"; readonly owner: "04"; readonly retired: false }; readonly sv1 push collapse: { readonly primitive: "HMAC"; readonly inputKey: "K_coll (19 §10.3)"; readonly input: "\"sv1 push collapse\" || 0x00 || opaque(topic)"; readonly outputLength: 32; readonly truncateTo: 16; readonly use: "Push collapse keys"; readonly owner: "19"; readonly retired: false } }

Source: crypto/hkdf.ts:119

LABELLED_SIGNATURE_PREFIX const

The ASCII prefix of every labelled-signature input (04 §7.1).

const LABELLED_SIGNATURE_PREFIX: "sv1 sig"

Source: crypto/labelled.ts:11

LONG_LIVED_JWS_TYPES const

Types signed for long-lived publication, which the signer SHOULD verify before publishing (04 §4.2 item 2).

const LONG_LIVED_JWS_TYPES: readonly JwsType[]

Source: crypto/jws.ts:66

MLS_EXPORTER_LABELS const

The MLS exporter label registry (04 §8.6, 00 §7.15). sv1 implementations MUST NOT call the MLS exporter with any other label (04 §8.6 item 1).

const MLS_EXPORTER_LABELS: { readonly sv1 history: { readonly context: "empty"; readonly length: 32; readonly output: "K_hist(e)"; readonly owner: "14" }; readonly SFrame 1.0 Base Key: { readonly context: "empty"; readonly length: 16; readonly output: "SFrame epoch secret (RFC 9605 §5.2, AEAD.Nk of 0x0004)"; readonly owner: "18" } }

Source: crypto/hkdf.ts:180

PINNED_CIPHER_SUITES const

The fixed MLS and SFrame cipher suite numbers pinned by 04 §2.1 (the profiles themselves are 13 and 18).

const PINNED_CIPHER_SUITES: { readonly mls: 1; readonly sframe: 4; readonly hpkeKem: 32; readonly hpkeKdf: 1; readonly hpkeAead: 2 }

Source: crypto/primitives.ts:36

PRIVATE_JWK_MEMBERS const

JWK members that hold private key material in any JWK key type (RFC 7517, RFC 7518, RFC 8037). A JWK carrying one is rejected with crypto.invalid_key in every context (04 §5.1 rule 3).

const PRIVATE_JWK_MEMBERS: readonly ["d", "p", "q", "dp", "dq", "qi", "oth", "k"]

Source: crypto/jwk.ts:31

RESERVED_CRYPTO_SUITES const

Suite identifiers reserved for later use; a v1 implementation treats them as unsupported (04 §2.3, §17.4).

const RESERVED_CRYPTO_SUITES: readonly ["sv1-c2"]

Source: crypto/primitives.ts:19

RESERVED_LABEL_PREFIX_MSG const

The prefix no other label may start with (04 §8.3 item 3, §8.7 item 1).

const RESERVED_LABEL_PREFIX_MSG: "sv1 msg"

Source: crypto/hkdf.ts:206

RETIRED_KDF_LABELS const

KDF/HMAC labels that are reserved and retired and MUST NOT be derived or reused (04 §8.4, 00 §7.15). The retired labelled-signature label history-link is in RETIRED_SIGNATURE_LABELS.

const RETIRED_KDF_LABELS: readonly ["sv1 link", "sv1 anchor"]

Source: crypto/hkdf.ts:197

RETIRED_LABELS const

Every reserved and retired label of 00 §7.15 and 04 §7.3, §8.4, by registry.

const RETIRED_LABELS: { readonly kdf: readonly ["sv1 link", "sv1 anchor"]; readonly signature: readonly ["history-link"] }

Source: crypto/hkdf.ts:200

RETIRED_SIGNATURE_LABELS const

Labels that are reserved and retired and MUST NOT be signed, accepted or reused (04 §7.3, 00 §7.15).

const RETIRED_SIGNATURE_LABELS: readonly ["history-link"]

Source: crypto/labelled.ts:56

SAFETY_NUMBER_ITERATIONS const

SHA-512 iterations of the fingerprint (07 §17.1, §20).

const SAFETY_NUMBER_ITERATIONS: 5200 = IDENTITY_LIMITS.safetyNumberIterations

Source: crypto/safety-number.ts:21

SAFETY_NUMBER_LABEL const

The hash-chain label sv1 safety, registered in 04 §8.5 (07 §17.1).

const SAFETY_NUMBER_LABEL: "sv1 safety" = 'sv1 safety'

Source: crypto/safety-number.ts:15

SAFETY_NUMBER_VERSION const

The construction version, 1 for sv1 (07 §17.1).

const SAFETY_NUMBER_VERSION: 1 = 1

Source: crypto/safety-number.ts:18

SIGNATURE_LABEL_PATTERN const

ABNF sig-label = lc-alnum *31( lc-alnum / "-" ): ASCII, 1 to 32 characters (04 §7.1).

const SIGNATURE_LABEL_PATTERN: RegExp

Source: crypto/labelled.ts:59

SIGNATURE_LABELS const

The labelled-signature label registry (04 §7.3; 00 §7.14 lists the initial labels).

const SIGNATURE_LABELS: { readonly sealed: { readonly signedBy: "DSK"; readonly covers: "A SealedMessage's header fields and ciphertext"; readonly owner: "14"; readonly retired: false }; readonly history-share: { readonly signedBy: "DSK"; readonly covers: "A HistoryShare: version, hosting domain, context, share ID, sharer and recipient addresses, sharing did, range, item count, bundle nonce and ciphertext"; readonly owner: "14 §7.5"; readonly retired: false }; readonly history-link: { readonly signedBy: null; readonly covers: "Reserved and retired (revised D-007); MUST NOT be reused"; readonly owner: "14"; readonly retired: true }; readonly media-attest: { readonly signedBy: "DSK"; readonly covers: "A MediaAttestation: version, group_id, epoch, call ID, KID, first and last SFrame counter, truncated frame hashes"; readonly owner: "18 §9.2, §9.4"; readonly retired: false }; readonly vault-box-key: { readonly signedBy: "DSK"; readonly covers: "A box key binding: the account's canonical address, did, identity generation and X25519 box public key"; readonly owner: "08 §10.1"; readonly retired: false }; readonly vault-generation: { readonly signedBy: "DSK"; readonly covers: "A vault key generation (VaultGenerationTBS)"; readonly owner: "08 §10.2"; readonly retired: false }; readonly test: { readonly signedBy: "Any"; readonly covers: "Test vectors only; no production verifier accepts it"; readonly owner: "04"; readonly retired: false } }

Source: crypto/labelled.ts:27

SUITE_ID_PATTERN const

ABNF suite-id = "sv" 1*DIGIT "-c" 1*DIGIT (04 §2.3).

const SUITE_ID_PATTERN: RegExp

Source: crypto/primitives.ts:22

SV_DEVICE_CREDENTIAL_TYPE const

The sv_device MLS credential type code point, private use until registered (07 §10.1, D-034).

const SV_DEVICE_CREDENTIAL_TYPE: 62880 = 0xf5a0

Source: crypto/identity.ts:92

SVF1 const

SVF1 format constants (04 §10.3, §10.4, §10.7).

const SVF1: { readonly magic: Uint8Array<ArrayBuffer>; readonly noncePrefixBytes: 7; readonly commitmentBytes: 32; readonly headerBytes: 43; readonly segmentBytes: 65536; readonly segmentCiphertextBytes: 65552; readonly minBucket: 4096; readonly minBlobBytes: 4155; readonly minLastSegmentCiphertextBytes: 4112; readonly lengthPrefixBytes: 8; readonly fileKeyBytes: 32; readonly maxSegments: number }

Source: crypto/attachments.ts:37

VERIFY_QR_PREFIX const

The ASCII prefix of a VerifyQR code (07 §17.2).

const VERIFY_QR_PREFIX: "SVV1:" = 'SVV1:'

Source: crypto/safety-number.ts:24

VERIFY_QR_VALIDITY_MS const

How long a displayed VerifyQR code is valid, ms (07 §17.2).

const VERIFY_QR_VALIDITY_MS: number

Source: crypto/safety-number.ts:30

VERIFY_QR_VERSION const

The VerifyQR version (07 §17.2).

const VERIFY_QR_VERSION: 1 = 1

Source: crypto/safety-number.ts:27