UNPKG

libnemo

Version:

Nano cryptocurrency wallet library.

93 lines (92 loc) 4.66 kB
/** * Ported in 2014 by Dmitry Chestnykh and Devi Mandiri. * Public domain. * * Implementation derived from TweetNaCl version 20140427: http://tweetnacl.cr.yp.to/ * * Modified to hash secret key to public key using BLAKE2b instead of SHA-512 per * Nano cryptocurrency specifications: https://docs.nano.org/integration-guides/the-basics/ * * Original source commit: https://github.com/dchest/tweetnacl-js/blob/71df1d6a1d78236ca3e9f6c788786e21f5a651a6/nacl-fast.js */ export declare class NanoNaCl { static crypto_sign_BYTES: 64; static crypto_sign_PUBLICKEYBYTES: 32; static crypto_sign_PRIVATEKEYBYTES: 32; static crypto_sign_SEEDBYTES: 32; static D: Float64Array; static D2: Float64Array; static X: Float64Array; static Y: Float64Array; static I: Float64Array; static XY: Float64Array; /** * Checks first 32 bytes of two byte arrays to see if they are equivalent. * * @returns 0 if first 32 bytes are equal, else 1 if there is at least one bit difference */ static vn(x: Uint8Array, y: Uint8Array): number; static pow2523(out: Float64Array, i: Float64Array): void; static car25519(out: Float64Array): void; static inv25519(out: Float64Array, i: Float64Array): void; static neq25519(a: Float64Array, b: Float64Array): number; static pack25519(out: Uint8Array, n: Float64Array): void; static par25519(a: Float64Array): 0 | 1; static sel25519(p: Float64Array, q: Float64Array, b: number): void; static unpack25519(out: Float64Array, n: Uint8Array): void; static Add(out: Float64Array, a: Float64Array, b: Float64Array): void; static Subtract(out: Float64Array, a: Float64Array, b: Float64Array): void; static Multiply(out: Float64Array, a: Float64Array, b: Float64Array): void; static Square(out: Float64Array, a: Float64Array): void; static add(p: Float64Array[], q: Float64Array[]): void; static cswap(p: Float64Array[], q: Float64Array[], b: number): void; static pack(r: Uint8Array, p: Float64Array[]): void; static scalarmult(p: Float64Array[], q: Float64Array[], s: Uint8Array): void; static scalarbase(p: Float64Array[], s: Uint8Array): void; static L: Float64Array<ArrayBuffer>; static modL(r: Uint8Array, x: Float64Array): void; static reduce(r: Uint8Array): void; static unpackneg(r: Float64Array[], p: Uint8Array): number; static crypto_sign(sm: Uint8Array, m: Uint8Array, n: number, sk: Uint8Array, pk: Uint8Array): void; static crypto_sign_open(m: Uint8Array, sm: Uint8Array, n: number, pk: Uint8Array): number; /** * Derives a public key from a private key "seed". * * @param {Uint8Array<ArrayBuffer>} seed - 32-byte private key * @returns {Uint8Array<ArrayBuffer>} 32-byte public key */ static convert(seed: Uint8Array<ArrayBuffer>): Uint8Array<ArrayBuffer>; /** * Signs the message using the secret key and returns a signature. * * @param {Uint8Array<ArrayBuffer>} message - Message to sign * @param {Uint8Array<ArrayBuffer>} privateKey - 32-byte key to use for signing * @returns {Uint8Array<ArrayBuffer>} 64-byte signature */ static detached(message: Uint8Array<ArrayBuffer>, privateKey: Uint8Array<ArrayBuffer>): Uint8Array<ArrayBuffer>; /** * Verifies the signed message and returns the message without signature. * * @param {Uint8Array<ArrayBuffer>} signedMessage - Signed message * @param {Uint8Array<ArrayBuffer>} publicKey - 32-byte key used to sign message * @returns {Uint8Array<ArrayBuffer>} Message without signature */ static open(signedMessage: Uint8Array<ArrayBuffer>, publicKey: Uint8Array<ArrayBuffer>): Uint8Array<ArrayBuffer>; /** * Signs the message using the secret key and returns a signed message. * * @param {Uint8Array<ArrayBuffer>} message - Message to be signed * @param {Uint8Array<ArrayBuffer>} privateKey - 32-byte key to use for signing * @returns {Uint8Array<ArrayBuffer>} Signed message */ static sign(message: Uint8Array<ArrayBuffer>, privateKey: Uint8Array<ArrayBuffer>): Uint8Array<ArrayBuffer>; /** * Verifies a detached signature for a message. * * @param {Uint8Array<ArrayBuffer>} signedMessage - Signed message * @param {Uint8Array<ArrayBuffer>} signature - 64-byte signature * @param {Uint8Array<ArrayBuffer>} publicKey - 32-byte key used for signing * @returns {boolean} - True if `publicKey` was used to sign `msg` and generate `sig`, else false */ static verify(signedMessage: Uint8Array<ArrayBuffer>, signature: Uint8Array<ArrayBuffer>, publicKey: Uint8Array<ArrayBuffer>): boolean; }