/** * Supported Multihash algorithm identifiers. */ export declare enum MultihashAlgorithm { SHA2_256 = 18, SHA2_384 = 32, SHA3_256 = 22, SHA3_384 = 21 } /** * Supported multikey (multicodec key) identifiers, public and private, for * the Ed25519/X25519 and NIST P-curve suites. */ export declare enum MultikeyCodec { ED25519_PUB = 237, X25519_PUB = 236, ED25519_PRIV = 4864, X25519_PRIV = 4866, P256_PUB = 4608, P384_PUB = 4609, P521_PUB = 4610, P256_PRIV = 4870, P384_PRIV = 4871, P521_PRIV = 4872 } /** * Creates a multihash from an already-computed digest and its algorithm. * * @param digest {Uint8Array} The digest bytes. * @param algorithm {MultihashAlgorithm} The hash algorithm used. * @returns {Uint8Array} The multihash. */ export declare function createMultihash(digest: Uint8Array, algorithm: MultihashAlgorithm): Uint8Array; /** * Decodes a multihash, validating its algorithm and digest length. * * @param bytes {Uint8Array} The multihash bytes. * @param [expectedAlgorithm] {MultihashAlgorithm} When supplied, the decoded * algorithm must match it, so a caller that only accepts one algorithm does * not have to compare after the fact. * @returns {{ algorithm: MultihashAlgorithm, digestLength: number, digest: Uint8Array }} */ export declare function decodeMultihash(bytes: Uint8Array, expectedAlgorithm?: MultihashAlgorithm): { algorithm: MultihashAlgorithm; digestLength: number; digest: Uint8Array; }; /** * Decodes a multikey -- a multicodec-prefixed key, per the multiformats * multicodec table (https://github.com/multiformats/multicodec) -- carried as * a base58btc multibase string (the `z` prefix). The leading varint names the * key type and the remaining bytes are the raw key. * * Both the public- and private-key codecs of the Ed25519/X25519 and NIST * P-curve suites are covered. The public and private codecs of one curve are * distinct codecs, so an `ED25519_PUB` expectation still rejects an * `ED25519_PRIV` multikey (and the other way round). * * The expectation parameter sits on the codec here and on the algorithm in * `decodeMultihash`, because the two layouts carry different identifiers: a * multihash has no multikey codec, and a multikey has no digest algorithm. * * Decoding stays hashing-free; base58 is a pure codec. * * @param options {object} * @param options.multikey {string} The `z`-prefixed base58btc multikey. * @param [options.expectedCodec] {MultikeyCodec} When supplied, the decoded * codec must match it. * @returns {{ codec: MultikeyCodec, keyBytes: Uint8Array }} The decoded codec * and the raw key bytes, without the multicodec prefix. */ export declare function decodeMultikey({ multikey, expectedCodec }: { multikey: string; expectedCodec?: MultikeyCodec; }): { codec: MultikeyCodec; keyBytes: Uint8Array; }; //# sourceMappingURL=Multihash.d.ts.map