/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import { Bytes } from "../util/Bytes.js"; export declare enum KeyType { EC = "EC", RSA = "RSA", oct = "oct" } export declare enum CurveType { p256 = "P-256", p384 = "P-384", p521 = "P-521" } export type BinaryKeyPair = { publicKey: Bytes; privateKey: Bytes; }; /** * Represents a cryptographic key. * * Models keys as JWK. Advantages of this format: * * - Standard * - Widely supported * - Fully models relevant key types * - Where not supported, extracting constituent parts for translation is trivial */ export interface Key extends JsonWebKey { /** * The key algorithm, alias for JWK "alg" field. */ algorithm?: Key["alg"]; /** * The elliptic curve type, alias for JWK "crv" field. */ curve?: Key["crv"]; /** * The key type, alias for JWK "kty" field. */ type?: Key["kty"]; /** * Operations supported by the key, alias for JWK "key_ops" field. */ operations?: Key["key_ops"]; /** * The private key, alias for JWK "d" field. */ private?: Key["d"]; /** * Indicates whether the private key is extractable, alias for JSK "ext" * field. */ extractable?: Key["ext"]; alg?: string; crv?: CurveType; d?: string; dp?: string; dq?: string; e?: string; ext?: boolean; k?: string; key_ops?: string[]; kty?: KeyType; n?: string; oth?: RsaOtherPrimesInfo[]; p?: string; q?: string; qi?: string; use?: string; x?: string; y?: string; /** * Binary alias to private key field. Automatically encodes/decodes the * base-64 private key. */ privateBits?: Bytes; /** * Binary alias to the x field. Automatically encodes/decodes the base-64 * x-point on EC public keys. */ xBits?: Bytes; /** * Binary alias to the y field. Automatically encodes/decodes the base-64 * y-point on EC public keys. */ yBits?: Bytes; /** * Import (write-only) of private keys encoded in SEC1 format. */ sec1?: Bytes; /** * Import (write-only) of private keys encoded in PKCS #8 format. */ pkcs8?: Bytes; /** * Import (write-only) of public keys encoded in SPKI format. */ spki?: Bytes; /** * Import/export of EC public key in SEC1/SPKI format. Maps to x & y * fields internally. */ publicBits?: Bytes; /** * Import/export of BinaryKeyPair structure used as an alternate * serialization format for legacy reasons. */ keyPairBits?: BinaryKeyPair; /** * Alias for publicBits that throws if no public key is present. */ publicKey: Bytes; /** * Alias for privateBits that throws if no private key is present. */ privateKey: Bytes; /** * Alias for keyPairBits that throws if a complete key pair is not present. */ keyPair: BinaryKeyPair; } /** * EC key without private fields. */ export interface PublicKey extends Key { type: KeyType.EC; curve: CurveType; x: string; y: string; xBits: Bytes; yBits: Bytes; publicBits: Bytes; } /** * EC key with extractable private fields. */ export interface PrivateKey extends PublicKey { private: string; d: string; privateBits: Bytes; privateKey: Bytes; keyPair: BinaryKeyPair; keyPairBits: BinaryKeyPair; } /** * Symmetric key. */ export interface SymmetricKey extends Key { type: KeyType.oct; private: string; d: string; } /** * Generic key factory. */ export declare function Key(properties: Partial): Key; /** * EC private key factory. */ export declare function PrivateKey(privateKey: Bytes | BinaryKeyPair, options?: Partial): PrivateKey; /** * EC public key factory. */ export declare function PublicKey(publicKey: Bytes, options?: Partial): PublicKey; /** * Symmetric key factory. */ export declare function SymmetricKey(privateKey: Bytes, options?: Partial): Key; export declare namespace Key { /** * Diffie-Hellman shared secret computation. * * We provide this for platforms without a native implementation. */ function sharedSecretFor(key: PrivateKey, peerKey: PublicKey): Bytes; } //# sourceMappingURL=Key.d.ts.map