/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { Bytes } from "#util/Bytes.js";
import { MaybePromise } from "#util/Promises.js";
import * as mod from "@noble/curves/abstract/modular.js";
import * as utils from "@noble/curves/utils.js";
import { Entropy } from "../util/Entropy.js";
import { EcdsaSignature } from "./EcdsaSignature.js";
import type { PrivateKey, PublicKey } from "./Key.js";
export declare const ec: {
    abytes: <T extends utils.TArg<Uint8Array<ArrayBufferLike>>>(value: T, length?: number, title?: string) => T;
    anumber: typeof import("@noble/hashes/utils.js").anumber;
    bytesToHex: typeof import("@noble/hashes/utils.js").bytesToHex;
    concatBytes: (...arrays: utils.TArg<Uint8Array<ArrayBufferLike>[]>) => Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>;
    hexToBytes: (hex: string) => Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>;
    isBytes: typeof import("@noble/hashes/utils.js").isBytes;
    randomBytes: (bytesLength?: number) => Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>;
    abool(value: boolean, title?: string): boolean;
    abignumber<T extends number | bigint>(n: T): T;
    asafenumber(value: number, title?: string): void;
    numberToHexUnpadded(num: number | bigint): string;
    hexToNumber(hex: string): bigint;
    bytesToNumberBE(bytes: utils.TArg<Uint8Array>): bigint;
    bytesToNumberLE(bytes: utils.TArg<Uint8Array>): bigint;
    numberToBytesBE(n: number | bigint, len: number): utils.TRet<Uint8Array>;
    numberToBytesLE(n: number | bigint, len: number): utils.TRet<Uint8Array>;
    numberToVarBytesBE(n: number | bigint): utils.TRet<Uint8Array>;
    equalBytes(a: utils.TArg<Uint8Array>, b: utils.TArg<Uint8Array>): boolean;
    copyBytes(bytes: utils.TArg<Uint8Array>): utils.TRet<Uint8Array>;
    asciiToBytes(ascii: string): utils.TRet<Uint8Array>;
    inRange(n: bigint, min: bigint, max: bigint): boolean;
    aInRange(title: string, n: bigint, min: bigint, max: bigint): void;
    bitLen(n: bigint): number;
    bitGet(n: bigint, pos: number): bigint;
    bitSet(n: bigint, pos: number, value: boolean): bigint;
    bitMask: (n: number) => bigint;
    createHmacDrbg<T>(hashLen: number, qByteLen: number, hmacFn: utils.TArg<utils.HmacFn>): utils.TRet<(seed: Uint8Array, predicate: (v: utils.TArg<Uint8Array>) => T | undefined) => T>;
    validateObject(object: Record<string, any>, fields?: Record<string, string>, optFields?: Record<string, string>): void;
    notImplemented: () => never;
    mod(a: bigint, b: bigint): bigint;
    pow(num: bigint, power: bigint, modulo: bigint): bigint;
    pow2(x: bigint, power: bigint, modulo: bigint): bigint;
    invert(number: bigint, modulo: bigint): bigint;
    tonelliShanks(P: bigint): utils.TRet<(<T>(Fp: mod.IField<T>, n: T) => T)>;
    FpSqrt(P: bigint): utils.TRet<(<T>(Fp: mod.IField<T>, n: T) => T)>;
    isNegativeLE: (num: bigint, modulo: bigint) => boolean;
    validateField<T>(field: utils.TArg<mod.IField<T>>): utils.TRet<mod.IField<T>>;
    FpPow<T>(Fp: utils.TArg<mod.IField<T>>, num: T, power: bigint): T;
    FpInvertBatch<T>(Fp: utils.TArg<mod.IField<T>>, nums: T[], passZero?: boolean): T[];
    FpDiv<T>(Fp: utils.TArg<mod.IField<T>>, lhs: T, rhs: T | bigint): T;
    FpLegendre<T>(Fp: utils.TArg<mod.IField<T>>, n: T): -1 | 0 | 1;
    FpIsSquare<T>(Fp: utils.TArg<mod.IField<T>>, n: T): boolean;
    nLength(n: bigint, nBitLength?: number): mod.NLength;
    Field(ORDER: bigint, opts?: Partial<{
        isLE: boolean;
        BITS: number;
        sqrt: (n: bigint) => bigint;
        allowedLengths?: readonly number[];
        modFromBytes: boolean;
    }>): utils.TRet<Readonly<mod.IField<bigint> & Required<Pick<mod.IField<bigint>, "isOdd">>>>;
    FpSqrtOdd<T>(Fp: utils.TArg<mod.IField<T>>, elm: T): T;
    FpSqrtEven<T>(Fp: utils.TArg<mod.IField<T>>, elm: T): T;
    getFieldBytesLength(fieldOrder: bigint): number;
    getMinHashLength(fieldOrder: bigint): number;
    mapHashToField(key: utils.TArg<Uint8Array>, fieldOrder: bigint, isLE?: boolean): utils.TRet<Uint8Array>;
    p256: import("@noble/curves/abstract/weierstrass.js").ECDSA;
};
export declare const CRYPTO_ENCRYPT_ALGORITHM = "aes-128-ccm";
export declare const CRYPTO_HASH_ALGORITHM = "sha256";
export declare const CRYPTO_EC_CURVE = "prime256v1";
export declare const CRYPTO_EC_KEY_BYTES = 32;
export declare const CRYPTO_AUTH_TAG_LENGTH = 16;
export declare const CRYPTO_SYMMETRIC_KEY_LENGTH = 16;
/** Hash algorithm names supported by the Matter crypto primitives. */
export type HashAlgorithm = "SHA-1" | "SHA-256" | "SHA-512" | "SHA-384" | "SHA-512/224" | "SHA-512/256" | "SHA3-256";
export declare const HASH_ALGORITHM_OUTPUT_LENGTHS: Record<HashAlgorithm, number>;
/**
 * Identifiers from the IANA Named Information (NI) Hash Algorithm Registry (RFC 6920), used as the OTA
 * image digest type (Matter Core §11.21.2.4.9) and the DCL data digest type. Limited to the registry
 * algorithms the Matter crypto primitives can compute; SHA3-256 availability is backend-dependent (no
 * browser Web Crypto support).
 */
