aboutsummaryrefslogtreecommitdiff
path: root/lib/wallet/emscriptif.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/wallet/emscriptif.ts')
-rw-r--r--lib/wallet/emscriptif.ts271
1 files changed, 134 insertions, 137 deletions
diff --git a/lib/wallet/emscriptif.ts b/lib/wallet/emscriptif.ts
index 3ae2db72a..4757fd8f4 100644
--- a/lib/wallet/emscriptif.ts
+++ b/lib/wallet/emscriptif.ts
@@ -35,157 +35,154 @@ const GNUNET_NO = 0;
const GNUNET_SYSERR = -1;
-function myCcall(name: string, ret: any, argTypes: any[], args: any[]) {
- return Module.ccall(name, ret, argTypes, args);
-}
-
-let getEmsc: EmscFunGen = (name: string, ret: any,
- argTypes: any[]) => {
+const getEmsc: EmscFunGen = (name: string, ret: any, argTypes: any[]) => {
return (...args: any[]) => {
- return myCcall(name, ret, argTypes, args);
+ return Module.ccall(name, ret, argTypes, args);
}
};
-var emsc = {
+/**
+ * Wrapped emscripten functions that do not allocate any memory.
+ */
+const emsc = {
free: (ptr: number) => Module._free(ptr),
- get_value: getEmsc('TALER_WR_get_value',
- 'number',
- ['number']),
- get_fraction: getEmsc('TALER_WR_get_fraction',
- 'number',
- ['number']),
- get_currency: getEmsc('TALER_WR_get_currency',
- 'string',
- ['number']),
- amount_add: getEmsc('TALER_amount_add',
- 'number',
- ['number', 'number', 'number']),
- amount_subtract: getEmsc('TALER_amount_subtract',
- 'number',
- ['number', 'number', 'number']),
- amount_normalize: getEmsc('TALER_amount_normalize',
- 'void',
- ['number']),
- amount_get_zero: getEmsc('TALER_amount_get_zero',
- 'number',
- ['string', 'number']),
- amount_cmp: getEmsc('TALER_amount_cmp',
- 'number',
- ['number', 'number']),
- amount_hton: getEmsc('TALER_amount_hton',
- 'void',
- ['number', 'number']),
- amount_ntoh: getEmsc('TALER_amount_ntoh',
- 'void',
- ['number', 'number']),
- hash: getEmsc('GNUNET_CRYPTO_hash',
- 'void',
- ['number', 'number', 'number']),
- memmove: getEmsc('memmove',
- 'number',
- ['number', 'number', 'number']),
- rsa_public_key_free: getEmsc('GNUNET_CRYPTO_rsa_public_key_free',
- 'void',
- ['number']),
- rsa_signature_free: getEmsc('GNUNET_CRYPTO_rsa_signature_free',
- 'void',
- ['number']),
- string_to_data: getEmsc('GNUNET_STRINGS_string_to_data',
- 'number',
- ['number', 'number', 'number', 'number']),
- eddsa_sign: getEmsc('GNUNET_CRYPTO_eddsa_sign',
- 'number',
- ['number', 'number', 'number']),
- eddsa_verify: getEmsc('GNUNET_CRYPTO_eddsa_verify',
- 'number',
- ['number', 'number', 'number', 'number']),
- hash_create_random: getEmsc('GNUNET_CRYPTO_hash_create_random',
- 'void',
- ['number', 'number']),
- rsa_blinding_key_destroy: getEmsc('GNUNET_CRYPTO_rsa_blinding_key_free',
- 'void',
- ['number']),
- random_block: getEmsc('GNUNET_CRYPTO_random_block',
- 'void',
- ['number', 'number', 'number']),
- hash_context_abort: getEmsc('GNUNET_CRYPTO_hash_context_abort',
- 'void',
- ['number']),
- hash_context_read: getEmsc('GNUNET_CRYPTO_hash_context_read',
- 'void',
- ['number', 'number', 'number']),
- hash_context_finish: getEmsc('GNUNET_CRYPTO_hash_context_finish',
- 'void',
- ['number', 'number']),
- ecdh_eddsa: getEmsc(
- "GNUNET_CRYPTO_ecdh_eddsa",
- 'number',
- ["number", "number", "number"]),
+ get_value: getEmsc("TALER_WR_get_value",
+ "number",
+ ["number"]),
+ get_fraction: getEmsc("TALER_WR_get_fraction",
+ "number",
+ ["number"]),
+ get_currency: getEmsc("TALER_WR_get_currency",
+ "string",
+ ["number"]),
+ amount_add: getEmsc("TALER_amount_add",
+ "number",
+ ["number", "number", "number"]),
+ amount_subtract: getEmsc("TALER_amount_subtract",
+ "number",
+ ["number", "number", "number"]),
+ amount_normalize: getEmsc("TALER_amount_normalize",
+ "void",
+ ["number"]),
+ amount_get_zero: getEmsc("TALER_amount_get_zero",
+ "number",
+ ["string", "number"]),
+ amount_cmp: getEmsc("TALER_amount_cmp",
+ "number",
+ ["number", "number"]),
+ amount_hton: getEmsc("TALER_amount_hton",
+ "void",
+ ["number", "number"]),
+ amount_ntoh: getEmsc("TALER_amount_ntoh",
+ "void",
+ ["number", "number"]),
+ hash: getEmsc("GNUNET_CRYPTO_hash",
+ "void",
+ ["number", "number", "number"]),
+ memmove: getEmsc("memmove",
+ "number",
+ ["number", "number", "number"]),
+ rsa_public_key_free: getEmsc("GNUNET_CRYPTO_rsa_public_key_free",
+ "void",
+ ["number"]),
+ rsa_signature_free: getEmsc("GNUNET_CRYPTO_rsa_signature_free",
+ "void",
+ ["number"]),
+ string_to_data: getEmsc("GNUNET_STRINGS_string_to_data",
+ "number",
+ ["number", "number", "number", "number"]),
+ eddsa_sign: getEmsc("GNUNET_CRYPTO_eddsa_sign",
+ "number",
+ ["number", "number", "number"]),
+ eddsa_verify: getEmsc("GNUNET_CRYPTO_eddsa_verify",
+ "number",
+ ["number", "number", "number", "number"]),
+ hash_create_random: getEmsc("GNUNET_CRYPTO_hash_create_random",
+ "void",
+ ["number", "number"]),
+ rsa_blinding_key_destroy: getEmsc("GNUNET_CRYPTO_rsa_blinding_key_free",
+ "void",
+ ["number"]),
+ random_block: getEmsc("GNUNET_CRYPTO_random_block",
+ "void",
+ ["number", "number", "number"]),
+ hash_context_abort: getEmsc("GNUNET_CRYPTO_hash_context_abort",
+ "void",
+ ["number"]),
+ hash_context_read: getEmsc("GNUNET_CRYPTO_hash_context_read",
+ "void",
+ ["number", "number", "number"]),
+ hash_context_finish: getEmsc("GNUNET_CRYPTO_hash_context_finish",
+ "void",
+ ["number", "number"]),
+ ecdh_eddsa: getEmsc("GNUNET_CRYPTO_ecdh_eddsa",
+ "number",
+ ["number", "number", "number"]),
setup_fresh_coin: getEmsc(
"TALER_setup_fresh_coin",
- 'void',
+ "void",
["number", "number", "number"]),
};
-var emscAlloc = {
- get_amount: getEmsc('TALER_WRALL_get_amount',
- 'number',
- ['number', 'number', 'number', 'string']),
- eddsa_key_create: getEmsc('GNUNET_CRYPTO_eddsa_key_create',
- 'number', []),
- ecdsa_key_create: getEmsc('GNUNET_CRYPTO_ecdsa_key_create',
- 'number', []),
- ecdhe_key_create: getEmsc('GNUNET_CRYPTO_ecdhe_key_create',
- 'number', []),
+const emscAlloc = {
+ get_amount: getEmsc("TALER_WRALL_get_amount",
+ "number",
+ ["number", "number", "number", "string"]),
+ eddsa_key_create: getEmsc("GNUNET_CRYPTO_eddsa_key_create",
+ "number", []),
+ ecdsa_key_create: getEmsc("GNUNET_CRYPTO_ecdsa_key_create",
+ "number", []),
+ ecdhe_key_create: getEmsc("GNUNET_CRYPTO_ecdhe_key_create",
+ "number", []),
eddsa_public_key_from_private: getEmsc(
- 'TALER_WRALL_eddsa_public_key_from_private',
- 'number',
- ['number']),
+ "TALER_WRALL_eddsa_public_key_from_private",
+ "number",
+ ["number"]),
ecdsa_public_key_from_private: getEmsc(
- 'TALER_WRALL_ecdsa_public_key_from_private',
- 'number',
- ['number']),
+ "TALER_WRALL_ecdsa_public_key_from_private",
+ "number",
+ ["number"]),
ecdhe_public_key_from_private: getEmsc(
- 'TALER_WRALL_ecdhe_public_key_from_private',
- 'number',
- ['number']),
- data_to_string_alloc: getEmsc('GNUNET_STRINGS_data_to_string_alloc',
- 'number',
- ['number', 'number']),
- purpose_create: getEmsc('TALER_WRALL_purpose_create',
- 'number',
- ['number', 'number', 'number']),
- rsa_blind: getEmsc('GNUNET_CRYPTO_rsa_blind',
- 'number',
- ['number', 'number', 'number', 'number', 'number']),
- rsa_blinding_key_create: getEmsc('GNUNET_CRYPTO_rsa_blinding_key_create',
- 'number',
- ['number']),
- rsa_blinding_key_encode: getEmsc('GNUNET_CRYPTO_rsa_blinding_key_encode',
- 'number',
- ['number', 'number']),
- rsa_signature_encode: getEmsc('GNUNET_CRYPTO_rsa_signature_encode',
- 'number',
- ['number', 'number']),
- rsa_blinding_key_decode: getEmsc('GNUNET_CRYPTO_rsa_blinding_key_decode',
- 'number',
- ['number', 'number']),
- rsa_public_key_decode: getEmsc('GNUNET_CRYPTO_rsa_public_key_decode',
- 'number',
- ['number', 'number']),
- rsa_signature_decode: getEmsc('GNUNET_CRYPTO_rsa_signature_decode',
- 'number',
- ['number', 'number']),
- rsa_public_key_encode: getEmsc('GNUNET_CRYPTO_rsa_public_key_encode',
- 'number',
- ['number', 'number']),
- rsa_unblind: getEmsc('GNUNET_CRYPTO_rsa_unblind',
- 'number',
- ['number', 'number', 'number']),
- hash_context_start: getEmsc('GNUNET_CRYPTO_hash_context_start',
- 'number',
+ "TALER_WRALL_ecdhe_public_key_from_private",
+ "number",
+ ["number"]),
+ data_to_string_alloc: getEmsc("GNUNET_STRINGS_data_to_string_alloc",
+ "number",
+ ["number", "number"]),
+ purpose_create: getEmsc("TALER_WRALL_purpose_create",
+ "number",
+ ["number", "number", "number"]),
+ rsa_blind: getEmsc("GNUNET_CRYPTO_rsa_blind",
+ "number",
+ ["number", "number", "number", "number", "number"]),
+ rsa_blinding_key_create: getEmsc("GNUNET_CRYPTO_rsa_blinding_key_create",
+ "number",
+ ["number"]),
+ rsa_blinding_key_encode: getEmsc("GNUNET_CRYPTO_rsa_blinding_key_encode",
+ "number",
+ ["number", "number"]),
+ rsa_signature_encode: getEmsc("GNUNET_CRYPTO_rsa_signature_encode",
+ "number",
+ ["number", "number"]),
+ rsa_blinding_key_decode: getEmsc("GNUNET_CRYPTO_rsa_blinding_key_decode",
+ "number",
+ ["number", "number"]),
+ rsa_public_key_decode: getEmsc("GNUNET_CRYPTO_rsa_public_key_decode",
+ "number",
+ ["number", "number"]),
+ rsa_signature_decode: getEmsc("GNUNET_CRYPTO_rsa_signature_decode",
+ "number",
+ ["number", "number"]),
+ rsa_public_key_encode: getEmsc("GNUNET_CRYPTO_rsa_public_key_encode",
+ "number",
+ ["number", "number"]),
+ rsa_unblind: getEmsc("GNUNET_CRYPTO_rsa_unblind",
+ "number",
+ ["number", "number", "number"]),
+ hash_context_start: getEmsc("GNUNET_CRYPTO_hash_context_start",
+ "number",
[]),
malloc: (size: number) => Module._malloc(size),
};
@@ -198,7 +195,7 @@ export enum SignaturePurpose {
WALLET_COIN_MELT = 1202,
}
-enum RandomQuality {
+export enum RandomQuality {
WEAK = 0,
STRONG = 1,
NONCE = 2