/** * @license * Copyright 2022-2024 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ 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: Uint8Array; privateKey: Uint8Array; }; /** * 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?: Uint8Array; /** * Binary alias to the x field. Automatically encodes/decodes the base-64 * x-point on EC public keys. */ xBits?: Uint8Array; /** * Binary alias to the y field. Automatically encodes/decodes the base-64 * y-point on EC public keys. */ yBits?: Uint8Array; /** * Import (write-only) of private keys encoded in SEC1 format. */ sec1?: Uint8Array; /** * Import (write-only) of private keys encoded in PKCS #8 format. */ pkcs8?: Uint8Array; /** * Import (write-only) of public keys encoded in SPKI format. */ spki?: Uint8Array; /** * Import/export of EC public key in SEC1/SPKI format. Maps to x & y * fields internally. */ publicBits?: Uint8Array; /** * 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: Uint8Array; /** * Alias for privateBits that throws if no private key is present. */ privateKey: Uint8Array; /** * 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: Uint8Array; yBits: Uint8Array; publicBits: Uint8Array; } /** * EC key with extractable private fields. */ export interface PrivateKey extends PublicKey { private: string; d: string; privateBits: Uint8Array; privateKey: Uint8Array; 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; /** * Private key factory. */ export declare function PrivateKey(privateKey: Uint8Array | BinaryKeyPair, options?: Partial): PrivateKey; /** * Public key factory. */ export declare function PublicKey(publicKey: Uint8Array, options?: Partial): PublicKey; /** * Symmetric key factory. */ export declare function SymmetricKey(privateKey: Uint8Array, options?: Partial): Key; //# sourceMappingURL=Key.d.ts.map