fixed gitignore issue

This commit is contained in:
Matt Hess
2026-02-10 22:40:13 +00:00
parent 9d3e93ebe3
commit 6904ee60a4
4 changed files with 1068 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
# Ignore WASM build intermediates, keep distributable files
package.json
*.wasm.d.ts
+191
View File
@@ -0,0 +1,191 @@
/* tslint:disable */
/* eslint-disable */
/**
* Argon2id key derivation (WASM-accessible).
* password, salt: arbitrary-length byte slices.
* t_cost: number of iterations, m_cost: memory in KiB, parallelism: threads.
* dk_len: desired output length in bytes.
* Returns the derived key bytes, or empty vec on error.
*/
export function argon2id_hash(password: Uint8Array, salt: Uint8Array, t_cost: number, m_cost: number, parallelism: number, dk_len: number): Uint8Array;
/**
* Blake2b with variable output length (unkeyed)
* Matches Salvium C++ blake2b(out, outLen, data, dataLen, NULL, 0)
*/
export function blake2b_hash(data: Uint8Array, out_len: number): Uint8Array;
/**
* Blake2b with key (keyed variant per RFC 7693)
* Matches Salvium C++ blake2b(out, outLen, data, dataLen, key, keyLen)
* Used by CARROT protocol for domain-separated hashing
*/
export function blake2b_keyed(data: Uint8Array, out_len: number, key: Uint8Array): Uint8Array;
export function bulletproof_plus_prove_wasm(amounts_bytes: Uint8Array, masks_flat: Uint8Array): Uint8Array;
export function bulletproof_plus_verify_wasm(proof_data: Uint8Array, commitments_flat: Uint8Array): boolean;
export function clsag_sign_wasm(message: Uint8Array, ring_flat: Uint8Array, secret_key: Uint8Array, commitments_flat: Uint8Array, commitment_mask: Uint8Array, pseudo_output: Uint8Array, secret_index: number): Uint8Array;
export function clsag_verify_wasm(message: Uint8Array, sig_bytes: Uint8Array, ring_flat: Uint8Array, commitments_flat: Uint8Array, pseudo_output: Uint8Array): boolean;
/**
* Derive public key: base + H(derivation || index) * G
*/
export function derive_public_key(derivation: Uint8Array, output_index: number, base_pub: Uint8Array): Uint8Array;
/**
* Derive secret key: base + H(derivation || index) mod L
*/
export function derive_secret_key(derivation: Uint8Array, output_index: number, base_sec: Uint8Array): Uint8Array;
export function double_scalar_mult_base(a: Uint8Array, p: Uint8Array, b: Uint8Array): Uint8Array;
/**
* Generate commitment mask from shared secret
* mask = scReduce32(keccak256("commitment_mask" || sharedSecret))
*/
export function gen_commitment_mask(shared_secret: Uint8Array): Uint8Array;
/**
* Generate key derivation: D = 8 * (sec * pub)
*/
export function generate_key_derivation(pub_key: Uint8Array, sec_key: Uint8Array): Uint8Array;
/**
* Generate key image: KI = sec * H_p(pub)
*/
export function generate_key_image(pub_key: Uint8Array, sec_key: Uint8Array): Uint8Array;
/**
* Hash-to-point: H_p(data) = cofactor * elligator2(keccak256(data))
* Matches Salvium C++ hash_to_ec / ge_fromfe_frombytes_vartime
*/
export function hash_to_point(data: Uint8Array): Uint8Array;
/**
* Keccak-256 hash (CryptoNote variant with 0x01 padding, NOT SHA3)
* Matches Salvium C++ cn_fast_hash / keccak()
*/
export function keccak256(data: Uint8Array): Uint8Array;
/**
* Pedersen commitment: C = mask*G + amount*H
*/
export function pedersen_commit(amount: Uint8Array, mask: Uint8Array): Uint8Array;
export function point_add_compressed(p: Uint8Array, q: Uint8Array): Uint8Array;
export function point_negate(p: Uint8Array): Uint8Array;
export function point_sub_compressed(p: Uint8Array, q: Uint8Array): Uint8Array;
export function sc_add(a: Uint8Array, b: Uint8Array): Uint8Array;
export function sc_check(s: Uint8Array): boolean;
export function sc_invert(a: Uint8Array): Uint8Array;
export function sc_is_zero(s: Uint8Array): boolean;
export function sc_mul(a: Uint8Array, b: Uint8Array): Uint8Array;
export function sc_mul_add(a: Uint8Array, b: Uint8Array, c: Uint8Array): Uint8Array;
export function sc_mul_sub(a: Uint8Array, b: Uint8Array, c: Uint8Array): Uint8Array;
export function sc_reduce32(s: Uint8Array): Uint8Array;
export function sc_reduce64(s: Uint8Array): Uint8Array;
export function sc_sub(a: Uint8Array, b: Uint8Array): Uint8Array;
export function scalar_mult_base(s: Uint8Array): Uint8Array;
export function scalar_mult_point(s: Uint8Array, p: Uint8Array): Uint8Array;
/**
* SHA-256 hash
*/
export function sha256(data: Uint8Array): Uint8Array;
export function tclsag_sign_wasm(message: Uint8Array, ring_flat: Uint8Array, secret_key_x: Uint8Array, secret_key_y: Uint8Array, commitments_flat: Uint8Array, commitment_mask: Uint8Array, pseudo_output: Uint8Array, secret_index: number): Uint8Array;
export function tclsag_verify_wasm(message: Uint8Array, sig_bytes: Uint8Array, ring_flat: Uint8Array, commitments_flat: Uint8Array, pseudo_output: Uint8Array): boolean;
/**
* Zero commitment: C = 1*G + amount*H (blinding factor = 1)
* Matches C++ rct::zeroCommit() used for coinbase outputs and fee commitments.
*/
export function zero_commit(amount: Uint8Array): Uint8Array;
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
export interface InitOutput {
readonly memory: WebAssembly.Memory;
readonly argon2id_hash: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
readonly blake2b_hash: (a: number, b: number, c: number) => [number, number];
readonly blake2b_keyed: (a: number, b: number, c: number, d: number, e: number) => [number, number];
readonly bulletproof_plus_prove_wasm: (a: number, b: number, c: number, d: number) => [number, number];
readonly bulletproof_plus_verify_wasm: (a: number, b: number, c: number, d: number) => number;
readonly clsag_sign_wasm: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => [number, number];
readonly clsag_verify_wasm: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => number;
readonly derive_public_key: (a: number, b: number, c: number, d: number, e: number) => [number, number];
readonly derive_secret_key: (a: number, b: number, c: number, d: number, e: number) => [number, number];
readonly double_scalar_mult_base: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
readonly gen_commitment_mask: (a: number, b: number) => [number, number];
readonly generate_key_derivation: (a: number, b: number, c: number, d: number) => [number, number];
readonly generate_key_image: (a: number, b: number, c: number, d: number) => [number, number];
readonly hash_to_point: (a: number, b: number) => [number, number];
readonly keccak256: (a: number, b: number) => [number, number];
readonly pedersen_commit: (a: number, b: number, c: number, d: number) => [number, number];
readonly point_add_compressed: (a: number, b: number, c: number, d: number) => [number, number];
readonly point_negate: (a: number, b: number) => [number, number];
readonly point_sub_compressed: (a: number, b: number, c: number, d: number) => [number, number];
readonly sc_add: (a: number, b: number, c: number, d: number) => [number, number];
readonly sc_check: (a: number, b: number) => number;
readonly sc_invert: (a: number, b: number) => [number, number];
readonly sc_is_zero: (a: number, b: number) => number;
readonly sc_mul: (a: number, b: number, c: number, d: number) => [number, number];
readonly sc_mul_add: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
readonly sc_mul_sub: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
readonly sc_reduce32: (a: number, b: number) => [number, number];
readonly sc_reduce64: (a: number, b: number) => [number, number];
readonly sc_sub: (a: number, b: number, c: number, d: number) => [number, number];
readonly scalar_mult_base: (a: number, b: number) => [number, number];
readonly scalar_mult_point: (a: number, b: number, c: number, d: number) => [number, number];
readonly sha256: (a: number, b: number) => [number, number];
readonly tclsag_sign_wasm: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number) => [number, number];
readonly tclsag_verify_wasm: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => number;
readonly zero_commit: (a: number, b: number) => [number, number];
readonly __wbindgen_exn_store: (a: number) => void;
readonly __externref_table_alloc: () => number;
readonly __wbindgen_externrefs: WebAssembly.Table;
readonly __wbindgen_malloc: (a: number, b: number) => number;
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
readonly __wbindgen_start: () => void;
}
export type SyncInitInput = BufferSource | WebAssembly.Module;
/**
* Instantiates the given `module`, which can either be bytes or
* a precompiled `WebAssembly.Module`.
*
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
*
* @returns {InitOutput}
*/
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
/**
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
* for everything else, calls `WebAssembly.instantiate` directly.
*
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
*
* @returns {Promise<InitOutput>}
*/
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
+874
View File
@@ -0,0 +1,874 @@
/* @ts-self-types="./salvium_crypto.d.ts" */
/**
* Argon2id key derivation (WASM-accessible).
* password, salt: arbitrary-length byte slices.
* t_cost: number of iterations, m_cost: memory in KiB, parallelism: threads.
* dk_len: desired output length in bytes.
* Returns the derived key bytes, or empty vec on error.
* @param {Uint8Array} password
* @param {Uint8Array} salt
* @param {number} t_cost
* @param {number} m_cost
* @param {number} parallelism
* @param {number} dk_len
* @returns {Uint8Array}
*/
export function argon2id_hash(password, salt, t_cost, m_cost, parallelism, dk_len) {
const ptr0 = passArray8ToWasm0(password, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(salt, wasm.__wbindgen_malloc);
const len1 = WASM_VECTOR_LEN;
const ret = wasm.argon2id_hash(ptr0, len0, ptr1, len1, t_cost, m_cost, parallelism, dk_len);
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v3;
}
/**
* Blake2b with variable output length (unkeyed)
* Matches Salvium C++ blake2b(out, outLen, data, dataLen, NULL, 0)
* @param {Uint8Array} data
* @param {number} out_len
* @returns {Uint8Array}
*/
export function blake2b_hash(data, out_len) {
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.blake2b_hash(ptr0, len0, out_len);
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v2;
}
/**
* Blake2b with key (keyed variant per RFC 7693)
* Matches Salvium C++ blake2b(out, outLen, data, dataLen, key, keyLen)
* Used by CARROT protocol for domain-separated hashing
* @param {Uint8Array} data
* @param {number} out_len
* @param {Uint8Array} key
* @returns {Uint8Array}
*/
export function blake2b_keyed(data, out_len, key) {
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
const len1 = WASM_VECTOR_LEN;
const ret = wasm.blake2b_keyed(ptr0, len0, out_len, ptr1, len1);
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v3;
}
/**
* @param {Uint8Array} amounts_bytes
* @param {Uint8Array} masks_flat
* @returns {Uint8Array}
*/
export function bulletproof_plus_prove_wasm(amounts_bytes, masks_flat) {
const ptr0 = passArray8ToWasm0(amounts_bytes, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(masks_flat, wasm.__wbindgen_malloc);
const len1 = WASM_VECTOR_LEN;
const ret = wasm.bulletproof_plus_prove_wasm(ptr0, len0, ptr1, len1);
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v3;
}
/**
* @param {Uint8Array} proof_data
* @param {Uint8Array} commitments_flat
* @returns {boolean}
*/
export function bulletproof_plus_verify_wasm(proof_data, commitments_flat) {
const ptr0 = passArray8ToWasm0(proof_data, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(commitments_flat, wasm.__wbindgen_malloc);
const len1 = WASM_VECTOR_LEN;
const ret = wasm.bulletproof_plus_verify_wasm(ptr0, len0, ptr1, len1);
return ret !== 0;
}
/**
* @param {Uint8Array} message
* @param {Uint8Array} ring_flat
* @param {Uint8Array} secret_key
* @param {Uint8Array} commitments_flat
* @param {Uint8Array} commitment_mask
* @param {Uint8Array} pseudo_output
* @param {number} secret_index
* @returns {Uint8Array}
*/
export function clsag_sign_wasm(message, ring_flat, secret_key, commitments_flat, commitment_mask, pseudo_output, secret_index) {
const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(ring_flat, wasm.__wbindgen_malloc);
const len1 = WASM_VECTOR_LEN;
const ptr2 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);
const len2 = WASM_VECTOR_LEN;
const ptr3 = passArray8ToWasm0(commitments_flat, wasm.__wbindgen_malloc);
const len3 = WASM_VECTOR_LEN;
const ptr4 = passArray8ToWasm0(commitment_mask, wasm.__wbindgen_malloc);
const len4 = WASM_VECTOR_LEN;
const ptr5 = passArray8ToWasm0(pseudo_output, wasm.__wbindgen_malloc);
const len5 = WASM_VECTOR_LEN;
const ret = wasm.clsag_sign_wasm(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, secret_index);
var v7 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v7;
}
/**
* @param {Uint8Array} message
* @param {Uint8Array} sig_bytes
* @param {Uint8Array} ring_flat
* @param {Uint8Array} commitments_flat
* @param {Uint8Array} pseudo_output
* @returns {boolean}
*/
export function clsag_verify_wasm(message, sig_bytes, ring_flat, commitments_flat, pseudo_output) {
const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(sig_bytes, wasm.__wbindgen_malloc);
const len1 = WASM_VECTOR_LEN;
const ptr2 = passArray8ToWasm0(ring_flat, wasm.__wbindgen_malloc);
const len2 = WASM_VECTOR_LEN;
const ptr3 = passArray8ToWasm0(commitments_flat, wasm.__wbindgen_malloc);
const len3 = WASM_VECTOR_LEN;
const ptr4 = passArray8ToWasm0(pseudo_output, wasm.__wbindgen_malloc);
const len4 = WASM_VECTOR_LEN;
const ret = wasm.clsag_verify_wasm(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
return ret !== 0;
}
/**
* Derive public key: base + H(derivation || index) * G
* @param {Uint8Array} derivation
* @param {number} output_index
* @param {Uint8Array} base_pub
* @returns {Uint8Array}
*/
export function derive_public_key(derivation, output_index, base_pub) {
const ptr0 = passArray8ToWasm0(derivation, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(base_pub, wasm.__wbindgen_malloc);
const len1 = WASM_VECTOR_LEN;
const ret = wasm.derive_public_key(ptr0, len0, output_index, ptr1, len1);
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v3;
}
/**
* Derive secret key: base + H(derivation || index) mod L
* @param {Uint8Array} derivation
* @param {number} output_index
* @param {Uint8Array} base_sec
* @returns {Uint8Array}
*/
export function derive_secret_key(derivation, output_index, base_sec) {
const ptr0 = passArray8ToWasm0(derivation, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(base_sec, wasm.__wbindgen_malloc);
const len1 = WASM_VECTOR_LEN;
const ret = wasm.derive_secret_key(ptr0, len0, output_index, ptr1, len1);
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v3;
}
/**
* @param {Uint8Array} a
* @param {Uint8Array} p
* @param {Uint8Array} b
* @returns {Uint8Array}
*/
export function double_scalar_mult_base(a, p, b) {
const ptr0 = passArray8ToWasm0(a, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(p, wasm.__wbindgen_malloc);
const len1 = WASM_VECTOR_LEN;
const ptr2 = passArray8ToWasm0(b, wasm.__wbindgen_malloc);
const len2 = WASM_VECTOR_LEN;
const ret = wasm.double_scalar_mult_base(ptr0, len0, ptr1, len1, ptr2, len2);
var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v4;
}
/**
* Generate commitment mask from shared secret
* mask = scReduce32(keccak256("commitment_mask" || sharedSecret))
* @param {Uint8Array} shared_secret
* @returns {Uint8Array}
*/
export function gen_commitment_mask(shared_secret) {
const ptr0 = passArray8ToWasm0(shared_secret, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.gen_commitment_mask(ptr0, len0);
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v2;
}
/**
* Generate key derivation: D = 8 * (sec * pub)
* @param {Uint8Array} pub_key
* @param {Uint8Array} sec_key
* @returns {Uint8Array}
*/
export function generate_key_derivation(pub_key, sec_key) {
const ptr0 = passArray8ToWasm0(pub_key, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(sec_key, wasm.__wbindgen_malloc);
const len1 = WASM_VECTOR_LEN;
const ret = wasm.generate_key_derivation(ptr0, len0, ptr1, len1);
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v3;
}
/**
* Generate key image: KI = sec * H_p(pub)
* @param {Uint8Array} pub_key
* @param {Uint8Array} sec_key
* @returns {Uint8Array}
*/
export function generate_key_image(pub_key, sec_key) {
const ptr0 = passArray8ToWasm0(pub_key, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(sec_key, wasm.__wbindgen_malloc);
const len1 = WASM_VECTOR_LEN;
const ret = wasm.generate_key_image(ptr0, len0, ptr1, len1);
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v3;
}
/**
* Hash-to-point: H_p(data) = cofactor * elligator2(keccak256(data))
* Matches Salvium C++ hash_to_ec / ge_fromfe_frombytes_vartime
* @param {Uint8Array} data
* @returns {Uint8Array}
*/
export function hash_to_point(data) {
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.hash_to_point(ptr0, len0);
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v2;
}
/**
* Keccak-256 hash (CryptoNote variant with 0x01 padding, NOT SHA3)
* Matches Salvium C++ cn_fast_hash / keccak()
* @param {Uint8Array} data
* @returns {Uint8Array}
*/
export function keccak256(data) {
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.keccak256(ptr0, len0);
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v2;
}
/**
* Pedersen commitment: C = mask*G + amount*H
* @param {Uint8Array} amount
* @param {Uint8Array} mask
* @returns {Uint8Array}
*/
export function pedersen_commit(amount, mask) {
const ptr0 = passArray8ToWasm0(amount, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(mask, wasm.__wbindgen_malloc);
const len1 = WASM_VECTOR_LEN;
const ret = wasm.pedersen_commit(ptr0, len0, ptr1, len1);
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v3;
}
/**
* @param {Uint8Array} p
* @param {Uint8Array} q
* @returns {Uint8Array}
*/
export function point_add_compressed(p, q) {
const ptr0 = passArray8ToWasm0(p, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(q, wasm.__wbindgen_malloc);
const len1 = WASM_VECTOR_LEN;
const ret = wasm.point_add_compressed(ptr0, len0, ptr1, len1);
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v3;
}
/**
* @param {Uint8Array} p
* @returns {Uint8Array}
*/
export function point_negate(p) {
const ptr0 = passArray8ToWasm0(p, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.point_negate(ptr0, len0);
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v2;
}
/**
* @param {Uint8Array} p
* @param {Uint8Array} q
* @returns {Uint8Array}
*/
export function point_sub_compressed(p, q) {
const ptr0 = passArray8ToWasm0(p, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(q, wasm.__wbindgen_malloc);
const len1 = WASM_VECTOR_LEN;
const ret = wasm.point_sub_compressed(ptr0, len0, ptr1, len1);
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v3;
}
/**
* @param {Uint8Array} a
* @param {Uint8Array} b
* @returns {Uint8Array}
*/
export function sc_add(a, b) {
const ptr0 = passArray8ToWasm0(a, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(b, wasm.__wbindgen_malloc);
const len1 = WASM_VECTOR_LEN;
const ret = wasm.sc_add(ptr0, len0, ptr1, len1);
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v3;
}
/**
* @param {Uint8Array} s
* @returns {boolean}
*/
export function sc_check(s) {
const ptr0 = passArray8ToWasm0(s, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.sc_check(ptr0, len0);
return ret !== 0;
}
/**
* @param {Uint8Array} a
* @returns {Uint8Array}
*/
export function sc_invert(a) {
const ptr0 = passArray8ToWasm0(a, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.sc_invert(ptr0, len0);
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v2;
}
/**
* @param {Uint8Array} s
* @returns {boolean}
*/
export function sc_is_zero(s) {
const ptr0 = passArray8ToWasm0(s, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.sc_is_zero(ptr0, len0);
return ret !== 0;
}
/**
* @param {Uint8Array} a
* @param {Uint8Array} b
* @returns {Uint8Array}
*/
export function sc_mul(a, b) {
const ptr0 = passArray8ToWasm0(a, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(b, wasm.__wbindgen_malloc);
const len1 = WASM_VECTOR_LEN;
const ret = wasm.sc_mul(ptr0, len0, ptr1, len1);
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v3;
}
/**
* @param {Uint8Array} a
* @param {Uint8Array} b
* @param {Uint8Array} c
* @returns {Uint8Array}
*/
export function sc_mul_add(a, b, c) {
const ptr0 = passArray8ToWasm0(a, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(b, wasm.__wbindgen_malloc);
const len1 = WASM_VECTOR_LEN;
const ptr2 = passArray8ToWasm0(c, wasm.__wbindgen_malloc);
const len2 = WASM_VECTOR_LEN;
const ret = wasm.sc_mul_add(ptr0, len0, ptr1, len1, ptr2, len2);
var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v4;
}
/**
* @param {Uint8Array} a
* @param {Uint8Array} b
* @param {Uint8Array} c
* @returns {Uint8Array}
*/
export function sc_mul_sub(a, b, c) {
const ptr0 = passArray8ToWasm0(a, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(b, wasm.__wbindgen_malloc);
const len1 = WASM_VECTOR_LEN;
const ptr2 = passArray8ToWasm0(c, wasm.__wbindgen_malloc);
const len2 = WASM_VECTOR_LEN;
const ret = wasm.sc_mul_sub(ptr0, len0, ptr1, len1, ptr2, len2);
var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v4;
}
/**
* @param {Uint8Array} s
* @returns {Uint8Array}
*/
export function sc_reduce32(s) {
const ptr0 = passArray8ToWasm0(s, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.sc_reduce32(ptr0, len0);
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v2;
}
/**
* @param {Uint8Array} s
* @returns {Uint8Array}
*/
export function sc_reduce64(s) {
const ptr0 = passArray8ToWasm0(s, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.sc_reduce64(ptr0, len0);
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v2;
}
/**
* @param {Uint8Array} a
* @param {Uint8Array} b
* @returns {Uint8Array}
*/
export function sc_sub(a, b) {
const ptr0 = passArray8ToWasm0(a, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(b, wasm.__wbindgen_malloc);
const len1 = WASM_VECTOR_LEN;
const ret = wasm.sc_sub(ptr0, len0, ptr1, len1);
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v3;
}
/**
* @param {Uint8Array} s
* @returns {Uint8Array}
*/
export function scalar_mult_base(s) {
const ptr0 = passArray8ToWasm0(s, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.scalar_mult_base(ptr0, len0);
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v2;
}
/**
* @param {Uint8Array} s
* @param {Uint8Array} p
* @returns {Uint8Array}
*/
export function scalar_mult_point(s, p) {
const ptr0 = passArray8ToWasm0(s, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(p, wasm.__wbindgen_malloc);
const len1 = WASM_VECTOR_LEN;
const ret = wasm.scalar_mult_point(ptr0, len0, ptr1, len1);
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v3;
}
/**
* SHA-256 hash
* @param {Uint8Array} data
* @returns {Uint8Array}
*/
export function sha256(data) {
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.sha256(ptr0, len0);
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v2;
}
/**
* @param {Uint8Array} message
* @param {Uint8Array} ring_flat
* @param {Uint8Array} secret_key_x
* @param {Uint8Array} secret_key_y
* @param {Uint8Array} commitments_flat
* @param {Uint8Array} commitment_mask
* @param {Uint8Array} pseudo_output
* @param {number} secret_index
* @returns {Uint8Array}
*/
export function tclsag_sign_wasm(message, ring_flat, secret_key_x, secret_key_y, commitments_flat, commitment_mask, pseudo_output, secret_index) {
const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(ring_flat, wasm.__wbindgen_malloc);
const len1 = WASM_VECTOR_LEN;
const ptr2 = passArray8ToWasm0(secret_key_x, wasm.__wbindgen_malloc);
const len2 = WASM_VECTOR_LEN;
const ptr3 = passArray8ToWasm0(secret_key_y, wasm.__wbindgen_malloc);
const len3 = WASM_VECTOR_LEN;
const ptr4 = passArray8ToWasm0(commitments_flat, wasm.__wbindgen_malloc);
const len4 = WASM_VECTOR_LEN;
const ptr5 = passArray8ToWasm0(commitment_mask, wasm.__wbindgen_malloc);
const len5 = WASM_VECTOR_LEN;
const ptr6 = passArray8ToWasm0(pseudo_output, wasm.__wbindgen_malloc);
const len6 = WASM_VECTOR_LEN;
const ret = wasm.tclsag_sign_wasm(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6, secret_index);
var v8 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v8;
}
/**
* @param {Uint8Array} message
* @param {Uint8Array} sig_bytes
* @param {Uint8Array} ring_flat
* @param {Uint8Array} commitments_flat
* @param {Uint8Array} pseudo_output
* @returns {boolean}
*/
export function tclsag_verify_wasm(message, sig_bytes, ring_flat, commitments_flat, pseudo_output) {
const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(sig_bytes, wasm.__wbindgen_malloc);
const len1 = WASM_VECTOR_LEN;
const ptr2 = passArray8ToWasm0(ring_flat, wasm.__wbindgen_malloc);
const len2 = WASM_VECTOR_LEN;
const ptr3 = passArray8ToWasm0(commitments_flat, wasm.__wbindgen_malloc);
const len3 = WASM_VECTOR_LEN;
const ptr4 = passArray8ToWasm0(pseudo_output, wasm.__wbindgen_malloc);
const len4 = WASM_VECTOR_LEN;
const ret = wasm.tclsag_verify_wasm(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
return ret !== 0;
}
/**
* Zero commitment: C = 1*G + amount*H (blinding factor = 1)
* Matches C++ rct::zeroCommit() used for coinbase outputs and fee commitments.
* @param {Uint8Array} amount
* @returns {Uint8Array}
*/
export function zero_commit(amount) {
const ptr0 = passArray8ToWasm0(amount, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.zero_commit(ptr0, len0);
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v2;
}
function __wbg_get_imports() {
const import0 = {
__proto__: null,
__wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
const ret = typeof(arg0) === 'function';
return ret;
},
__wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
const val = arg0;
const ret = typeof(val) === 'object' && val !== null;
return ret;
},
__wbg___wbindgen_is_string_cd444516edc5b180: function(arg0) {
const ret = typeof(arg0) === 'string';
return ret;
},
__wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
const ret = arg0 === undefined;
return ret;
},
__wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
throw new Error(getStringFromWasm0(arg0, arg1));
},
__wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
const ret = arg0.call(arg1);
return ret;
}, arguments); },
__wbg_call_4708e0c13bdc8e95: function() { return handleError(function (arg0, arg1, arg2) {
const ret = arg0.call(arg1, arg2);
return ret;
}, arguments); },
__wbg_crypto_86f2631e91b51511: function(arg0) {
const ret = arg0.crypto;
return ret;
},
__wbg_getRandomValues_b3f15fcbfabb0f8b: function() { return handleError(function (arg0, arg1) {
arg0.getRandomValues(arg1);
}, arguments); },
__wbg_length_32ed9a279acd054c: function(arg0) {
const ret = arg0.length;
return ret;
},
__wbg_msCrypto_d562bbe83e0d4b91: function(arg0) {
const ret = arg0.msCrypto;
return ret;
},
__wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {
const ret = new Function(getStringFromWasm0(arg0, arg1));
return ret;
},
__wbg_new_with_length_a2c39cbe88fd8ff1: function(arg0) {
const ret = new Uint8Array(arg0 >>> 0);
return ret;
},
__wbg_node_e1f24f89a7336c2e: function(arg0) {
const ret = arg0.node;
return ret;
},
__wbg_process_3975fd6c72f520aa: function(arg0) {
const ret = arg0.process;
return ret;
},
__wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
},
__wbg_randomFillSync_f8c153b79f285817: function() { return handleError(function (arg0, arg1) {
arg0.randomFillSync(arg1);
}, arguments); },
__wbg_require_b74f47fc2d022fd6: function() { return handleError(function () {
const ret = module.require;
return ret;
}, arguments); },
__wbg_static_accessor_GLOBAL_12837167ad935116: function() {
const ret = typeof global === 'undefined' ? null : global;
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
},
__wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {
const ret = typeof globalThis === 'undefined' ? null : globalThis;
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
},
__wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {
const ret = typeof self === 'undefined' ? null : self;
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
},
__wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {
const ret = typeof window === 'undefined' ? null : window;
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
},
__wbg_subarray_a96e1fef17ed23cb: function(arg0, arg1, arg2) {
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
return ret;
},
__wbg_versions_4e31226f5e8dc909: function(arg0) {
const ret = arg0.versions;
return ret;
},
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
const ret = getArrayU8FromWasm0(arg0, arg1);
return ret;
},
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
// Cast intrinsic for `Ref(String) -> Externref`.
const ret = getStringFromWasm0(arg0, arg1);
return ret;
},
__wbindgen_init_externref_table: function() {
const table = wasm.__wbindgen_externrefs;
const offset = table.grow(4);
table.set(0, undefined);
table.set(offset + 0, undefined);
table.set(offset + 1, null);
table.set(offset + 2, true);
table.set(offset + 3, false);
},
};
return {
__proto__: null,
"./salvium_crypto_bg.js": import0,
};
}
function addToExternrefTable0(obj) {
const idx = wasm.__externref_table_alloc();
wasm.__wbindgen_externrefs.set(idx, obj);
return idx;
}
function getArrayU8FromWasm0(ptr, len) {
ptr = ptr >>> 0;
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
}
function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return decodeText(ptr, len);
}
let cachedUint8ArrayMemory0 = null;
function getUint8ArrayMemory0() {
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
}
return cachedUint8ArrayMemory0;
}
function handleError(f, args) {
try {
return f.apply(this, args);
} catch (e) {
const idx = addToExternrefTable0(e);
wasm.__wbindgen_exn_store(idx);
}
}
function isLikeNone(x) {
return x === undefined || x === null;
}
function passArray8ToWasm0(arg, malloc) {
const ptr = malloc(arg.length * 1, 1) >>> 0;
getUint8ArrayMemory0().set(arg, ptr / 1);
WASM_VECTOR_LEN = arg.length;
return ptr;
}
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
cachedTextDecoder.decode();
const MAX_SAFARI_DECODE_BYTES = 2146435072;
let numBytesDecoded = 0;
function decodeText(ptr, len) {
numBytesDecoded += len;
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
cachedTextDecoder.decode();
numBytesDecoded = len;
}
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
}
let WASM_VECTOR_LEN = 0;
let wasmModule, wasm;
function __wbg_finalize_init(instance, module) {
wasm = instance.exports;
wasmModule = module;
cachedUint8ArrayMemory0 = null;
wasm.__wbindgen_start();
return wasm;
}
async function __wbg_load(module, imports) {
if (typeof Response === 'function' && module instanceof Response) {
if (typeof WebAssembly.instantiateStreaming === 'function') {
try {
return await WebAssembly.instantiateStreaming(module, imports);
} catch (e) {
const validResponse = module.ok && expectedResponseType(module.type);
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
} else { throw e; }
}
}
const bytes = await module.arrayBuffer();
return await WebAssembly.instantiate(bytes, imports);
} else {
const instance = await WebAssembly.instantiate(module, imports);
if (instance instanceof WebAssembly.Instance) {
return { instance, module };
} else {
return instance;
}
}
function expectedResponseType(type) {
switch (type) {
case 'basic': case 'cors': case 'default': return true;
}
return false;
}
}
function initSync(module) {
if (wasm !== undefined) return wasm;
if (module !== undefined) {
if (Object.getPrototypeOf(module) === Object.prototype) {
({module} = module)
} else {
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
}
}
const imports = __wbg_get_imports();
if (!(module instanceof WebAssembly.Module)) {
module = new WebAssembly.Module(module);
}
const instance = new WebAssembly.Instance(module, imports);
return __wbg_finalize_init(instance, module);
}
async function __wbg_init(module_or_path) {
if (wasm !== undefined) return wasm;
if (module_or_path !== undefined) {
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
({module_or_path} = module_or_path)
} else {
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
}
}
if (module_or_path === undefined) {
module_or_path = new URL('salvium_crypto_bg.wasm', import.meta.url);
}
const imports = __wbg_get_imports();
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
module_or_path = fetch(module_or_path);
}
const { instance, module } = await __wbg_load(await module_or_path, imports);
return __wbg_finalize_init(instance, module);
}
export { initSync, __wbg_init as default };
Binary file not shown.