UNPKG

js-crypto-key-utils

Version:

Universal Module for Cryptographic Key Utilities in JavaScript, including PEM-JWK converters

29 lines (28 loc) 1.41 kB
/** * octenc.js */ import { OctetFormat, OctetEC, CurveTypes } from './typedef'; /** * Convert JWK EC public/private keys to octet form. * Compressed form of EC public key is referred to RFC 5480 {@link https://tools.ietf.org/html/rfc5480}. * @param {JsonWebKey} jwkey - A key object in JWK format to be encoded to SEC1 octet format key. * @param {boolean} [outputPublic] - Export public key even from private key if true. * @param {OctetFormat} [outputFormat='binary'] - 'binary' or 'string'. * @param {boolean} [compact=false] - Export compressed form of public key if true. * @return {Uint8Array|string} - Encoded key object in JWK format. */ export declare const fromJwk: (jwkey: JsonWebKey, { outputPublic, outputFormat, compact }: { outputPublic?: boolean | undefined; outputFormat?: OctetFormat | undefined; compact?: boolean | undefined; }) => Uint8Array | string; /** * Convert Octet form of EC public/private keys to JWK. * @param {OctetEC} octkey - OctetEC key object in hex string format or Uint8Array. * @param {String} namedCurve - Name of elliptic curve like 'P-256'. * @param {boolean} [outputPublic] - Export public key even from private key if true. * @return {JsonWebKey} - Derived key object in JWK format. */ export declare const toJwk: (octkey: OctetEC, namedCurve: CurveTypes, { outputPublic }: { outputPublic?: boolean | undefined; }) => JsonWebKey;