/* tslint:disable */ /* eslint-disable */ /** * @param {Uint8Array} key * @param {Uint8Array} data * @returns {Uint8Array} */ export function calculate_mac(key: Uint8Array, data: Uint8Array): Uint8Array; /** * @param {Uint8Array} secret * @param {Uint8Array} data * @returns {Uint8Array} */ export function create_tagged_mac(secret: Uint8Array, data: Uint8Array): Uint8Array; /** * @returns {number} */ export function random_float(): number; /** * @param {bigint} bound * @returns {bigint} */ export function random_bounded_integer(bound: bigint): bigint; /** * @param {bigint} start * @param {bigint | undefined} end * @returns {bigint} */ export function random_integer(start: bigint, end?: bigint): bigint; /** * @param {Uint8Array} buffer * @param {number} from * @param {number} len */ export function random_fill(buffer: Uint8Array, from: number, len: number): void; /** * @param {Uint8Array} seed * @param {number} iterations * @param {number} step_size * @returns {IteratedHash} */ export function iterate_hash(seed: Uint8Array, iterations: number, step_size: number): IteratedHash; /** * @param {Uint8Array} hash_value * @param {Function} hints * @param {number} max_iterations * @param {number} step_size * @param {number | undefined} index_hint * @returns {Intermediate} */ export function recover_iterated_hash(hash_value: Uint8Array, hints: Function, max_iterations: number, step_size: number, index_hint?: number): Intermediate; /** */ export function core_crypto_set_panic_hook(): void; /** * @param {Uint8Array} secret * @returns {Uint8Array} */ export function derive_packet_tag(secret: Uint8Array): Uint8Array; /** * @param {Uint8Array} private_key * @param {Uint8Array} channel_info * @returns {Uint8Array} */ export function derive_commitment_seed(private_key: Uint8Array, channel_info: Uint8Array): Uint8Array; /** * @param {Uint8Array} secret * @returns {Uint8Array} */ export function derive_mac_key(secret: Uint8Array): Uint8Array; /** * Dummy function to test WASM. * @returns {string} */ export function dummy_get_one(): string; /** */ export function utils_misc_set_panic_hook(): void; /** * Reads the given package.json file and determines its version. * @param {string} package_file * @returns {string} */ export function get_package_version(package_file: string): string; /** */ export function utils_types_set_panic_hook(): void; /** */ export function utils_log_set_panic_hook(): void; /** * Represents a type of the balance: native or HOPR tokens. */ export enum BalanceType { Native = 0, HOPR = 1, } /** * Represents an Ethereum address */ export class Address { free(): void; /** * @param {Uint8Array} bytes */ constructor(bytes: Uint8Array); /** * @returns {string} */ to_string(): string; /** * @param {Uint8Array} data * @returns {Address} */ static deserialize(data: Uint8Array): Address; /** * @returns {string} */ to_hex(): string; /** * @returns {Uint8Array} */ serialize(): Uint8Array; /** * @param {Address} other * @returns {boolean} */ eq(other: Address): boolean; /** * @returns {number} */ static size(): number; } /** * Helper struct to export Rust Streams into Javascript AsyncIterables * * ``` * use futures::stream::{Stream, StreamExt}; * use wasm_bindgen::prelude::*; * use wasm_bindgen_futures::stream::JsStream; * use js_sys::AsyncIterator; * use utils_misc::async_iterable::wasm::to_box_u8_stream; * * #[wasm_bindgen] * pub struct AsyncIterableHelper { * stream: Box, String>> + Unpin>, // must not be pub * } * #[wasm_bindgen] * pub fn async_test(some_async_iterable: AsyncIterator) -> Result { * let stream = JsStream::from(some_async_iterable); * * let stream = stream.map(to_box_u8_stream); * * Ok(AsyncIterableHelper { * stream: Box::new(stream), * }) * } * ``` */ export class AsyncIterableHelper { free(): void; /** * @returns {Promise} */ next(): Promise; } /** * Represents balance of some coin or token. */ export class Balance { free(): void; /** * @param {string} value * @param {number} balance_type */ constructor(value: string, balance_type: number); /** * Retrieves the type (symbol) of the balance * @returns {number} */ balance_type(): number; /** * @returns {string} */ to_hex(): string; /** * @returns {string} */ to_string(): string; /** * Serializes just the value of the balance (not the symbol) * @returns {Uint8Array} */ serialize_value(): Uint8Array; /** * @param {Balance} other * @returns {boolean} */ lt(other: Balance): boolean; /** * @param {Balance} other * @returns {boolean} */ lte(other: Balance): boolean; /** * @param {Balance} other * @returns {boolean} */ gt(other: Balance): boolean; /** * @param {Balance} other * @returns {boolean} */ gte(other: Balance): boolean; /** * @param {Balance} other * @returns {Balance} */ add(other: Balance): Balance; /** * @param {bigint} amount * @returns {Balance} */ iadd(amount: bigint): Balance; /** * @param {Balance} other * @returns {Balance} */ sub(other: Balance): Balance; /** * @param {bigint} amount * @returns {Balance} */ isub(amount: bigint): Balance; /** * @param {Uint8Array} data * @param {number} balance_type * @returns {Balance} */ static deserialize(data: Uint8Array, balance_type: number): Balance; /** * @param {Balance} other * @returns {boolean} */ eq(other: Balance): boolean; } /** * Natural extension of the Curve Point to the PoR challenge */ export class Challenge { free(): void; /** * @returns {EthereumChallenge} */ to_ethereum_challenge(): EthereumChallenge; /** * @param {HalfKeyChallenge} own_share * @param {HalfKeyChallenge} hint * @returns {Challenge} */ static from_hint_and_share(own_share: HalfKeyChallenge, hint: HalfKeyChallenge): Challenge; /** * @param {HalfKeyChallenge} own_share * @param {HalfKey} half_key * @returns {Challenge} */ static from_own_share_and_half_key(own_share: HalfKeyChallenge, half_key: HalfKey): Challenge; /** */ curve_point: CurvePoint; } /** * Represent an uncompressed elliptic curve point on the secp256k1 curve */ export class CurvePoint { free(): void; /** * @returns {Address} */ to_address(): Address; /** * @param {Uint8Array} exponent * @returns {CurvePoint} */ static from_exponent(exponent: Uint8Array): CurvePoint; /** * @param {string} str * @returns {CurvePoint} */ static from_str(str: string): CurvePoint; /** * @param {string} peer_id * @returns {CurvePoint} */ static from_peerid_str(peer_id: string): CurvePoint; /** * @returns {string} */ to_peerid_str(): string; /** * @param {Uint8Array} bytes * @returns {CurvePoint} */ static deserialize(bytes: Uint8Array): CurvePoint; /** * @returns {string} */ to_hex(): string; /** * @returns {Uint8Array} */ serialize(): Uint8Array; /** * @param {CurvePoint} other * @returns {boolean} */ eq(other: CurvePoint): boolean; /** * @returns {number} */ static size(): number; } /** * Represents and Ethereum challenge. */ export class EthereumChallenge { free(): void; /** * @param {Uint8Array} data */ constructor(data: Uint8Array); /** * @param {Uint8Array} data * @returns {EthereumChallenge} */ static deserialize(data: Uint8Array): EthereumChallenge; /** * @returns {Uint8Array} */ serialize(): Uint8Array; /** * @returns {string} */ to_hex(): string; /** * @param {EthereumChallenge} other * @returns {boolean} */ eq(other: EthereumChallenge): boolean; /** * @returns {number} */ static size(): number; } /** */ export class GroupElement { free(): void; /** * @returns {GroupElement} */ static random(): GroupElement; /** * @returns {Uint8Array} */ coefficient(): Uint8Array; /** * @returns {CurvePoint} */ element(): CurvePoint; } /** * Represents a half-key used for Proof of Relay */ export class HalfKey { free(): void; /** * @param {Uint8Array} half_key */ constructor(half_key: Uint8Array); /** * @param {Uint8Array} data * @returns {HalfKey} */ static deserialize(data: Uint8Array): HalfKey; /** * @returns {string} */ to_hex(): string; /** * @returns {Uint8Array} */ serialize(): Uint8Array; /** * @returns {HalfKey} */ clone(): HalfKey; /** * @param {HalfKey} other * @returns {boolean} */ eq(other: HalfKey): boolean; /** * @returns {number} */ static size(): number; } /** * Represents a challange for the half-key in Proof of Relay */ export class HalfKeyChallenge { free(): void; /** * @param {Uint8Array} half_key_challenge */ constructor(half_key_challenge: Uint8Array); /** * @returns {Address} */ to_address(): Address; /** * @returns {string} */ to_hex(): string; /** * @param {HalfKeyChallenge} other * @returns {boolean} */ eq(other: HalfKeyChallenge): boolean; /** * @returns {HalfKeyChallenge} */ clone(): HalfKeyChallenge; /** * @returns {string} */ to_peerid_str(): string; /** * @param {Uint8Array} data * @returns {HalfKeyChallenge} */ static deserialize(data: Uint8Array): HalfKeyChallenge; /** * @param {string} str * @returns {HalfKeyChallenge} */ static from_str(str: string): HalfKeyChallenge; /** * @param {string} peer_id * @returns {HalfKeyChallenge} */ static from_peerid_str(peer_id: string): HalfKeyChallenge; /** * @returns {number} */ static size(): number; } /** * Represents a 256-bit hash value * This implementation instantiates the hash via Keccak256 digest. */ export class Hash { free(): void; /** * @param {Uint8Array} hash */ constructor(hash: Uint8Array); /** * @param {(Uint8Array)[]} inputs * @returns {Hash} */ static create(inputs: (Uint8Array)[]): Hash; /** * @param {Uint8Array} data * @returns {Hash} */ static deserialize(data: Uint8Array): Hash; /** * @returns {string} */ to_hex(): string; /** * @returns {Uint8Array} */ serialize(): Uint8Array; /** * @param {Hash} other * @returns {boolean} */ eq(other: Hash): boolean; /** * @returns {number} */ static size(): number; } /** * Contains the intermediate result in the hash iteration progression */ export class Intermediate { free(): void; /** */ intermediate: Uint8Array; /** */ iteration: number; } /** */ export class IteratedHash { free(): void; /** * @returns {Uint8Array} */ hash(): Uint8Array; /** * @returns {number} */ count_intermediates(): number; /** * @param {number} index * @returns {Intermediate | undefined} */ intermediate(index: number): Intermediate | undefined; } /** */ export class IteratorResult { free(): void; } /** * Pseudo-Random Generator (PRG) function that is instantiated * using AES-128 block cipher in Counter mode (with 32-bit counter). * It forms an infinite sequence of pseudo-random bytes (generated deterministically from the parameters) * and can be queried by chunks using the `digest` function. */ export class PRG { free(): void; /** * Creates a PRG instance using the raw key and IV for the underlying block cipher. * @param {Uint8Array} key * @param {Uint8Array} iv */ constructor(key: Uint8Array, iv: Uint8Array); /** * Creates a new PRG instance using the given parameters * @param {PRGParameters} params * @returns {PRG} */ static from_parameters(params: PRGParameters): PRG; /** * @param {number} from * @param {number} to * @returns {Uint8Array} */ digest(from: number, to: number): Uint8Array; } /** * Parameters for the Pseudo-Random Generator (PRG) function * This consists of IV and the raw secret key for use by the underlying block cipher. */ export class PRGParameters { free(): void; /** * Creates new parameters for the PRG by expanding the given * keying material into the secret key and IV for the underlying block cipher. * @param {Uint8Array} secret */ constructor(secret: Uint8Array); /** * @returns {Uint8Array} */ key(): Uint8Array; /** * @returns {Uint8Array} */ iv(): Uint8Array; } /** * Implementation of Pseudo-Random Permutation (PRP). * Currently based on the Lioness wide-block cipher. */ export class PRP { free(): void; /** * @param {Uint8Array} plaintext * @returns {Uint8Array} */ forward(plaintext: Uint8Array): Uint8Array; /** * @param {Uint8Array} ciphertext * @returns {Uint8Array} */ inverse(ciphertext: Uint8Array): Uint8Array; /** * Creates new instance of the PRP using the raw key and IV. * @param {Uint8Array} key * @param {Uint8Array} iv * @returns {PRP} */ static new(key: Uint8Array, iv: Uint8Array): PRP; /** * Creates a new PRP instance using the given parameters * @param {PRPParameters} params */ constructor(params: PRPParameters); } /** * Parameters for the Pseudo-Random Permutation (PRP) function * This consists of IV and the raw secret key for use by the underlying cryptographic transformation. */ export class PRPParameters { free(): void; /** * @returns {Uint8Array} */ key(): Uint8Array; /** * @returns {Uint8Array} */ iv(): Uint8Array; /** * Creates new parameters for the PRP by expanding the given * keying material into the secret key and IV for the underlying cryptographic transformation. * @param {Uint8Array} secret */ constructor(secret: Uint8Array); } /** * Represents a secp256k1 public key. * This is a "Schrödinger public key", both compressed and uncompressed to save some cycles. */ export class PublicKey { free(): void; /** * @returns {Address} */ to_address(): Address; /** * @param {boolean} compressed * @returns {Uint8Array} */ serialize(compressed: boolean): Uint8Array; /** * @param {boolean} compressed * @returns {string} */ to_hex(compressed: boolean): string; /** * @param {Uint8Array} bytes * @returns {PublicKey} */ static deserialize(bytes: Uint8Array): PublicKey; /** * @param {string} peer_id * @returns {PublicKey} */ static from_peerid_str(peer_id: string): PublicKey; /** * @returns {string} */ to_peerid_str(): string; /** * @param {Uint8Array} hash * @param {Uint8Array} r * @param {Uint8Array} s * @param {number} v * @returns {PublicKey} */ static from_signature(hash: Uint8Array, r: Uint8Array, s: Uint8Array, v: number): PublicKey; /** * @param {Uint8Array} private_key * @returns {PublicKey} */ static from_privkey(private_key: Uint8Array): PublicKey; /** * @param {PublicKey} other * @returns {boolean} */ eq(other: PublicKey): boolean; /** * @returns {number} */ static size_compressed(): number; /** * @returns {number} */ static size_uncompressed(): number; } /** * Structure containing shared keys for peers. * The members are exposed only using specialized methods. */ export class SharedKeys { free(): void; /** * Get the `alpha` value of the derived shared secrets. * @returns {Uint8Array} */ get_alpha(): Uint8Array; /** * Gets the shared secret of the peer on the given index. * The indices are assigned in the same order as they were given to the * [`generate`] function. * @param {number} peer_idx * @returns {Uint8Array | undefined} */ get_peer_shared_key(peer_idx: number): Uint8Array | undefined; /** * Returns the number of shared keys generated in this structure. * @returns {number} */ count_shared_keys(): number; /** * @param {Uint8Array} alpha * @param {Uint8Array} public_key * @param {Uint8Array} private_key * @returns {SharedKeys} */ static forward_transform(alpha: Uint8Array, public_key: Uint8Array, private_key: Uint8Array): SharedKeys; /** * Generate shared keys given the peer public keys * @param {(Uint8Array)[]} peer_public_keys * @returns {SharedKeys} */ static generate(peer_public_keys: (Uint8Array)[]): SharedKeys; } /** * Represents an ECDSA signature based on the secp256k1 curve with recoverable public key. * This signature encodes the 2-bit recovery information into the * upper-most bits of MSB of the S value, which are never used by this ECDSA * instantiation over secp256k1. */ export class Signature { free(): void; /** * @param {Uint8Array} raw_bytes * @param {number} recovery */ constructor(raw_bytes: Uint8Array, recovery: number); /** * Signs the given message using the raw private key. * @param {Uint8Array} message * @param {Uint8Array} private_key * @returns {Signature} */ static sign_message(message: Uint8Array, private_key: Uint8Array): Signature; /** * Signs the given hash using the raw private key. * @param {Uint8Array} hash * @param {Uint8Array} private_key * @returns {Signature} */ static sign_hash(hash: Uint8Array, private_key: Uint8Array): Signature; /** * Verifies this signature against the given message and a public key (compressed or uncompressed) * @param {Uint8Array} message * @param {Uint8Array} public_key * @returns {boolean} */ verify_message(message: Uint8Array, public_key: Uint8Array): boolean; /** * Verifies this signature against the given message and a public key object * @param {Uint8Array} message * @param {PublicKey} public_key * @returns {boolean} */ verify_message_with_pubkey(message: Uint8Array, public_key: PublicKey): boolean; /** * Verifies this signature against the given hash and a public key (compressed or uncompressed) * @param {Uint8Array} hash * @param {Uint8Array} public_key * @returns {boolean} */ verify_hash(hash: Uint8Array, public_key: Uint8Array): boolean; /** * Verifies this signature against the given message and a public key object * @param {Uint8Array} message * @param {PublicKey} public_key * @returns {boolean} */ verify_hash_with_pubkey(message: Uint8Array, public_key: PublicKey): boolean; /** * @returns {Uint8Array} */ raw_signature(): Uint8Array; /** * @param {Uint8Array} signature * @returns {Signature} */ static deserialize(signature: Uint8Array): Signature; /** * @returns {string} */ to_hex(): string; /** * @returns {Uint8Array} */ serialize(): Uint8Array; /** * @returns {number} */ static size(): number; } /** * Represents a snapshot in the blockchain */ export class Snapshot { free(): void; /** * @param {U256} block_number * @param {U256} transaction_index * @param {U256} log_index */ constructor(block_number: U256, transaction_index: U256, log_index: U256); /** * @param {Uint8Array} data * @returns {Snapshot} */ static deserialize(data: Uint8Array): Snapshot; /** * @returns {Uint8Array} */ serialize(): Uint8Array; /** * @returns {number} */ static size(): number; /** */ block_number: U256; /** */ log_index: U256; /** */ transaction_index: U256; } /** * Represents the Ethereum's basic numeric type - unsigned 256-bit integer */ export class U256 { free(): void; /** * @param {string} value */ constructor(value: string); /** * @param {Uint8Array} data * @returns {U256} */ static deserialize(data: Uint8Array): U256; /** * @returns {Uint8Array} */ serialize(): Uint8Array; /** * @returns {string} */ to_hex(): string; /** * @param {U256} inverse_prob * @returns {U256} */ static from_inverse_probability(inverse_prob: U256): U256; /** * @param {U256} other * @returns {boolean} */ eq(other: U256): boolean; /** * @param {U256} other * @returns {number} */ cmp(other: U256): number; }