export declare enum HashAlgorithmId {
    "SHA-256" = 1,
    "SHA-384" = 7,
    "SHA-512" = 8,
    "SHA3-256" = 10
}
/** Subset of {@link HashAlgorithm} that has an IANA NI registry identifier (see {@link HashAlgorithmId}). */
export type IdentifiedHashAlgorithm = keyof typeof HashAlgorithmId;
/** Resolves an IANA NI registry identifier to its {@link IdentifiedHashAlgorithm} name, or undefined if unsupported. */
export declare function hashAlgorithmForId(id: number): IdentifiedHashAlgorithm | undefined;
/**
 * These are the cryptographic primitives required to implement the Matter protocol.
 *
 * We provide a platform-independent implementation that uses Web Crypto via {@link crypto.subtle} and a JS-based
 * AES-CCM implementation.
 *
 * If your platform does not fully implement Web Crypto, or offers a native implementation of AES-CCM, you can replace
 * the implementation in {@link Environment.default}.
 *
 * WARNING: The standard implementation is unaudited.  See relevant warnings in StandardCrypto.ts.
 */
export declare abstract class Crypto extends Entropy {
    /**
     * The name used in log messages.
     */
    abstract implementationName: string;
    /**
     * Encrypt using AES-CCM with constants limited to those required by Matter.
     */
    abstract encrypt(key: Bytes, data: Bytes, nonce: Bytes, aad?: Bytes): Bytes;
    /**
     * Decrypt using AES-CCM with constants limited to those required by Matter.
     */
    abstract decrypt(key: Bytes, data: Bytes, nonce: Bytes, aad?: Bytes): Bytes;
    /**
     * Compute a cryptographic hash using the specified algorithm. If no algorithm is specified, SHA-256 is used.
     */
    abstract computeHash(data: Bytes | Bytes[] | ReadableStreamDefaultReader<Bytes> | AsyncIterator<Bytes>, algorithm?: HashAlgorithm): MaybePromise<Bytes>;
    /**
     * Create a key from a secret using PBKDF2.
     */
    abstract createPbkdf2Key(secret: Bytes, salt: Bytes, iteration: number, keyLength: number): MaybePromise<Bytes>;
    /**
     * Create a key from a secret using HKDF. The length parameter defines the length in bytes.
     *
     * @see {@link MatterSpecification.v151.Core} §3.8
     */
    abstract createHkdfKey(secret: Bytes, salt: Bytes, info: Bytes, length?: number): MaybePromise<Bytes>;
    /**
     * Create an HMAC signature.
     */
    abstract signHmac(key: Bytes, data: Bytes): MaybePromise<Bytes>;
    /**
     * Create an ECDSA signature.
     */
    abstract signEcdsa(privateKey: JsonWebKey, data: Bytes | Bytes[]): MaybePromise<EcdsaSignature>;
    /**
     * Authenticate an ECDSA signature.
     */
    abstract verifyEcdsa(publicKey: JsonWebKey, data: Bytes, signature: EcdsaSignature): MaybePromise<void>;
    /**
     * Create a general-purpose EC key.
     */
    abstract createKeyPair(): MaybePromise<PrivateKey>;
    /**
     * Compute the shared secret for a Diffie-Hellman exchange.
     */
    abstract generateDhSecret(key: PrivateKey, peerKey: PublicKey): MaybePromise<Bytes>;
    /**
     * Multiply an EC point by a scalar on the P-256 curve.
     *
     * @param point - 65-byte uncompressed EC point (04 || x || y)
     * @param scalar - 32-byte big-endian scalar
     * @returns 65-byte uncompressed EC point
     */
    abstract ecMultiply(point: Bytes, scalar: Bytes): Bytes;
    /**
     * Add two EC points on the P-256 curve.
     *
     * @param a - 65-byte uncompressed EC point (04 || x || y)
     * @param b - 65-byte uncompressed EC point (04 || x || y)
     * @returns 65-byte uncompressed EC point
     */
    ecAdd(a: Bytes, b: Bytes): Bytes;
    /**
     * Negate an EC point on the P-256 curve.
     *
     * @param point - 65-byte uncompressed EC point (04 || x || y)
     * @returns 65-byte uncompressed EC point
     */
    ecNegate(point: Bytes): Bytes;
    reportUsage(component?: string): void;
}
//# sourceMappingURL=Crypto.d.ts.map