import { type TRet } from '@noble/hashes/utils.js'; import * as P from 'micro-packed'; /** Utility */ interface JsonWebKey { crv?: string | undefined; d?: string | undefined; dp?: string | undefined; dq?: string | undefined; e?: string | undefined; k?: string | undefined; kty?: string | undefined; n?: string | undefined; p?: string | undefined; q?: string | undefined; qi?: string | undefined; x?: string | undefined; y?: string | undefined; [key: string]: unknown; } type ECConverter = { publicKey: P.Coder; secretKey: { encode(from: Uint8Array, opts?: Opts): T; decode(to: T): Uint8Array; }; }; type JWKConverter = ECConverter; /** DSA domain parameters carried by an AlgorithmIdentifier. */ export type DSAParams = { p: bigint; q: bigint; g: bigint; }; export declare const DSAParameters: P.CoderType; /** Bounded DER INTEGER used for an encoded DSA public key value. */ export declare const DSAPublicKey: P.CoderType; export declare const KeyAlgorithm: P.CoderType; export type RSAOtherPrimeInfo = { prime: bigint; exponent: bigint; coefficient: bigint; }; export type RSAPrivateKeyValue = { version: bigint; modulus: bigint; publicExponent: bigint; privateExponent: bigint; prime1: bigint; prime2: bigint; exponent1: bigint; exponent2: bigint; coefficient: bigint; otherPrimeInfos?: RSAOtherPrimeInfo[]; }; /** PKCS#1 RSA public-key value. */ export type RSAPublicKeyValue = { modulus: bigint; publicExponent: bigint; }; /** Elliptic-curve parameter encoding used by DER key structures. */ export type ECParams = { TAG: 'namedCurve'; data: string; } | { TAG: 'implicitCurve'; data: null; } | { TAG: 'specifiedCurve'; data: unknown; }; /** Algorithm identifier payload for DER key structures. */ export type KeyInfo = { TAG: 'EC'; data: ECParams; } | { TAG: 'X25519'; data: null; } | { TAG: 'X448'; data: null; } | { TAG: 'Ed25519'; data: null; } | { TAG: 'Ed448'; data: null; } | { TAG: 'rsaEncryption'; data: null; } | { TAG: 'DSA'; data: DSAParams | undefined; }; /** Top-level algorithm wrapper for DER key structures. */ export type Algo = { /** Algorithm identifier and its associated parameters. */ info: KeyInfo; }; type PKCS8Secret = { TAG: 'raw'; data: Uint8Array; } | { TAG: 'struct'; data: { version: bigint; privateKey: Uint8Array; parameters?: ECParams; publicKey?: Uint8Array; }; }; /** Decoded PKCS#8 private-key structure. */ export type PKCS8Key = { /** PKCS#8 version field. */ version: bigint; /** Algorithm identifier describing the wrapped private key. */ algorithm: Algo; /** Raw or structured private-key payload. */ privateKey: PKCS8Secret; /** Optional PKCS#8 attributes carried alongside the key. */ attributes?: Uint8Array[]; /** Optional public key attached to the private-key structure. */ publicKey?: Uint8Array; }; /** Decoded SubjectPublicKeyInfo structure. */ export type SPKIKey = { /** Algorithm identifier describing the public key. */ algorithm: Algo; /** Encoded public-key bytes. */ publicKey: Uint8Array; }; export declare const PKCS8SecretKey: P.CoderType; export declare const PKCS8: P.CoderType; export declare const SPKI: P.CoderType; /** Strict PKCS#1 RSAPublicKey parser with finite integer-width policy. */ export declare const RSAPublicKey: P.CoderType; export declare const RSAPrivateKey: P.CoderType; type DEROpts = { noPublicKey?: boolean; compressed?: boolean; }; type DERConverter = ECConverter; /** * JWK converter for P-256 signing keys. * @example * Encode a freshly generated P-256 signing key as JWK. * ```ts * import { p256 } from '@noble/curves/nist.js'; * import { p256_jwk } from 'micro-key-producer/convert.js'; * p256_jwk.secretKey.encode(p256.utils.randomSecretKey()); * ``` */ export declare const p256_jwk: TRet; /** * JWK converter for P-256 ECDH keys. * @example * Encode a P-256 private key for ECDH-oriented JWK consumers. * ```ts * import { p256 } from '@noble/curves/nist.js'; * import { p256_jwk_ecdh } from 'micro-key-producer/convert.js'; * p256_jwk_ecdh.secretKey.encode(p256.utils.randomSecretKey()); * ``` */ export declare const p256_jwk_ecdh: TRet; /** * DER converter for P-256 keys. * @example * Encode the same P-256 secret key into DER/PKCS#8 form. * ```ts * import { p256 } from '@noble/curves/nist.js'; * import { p256_der } from 'micro-key-producer/convert.js'; * p256_der.secretKey.encode(p256.utils.randomSecretKey()); * ``` */ export declare const p256_der: TRet; /** * JWK converter for P-384 signing keys. * @example * Encode a freshly generated P-384 signing key as JWK. * ```ts * import { p384 } from '@noble/curves/nist.js'; * import { p384_jwk } from 'micro-key-producer/convert.js'; * p384_jwk.secretKey.encode(p384.utils.randomSecretKey()); * ``` */ export declare const p384_jwk: TRet; /** * JWK converter for P-384 ECDH keys. * @example * Encode a P-384 private key for ECDH-oriented JWK consumers. * ```ts * import { p384 } from '@noble/curves/nist.js'; * import { p384_jwk_ecdh } from 'micro-key-producer/convert.js'; * p384_jwk_ecdh.secretKey.encode(p384.utils.randomSecretKey()); * ``` */ export declare const p384_jwk_ecdh: TRet; /** * DER converter for P-384 keys. * @example * Encode the same P-384 secret key into DER/PKCS#8 form. * ```ts * import { p384 } from '@noble/curves/nist.js'; * import { p384_der } from 'micro-key-producer/convert.js'; * p384_der.secretKey.encode(p384.utils.randomSecretKey()); * ``` */ export declare const p384_der: TRet; /** * JWK converter for P-521 signing keys. * @example * Encode a freshly generated P-521 signing key as JWK. * ```ts * import { p521 } from '@noble/curves/nist.js'; * import { p521_jwk } from 'micro-key-producer/convert.js'; * p521_jwk.secretKey.encode(p521.utils.randomSecretKey()); * ``` */ export declare const p521_jwk: TRet; /** * JWK converter for P-521 ECDH keys. * @example * Encode a P-521 private key for ECDH-oriented JWK consumers. * ```ts * import { p521 } from '@noble/curves/nist.js'; * import { p521_jwk_ecdh } from 'micro-key-producer/convert.js'; * p521_jwk_ecdh.secretKey.encode(p521.utils.randomSecretKey()); * ``` */ export declare const p521_jwk_ecdh: TRet; /** * DER converter for P-521 keys. * @example * Encode the same P-521 secret key into DER/PKCS#8 form. * ```ts * import { p521 } from '@noble/curves/nist.js'; * import { p521_der } from 'micro-key-producer/convert.js'; * p521_der.secretKey.encode(p521.utils.randomSecretKey()); * ``` */ export declare const p521_der: TRet; /** * JWK converter for Ed25519 keys. * @example * Encode an Ed25519 secret key into JWK form. * ```ts * import { ed25519 } from '@noble/curves/ed25519.js'; * import { ed25519_jwk } from 'micro-key-producer/convert.js'; * ed25519_jwk.secretKey.encode(ed25519.utils.randomSecretKey()); * ``` */ export declare const ed25519_jwk: TRet; /** * DER converter for Ed25519 keys. * @example * Encode the same Ed25519 secret key into DER/PKCS#8 form. * ```ts * import { ed25519 } from '@noble/curves/ed25519.js'; * import { ed25519_der } from 'micro-key-producer/convert.js'; * ed25519_der.secretKey.encode(ed25519.utils.randomSecretKey()); * ``` */ export declare const ed25519_der: TRet; /** * JWK converter for Ed448 keys. * @example * Encode an Ed448 secret key into JWK form. * ```ts * import { ed448 } from '@noble/curves/ed448.js'; * import { ed448_jwk } from 'micro-key-producer/convert.js'; * ed448_jwk.secretKey.encode(ed448.utils.randomSecretKey()); * ``` */ export declare const ed448_jwk: TRet; /** * DER converter for Ed448 keys. * @example * Encode the same Ed448 secret key into DER/PKCS#8 form. * ```ts * import { ed448 } from '@noble/curves/ed448.js'; * import { ed448_der } from 'micro-key-producer/convert.js'; * ed448_der.secretKey.encode(ed448.utils.randomSecretKey()); * ``` */ export declare const ed448_der: TRet; /** * JWK converter for X25519 keys. * @example * Encode an X25519 private key into JWK form. * ```ts * import { x25519 } from '@noble/curves/ed25519.js'; * import { x25519_jwk } from 'micro-key-producer/convert.js'; * x25519_jwk.secretKey.encode(x25519.utils.randomSecretKey()); * ``` */ export declare const x25519_jwk: TRet; /** * DER converter for X25519 keys. * @example * Encode the same X25519 secret key into DER/PKCS#8 form. * ```ts * import { x25519 } from '@noble/curves/ed25519.js'; * import { x25519_der } from 'micro-key-producer/convert.js'; * x25519_der.secretKey.encode(x25519.utils.randomSecretKey()); * ``` */ export declare const x25519_der: TRet; /** * JWK converter for X448 keys. * @example * Encode an X448 private key into JWK form. * ```ts * import { x448 } from '@noble/curves/ed448.js'; * import { x448_jwk } from 'micro-key-producer/convert.js'; * x448_jwk.secretKey.encode(x448.utils.randomSecretKey()); * ``` */ export declare const x448_jwk: TRet; /** * DER converter for X448 keys. * @example * Encode the same X448 secret key into DER/PKCS#8 form. * ```ts * import { x448 } from '@noble/curves/ed448.js'; * import { x448_der } from 'micro-key-producer/convert.js'; * x448_der.secretKey.encode(x448.utils.randomSecretKey()); * ``` */ export declare const x448_der: TRet; export {};