UNPKG

@hiero-ledger/cryptography

Version:

Cryptographic utilities and primitives for the Hiero SDK

103 lines (102 loc) 3.13 kB
export const derPrefix: "302e020100300506032b657004220420"; export const derPrefixBytes: Uint8Array<ArrayBufferLike>; export default class Ed25519PrivateKey { /** * Generate a random Ed25519 private key. * @returns {Ed25519PrivateKey} */ static generate(): Ed25519PrivateKey; /** * Generate a random Ed25519 private key. * @returns {Promise<Ed25519PrivateKey>} */ static generateAsync(): Promise<Ed25519PrivateKey>; /** * Construct a private key from bytes. * @param {Uint8Array} data * @returns {Ed25519PrivateKey} */ static fromBytes(data: Uint8Array): Ed25519PrivateKey; /** * Construct a private key from bytes with DER header. * @param {Uint8Array} data * @returns {Ed25519PrivateKey} */ static fromBytesDer(data: Uint8Array): Ed25519PrivateKey; /** * Construct a private key from bytes without DER header. * @param {Uint8Array} data * @returns {Ed25519PrivateKey} */ static fromBytesRaw(data: Uint8Array): Ed25519PrivateKey; /** * Construct a private key from a hex-encoded string. * @param {string} text * @returns {Ed25519PrivateKey} */ static fromString(text: string): Ed25519PrivateKey; /** * Construct a private key from a hex-encoded string. * @param {string} text * @returns {Ed25519PrivateKey} */ static fromStringDer(text: string): Ed25519PrivateKey; /** * Construct a private key from a hex-encoded string. * @param {string} text * @returns {Ed25519PrivateKey} */ static fromStringRaw(text: string): Ed25519PrivateKey; /** * Construct a ED25519 private key from a Uint8Array seed. * @param {Uint8Array} seed * @returns {Promise<Ed25519PrivateKey>} */ static fromSeed(seed: Uint8Array): Promise<Ed25519PrivateKey>; /** * @hideconstructor * @internal * @param {nacl.SignKeyPair | Uint8Array} keyPair * @param {Uint8Array=} chainCode */ constructor(keyPair: nacl.SignKeyPair | Uint8Array, chainCode?: Uint8Array | undefined); /** * @type {nacl.SignKeyPair} * @readonly * @private */ private readonly _keyPair; /** * @type {?Uint8Array} * @readonly */ readonly _chainCode: Uint8Array | null; /** * @returns {string} */ get _type(): string; /** * Get the public key associated with this private key. * * The public key can be freely given and used by other parties to verify * the signatures generated by this private key. * @returns {Ed25519PublicKey} */ get publicKey(): Ed25519PublicKey; /** * Sign a message with this private key. * @param {Uint8Array} bytes * @returns {Uint8Array} - The signature bytes without the message */ sign(bytes: Uint8Array): Uint8Array; /** * @returns {Uint8Array} */ toBytesDer(): Uint8Array; /** * @returns {Uint8Array} */ toBytesRaw(): Uint8Array; } import Ed25519PublicKey from "./Ed25519PublicKey.js"; import nacl from "tweetnacl";