export { constants } from './lib'
+declare global {
+ type Bytes = Uint8Array<ArrayBuffer>
+}
+
/**
* Nano public key derivation using WebAssembly. If byte output is required,
* pass a target buffer as a second argument.
- * @param {(Uint8Array<ArrayBuffer> | string)} prv - 32-byte private key
+ * @param {(Bytes | string)} prv - 32-byte private key
* @returns 32-byte public key
*/
-export function derive (prv: Uint8Array<ArrayBuffer> | string): string
+export function derive (prv: Bytes | string): string
/**
* Nano public key derivation using WebAssembly. Instead of allocating an output
* buffer internally for the return value, public key bytes are written to the
* the user-supplied output buffer.
- * @param {(Uint8Array<ArrayBuffer> | string)} prv - 32-byte private key
- * @param {Uint8Array<ArrayBuffer>} out - buffer to receive 32-byte public key
+ * @param {(Bytes | string)} prv - 32-byte private key
+ * @param {Bytes} out - buffer to receive 32-byte public key
*/
-export function derive (prv: Uint8Array<ArrayBuffer> | string, out: Uint8Array<ArrayBuffer>): void
-export function derive (prv: Uint8Array<ArrayBuffer> | string, out?: Uint8Array<ArrayBuffer>): string | void {
+export function derive (prv: Bytes | string, out: Bytes): void
+export function derive (prv: Bytes | string, out?: Bytes): string | void {
return nano25519.derive(prv, out)
}
/**
* Signing using WebAssembly. To sign Nano blocks, the message should be a
* 32-byte block hash.
- * @param {(Uint8Array<ArrayBuffer> | string)} msg - Variable-byte-length message up to 64 KiB
- * @param {(Uint8Array<ArrayBuffer> | string)} prv - 32-byte private key
- * @param {(Uint8Array<ArrayBuffer> | string)} pub - 32-byte public key
+ * @param {(Bytes | string)} msg - Variable-byte-length message up to 64 KiB
+ * @param {(Bytes | string)} prv - 32-byte private key
+ * @param {(Bytes | string)} pub - 32-byte public key
* @returns 64-byte detached signature
*/
-export function sign (msg: Uint8Array<ArrayBuffer> | string, prv: Uint8Array<ArrayBuffer> | string, pub: Uint8Array<ArrayBuffer> | string): string
+export function sign (msg: Bytes | string, prv: Bytes | string, pub: Bytes | string): string
/**
* Signing using WebAssembly. To sign Nano blocks, the message should be a
* 32-byte block hash. Instead of allocating an output buffer internally for the
* return value, signature bytes are written to the the user-supplied output
* buffer.
- * @param {(Uint8Array<ArrayBuffer> | string)} msg - Variable-byte-length message up to 64 KiB
- * @param {(Uint8Array<ArrayBuffer> | string)} prv - 32-byte private key
- * @param {(Uint8Array<ArrayBuffer> | string)} pub - 32-byte public key
- * @param {(Uint8Array<ArrayBuffer> | string)} out - buffer to receive 64-byte detached signature
+ * @param {(Bytes | string)} msg - Variable-byte-length message up to 64 KiB
+ * @param {(Bytes | string)} prv - 32-byte private key
+ * @param {(Bytes | string)} pub - 32-byte public key
+ * @param {(Bytes | string)} out - buffer to receive 64-byte detached signature
*/
-export function sign (msg: Uint8Array<ArrayBuffer> | string, prv: Uint8Array<ArrayBuffer> | string, pub: Uint8Array<ArrayBuffer> | string, out: Uint8Array<ArrayBuffer>): void
-export function sign (msg: Uint8Array<ArrayBuffer> | string, prv: Uint8Array<ArrayBuffer> | string, pub: Uint8Array<ArrayBuffer> | string, out?: Uint8Array<ArrayBuffer>): string | void {
+export function sign (msg: Bytes | string, prv: Bytes | string, pub: Bytes | string, out: Bytes): void
+export function sign (msg: Bytes | string, prv: Bytes | string, pub: Bytes | string, out?: Bytes): string | void {
return nano25519.sign(msg, prv, pub, out)
}
/**
* Signature verification using WebAssembly. To verify Nano block signatures,
* use `verify_blocks()` instead.
- * @param {(Uint8Array<ArrayBuffer> | string)} sig - 64-byte detached signature
- * @param {(Uint8Array<ArrayBuffer> | string)} msg - Variable-byte-length message up to 64 KiB
- * @param {(Uint8Array<ArrayBuffer> | string)} pub - 32-byte public key
+ * @param {(Bytes | string)} sig - 64-byte detached signature
+ * @param {(Bytes | string)} msg - Variable-byte-length message up to 64 KiB
+ * @param {(Bytes | string)} pub - 32-byte public key
* @returns true if signature matches block hash and public key, else false
*/
-export function verify (sig: Uint8Array<ArrayBuffer> | string, msg: Uint8Array<ArrayBuffer> | string, pub: Uint8Array<ArrayBuffer> | string): boolean {
+export function verify (sig: Bytes | string, msg: Bytes | string, pub: Bytes | string): boolean {
return nano25519.verify(sig, msg, pub)
}
/**
* Nano block signature bulk verification using WebAssembly.
- * @param {(Uint8Array<ArrayBuffer> | string)} publicKey - 32-byte public key
+ * @param {(Bytes | string)} publicKey - 32-byte public key
* @param {object[]} blocks - Array of up to 64 block signature/hash pairs
- * @param {(Uint8Array<ArrayBuffer> | string)} blocks.signature - 64-byte block signature
- * @param {(Uint8Array<ArrayBuffer> | string)} blocks.hash - 32-byte block hash
+ * @param {(Bytes | string)} blocks.signature - 64-byte block signature
+ * @param {(Bytes | string)} blocks.hash - 32-byte block hash
* @returns Array of results with, for each case, true if signature matches block hash and public key, else false
*/
-export function verify_blocks (publicKey: Uint8Array<ArrayBuffer> | string, blocks: { signature: Uint8Array<ArrayBuffer> | string, hash: Uint8Array<ArrayBuffer> | string }[]): boolean[] {
+export function verify_blocks (publicKey: Bytes | string, blocks: { signature: Bytes | string, hash: Bytes | string }[]): boolean[] {
return nano25519.verify_blocks(publicKey, blocks)
}