import { WalletChain, BitcoinAddressType } from '../types/index.mjs'; interface AesCiphertext { ciphertext: Uint8Array; iv: Uint8Array; } /** 32 random bytes, suitable for use as an AES-GCM DEK. */ declare function generateDek(): Uint8Array; /** * 8-byte fingerprint of the DEK. Lets the client detect wrap-mismatch * before it attempts to decrypt the share: after unwrapping, compute * the fingerprint, compare against the keyshare row's `dek_fingerprint`. * BLAKE2s-128 truncated to 64 bits is plenty for collision resistance * in this single-use-per-row context. * * Uses incremental hashing to avoid allocating a labeled buffer that * would hold a copy of the DEK bytes alongside the original. */ declare function dekFingerprint(dek: Uint8Array): Uint8Array; /** * Zero a Uint8Array's bytes in-place. Best-effort: only zeros the buffer * this view sees. Engine-internal copies (crypto.subtle scratch, hash * round state) live on the engine's allocator schedule; we cannot touch * them. See the implementation doc's "Plaintext DEK lifetime" gap. */ declare function zeroize(bytes: Uint8Array): void; /** AAD for the share ciphertext. Binds user + wallet identity. */ declare function shareAad(userId: string, keyId: string, chain: string): Uint8Array; /** * AAD for a wrap. Binds user + credential + wrap method. * * Under user-level DEK there's only one DEK per user, so the wrap AAD * doesn't need to carry wallet identity; the share-level AAD already * binds each share to its (key_id, chain). The wrap AAD only needs to * disambiguate across credentials and recovery methods. */ declare function wrapAad({ userId, credentialIdB64, wrapMethod, }: { userId: string; credentialIdB64?: string; wrapMethod: string; }): Uint8Array; /** * Import 32 raw DEK bytes as a non-extractable AES-GCM CryptoKey. After * this returns, callers should `zeroize(raw)`. The * CryptoKey holds the key material in browser-native memory, no longer * in JS-readable form. */ declare function importDekAsKey(raw: Uint8Array): Promise; /** AES-GCM encrypt with required associated data, given raw key bytes. * Used for wrap operations (userHandle → DEK) where the wrapping key * is a transient passkey-supplied secret we never cache as a CryptoKey. */ declare function aesGcmEncrypt(keyBytes: Uint8Array, plaintext: Uint8Array, aad: Uint8Array): Promise; /** AES-GCM decrypt with required associated data; throws on tag failure. */ declare function aesGcmDecrypt(keyBytes: Uint8Array, ciphertext: Uint8Array, iv: Uint8Array, aad: Uint8Array): Promise; /** AES-GCM encrypt against a CryptoKey handle. Used for steady-state * share encryption against the cached, non-extractable DEK key. */ declare function aesGcmEncryptWithKey(key: CryptoKey, plaintext: Uint8Array, aad: Uint8Array): Promise; /** AES-GCM decrypt against a CryptoKey handle. */ declare function aesGcmDecryptWithKey(key: CryptoKey, ciphertext: Uint8Array, iv: Uint8Array, aad: Uint8Array): Promise; /** Standard base64 (not base64url) encode. Backend endpoints use std. */ declare function b64(bytes: Uint8Array): string; declare function fromB64(s: string): Uint8Array; /** Base64url decode. Used for credential_ids and userHandles from WebAuthn. */ declare function fromB64url(s: string): Uint8Array; declare function toB64url(bytes: Uint8Array): string; /** Constant-time byte-array equality. Used for DEK fingerprint check. */ declare function bytesEqual(a: Uint8Array, b: Uint8Array): boolean; declare const COGNITO_KMS_WRAP_METHOD = "cognito_kms_v1"; type KmsWrapMethod = typeof COGNITO_KMS_WRAP_METHOD; type KmsTarget = "TrentService.Encrypt" | "TrentService.Decrypt"; interface TemporaryAwsCredentials { accessKeyId: string; secretAccessKey: string; sessionToken: string; expiration: Date; } interface WireTemporaryAwsCredentials { access_key_id: string; secret_access_key: string; session_token: string; expiration: string; } interface KmsCredentialsCommon { broker: "cognito_developer_identity"; config_id: string; expires_in: number; region: string; kms_key_arn: string; } interface CognitoKmsCredentialsResponse extends KmsCredentialsCommon { broker: "cognito_developer_identity"; identity_id: string; identity_pool_id: string; token?: string; credentials?: WireTemporaryAwsCredentials; } type KmsCredentialsResponse = CognitoKmsCredentialsResponse; declare const bytesToStandardBase64: (bytes: Uint8Array) => string; declare const standardBase64ToBytes: (value: string) => Uint8Array; declare const signAwsJsonRequest: ({ endpoint, target, body, region, credentials, now, }: { endpoint: string; target: string; body: string; region: string; credentials: TemporaryAwsCredentials; now?: Date; }) => Promise; declare const parseKmsCredentialsResponse: (value: unknown) => KmsCredentialsResponse; /** * Exchange the backend's Cognito developer token for temporary AWS * credentials. Local development material carries the credentials inline. */ declare const exchangeCognitoCredentials: (material: CognitoKmsCredentialsResponse, fetchImpl?: typeof fetch) => Promise; /** The regional AWS KMS endpoint for the credentials' region. */ declare const resolveKmsEndpoint: (material: Pick) => string; /** * The encryption context every DEK wrap is bound to. The KMS key policy pins * `cognito_identity_id` to the caller's Cognito identity. */ declare const kmsEncryptionContext: ({ cognitoIdentityId, appId, userId, }: { cognitoIdentityId: string; appId: string; userId: string; }) => Record; /** KMS Encrypt request body for a raw DEK. */ declare const kmsEncryptDekBody: ({ keyArn, dek, encryptionContext, }: { keyArn: string; dek: Uint8Array; encryptionContext: Record; }) => Record; /** Ciphertext bytes from a KMS Encrypt response. */ declare const kmsCiphertextFromResponse: (result: Record) => Uint8Array; /** KMS Decrypt request body for a wrapped DEK. */ declare const kmsDecryptDekBody: ({ keyArn, ciphertext, encryptionContext, }: { keyArn: string; ciphertext: Uint8Array; encryptionContext: Record; }) => Record; /** Plaintext bytes from a KMS Decrypt response. */ declare const kmsPlaintextFromResponse: (result: Record) => Uint8Array; /** Error code from a failed KMS JSON response, or "" when absent. */ declare const kmsErrorCode: (response: Response, body: unknown) => string; interface WalletKeygenAddress { /** Hex pubkey sent to /key/persist. */ pubkeyHex: string; /** Display address for the chain. */ address: string; } /** EIP-55 checksummed Ethereum address of a secp256k1 public key. */ declare function ethereumAddressFromPublicKey(publicKeyHex: string): string; /** Base58 Solana address of a 32-byte ed25519 public key. */ declare function solanaAddressFromPublicKey(publicKey: Uint8Array): string; /** * Derive the persisted pubkey and display address of a new wallet. ECDSA * chains use the child key at the chain's BIP44 path, because signing and * export run at that path. Bitcoin P2TR uses the BIP86 output key. * `signer` is the Sodot algorithm instance that ran the keygen and * `keygenResult` its result. */ declare function deriveWalletKeygenAddress({ chain, addressType, keygenResult, signer, }: { chain: WalletChain; addressType?: BitcoinAddressType; keygenResult: object; signer: object; }): Promise; declare function ownershipProofMessageHex(pubkeyHex: string, timestamp: number, userId: string): string; export { type AesCiphertext, COGNITO_KMS_WRAP_METHOD, type CognitoKmsCredentialsResponse, type KmsCredentialsResponse, type KmsTarget, type KmsWrapMethod, type TemporaryAwsCredentials, type WalletKeygenAddress, type WireTemporaryAwsCredentials, aesGcmDecrypt, aesGcmDecryptWithKey, aesGcmEncrypt, aesGcmEncryptWithKey, b64, bytesEqual, bytesToStandardBase64, dekFingerprint, deriveWalletKeygenAddress, ethereumAddressFromPublicKey, exchangeCognitoCredentials, fromB64, fromB64url, generateDek, importDekAsKey, kmsCiphertextFromResponse, kmsDecryptDekBody, kmsEncryptDekBody, kmsEncryptionContext, kmsErrorCode, kmsPlaintextFromResponse, ownershipProofMessageHex, parseKmsCredentialsResponse, resolveKmsEndpoint, shareAad, signAwsJsonRequest, solanaAddressFromPublicKey, standardBase64ToBytes, toB64url, wrapAad, zeroize };