micro-key-producer
Version:
Produces secure passwords & keys for WebCrypto, SSH, PGP, SLIP10, OTP and many others
49 lines • 1.79 kB
TypeScript
/**
* Formats a Tor v3 onion address from an ed25519 public key.
* @param pubBytes - Raw ed25519 public key bytes.
* @returns `.onion` address.
* @example
* Convert the exported Tor public key bytes into the user-facing `.onion` address.
* ```ts
* import { randomBytes } from '@noble/hashes/utils.js';
* import { formatPublicKey, getKeys } from 'micro-key-producer/tor.js';
* const seed = randomBytes(32);
* formatPublicKey(getKeys(seed).publicKeyBytes);
* ```
*/
export declare function formatPublicKey(pubBytes: Uint8Array): string;
/**
* Parses a Tor v3 onion address back into its public key bytes.
* @param address - `.onion` address.
* @returns Raw ed25519 public key bytes.
* @throws If the onion suffix or checksum is invalid. {@link Error}
* @example
* Recover the raw public key bytes from the published `.onion` address.
* ```ts
* import { randomBytes } from '@noble/hashes/utils.js';
* import { getKeys, parseAddress } from 'micro-key-producer/tor.js';
* const seed = randomBytes(32);
* parseAddress(getKeys(seed).publicKey);
* ```
*/
export declare function parseAddress(address: string): Uint8Array;
/**
* Derives Tor v3 key material from an ed25519 seed.
* @param seed - 32-byte ed25519 seed.
* @returns Public key bytes, onion address, and Tor private key string.
* @example
* Start from a seed and export both the onion address and Tor private-key text.
* ```ts
* import { randomBytes } from '@noble/hashes/utils.js';
* import { getKeys } from 'micro-key-producer/tor.js';
* const seed = randomBytes(32);
* getKeys(seed).publicKey;
* ```
*/
export declare function getKeys(seed: Uint8Array): {
publicKeyBytes: Uint8Array;
publicKey: string;
privateKey: string;
};
export default getKeys;
//# sourceMappingURL=tor.d.ts.map