@nockbox/iris-wasm 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/iris_wasm.d.ts CHANGED
@@ -1,5 +1,13 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+ /**
4
+ * Hash a noun (jam as input)
5
+ */
6
+ export function hashNoun(noun: Uint8Array): string;
7
+ /**
8
+ * Verify a signature with a public key
9
+ */
10
+ export function verifySignature(public_key_bytes: Uint8Array, signature: Signature, message: string): boolean;
3
11
  /**
4
12
  * Hash a public key to get its digest (for use in PKH)
5
13
  */
@@ -9,21 +17,17 @@ export function hashPublicKey(public_key_bytes: Uint8Array): string;
9
17
  */
10
18
  export function deriveMasterKey(seed: Uint8Array): ExtendedKey;
11
19
  /**
12
- * Hash a noun (jam as input)
13
- */
14
- export function hashNoun(noun: Uint8Array): string;
15
- /**
16
- * Hash a u64 value
20
+ * Sign a message string with a private key
17
21
  */
18
- export function hashU64(value: bigint): string;
22
+ export function signMessage(private_key_bytes: Uint8Array, message: string): Signature;
19
23
  /**
20
24
  * Derive master key from BIP39 mnemonic phrase
21
25
  */
22
26
  export function deriveMasterKeyFromMnemonic(mnemonic: string, passphrase?: string | null): ExtendedKey;
23
27
  /**
24
- * Sign a message string with a private key
28
+ * Hash a u64 value
25
29
  */
26
- export function signMessage(private_key_bytes: Uint8Array, message: string): Signature;
30
+ export function hashU64(value: bigint): string;
27
31
  /**
28
32
  * The `ReadableStreamType` enum.
29
33
  *
@@ -195,6 +199,15 @@ export class NoteDataEntry {
195
199
  readonly key: string;
196
200
  readonly blob: Uint8Array;
197
201
  }
202
+ export class Noun {
203
+ private constructor();
204
+ free(): void;
205
+ [Symbol.dispose](): void;
206
+ static cue(jam: Uint8Array): Noun;
207
+ jam(): Uint8Array;
208
+ static fromJs(value: any): Noun;
209
+ toJs(): any;
210
+ }
198
211
  export class Pkh {
199
212
  free(): void;
200
213
  [Symbol.dispose](): void;
@@ -241,9 +254,9 @@ export class Seed {
241
254
  gift: bigint;
242
255
  }
243
256
  export class Signature {
244
- private constructor();
245
257
  free(): void;
246
258
  [Symbol.dispose](): void;
259
+ constructor(c: Uint8Array, s: Uint8Array);
247
260
  readonly c: Uint8Array;
248
261
  readonly s: Uint8Array;
249
262
  }
@@ -598,6 +611,17 @@ export interface InitOutput {
598
611
  readonly wasmseed_fromProtobuf: (a: any) => [number, number, number];
599
612
  readonly wasmseed_toProtobuf: (a: number) => [number, number, number];
600
613
  readonly version_new: (a: number) => number;
614
+ readonly __wbg_grpcclient_free: (a: number, b: number) => void;
615
+ readonly __wbg_noun_free: (a: number, b: number) => void;
616
+ readonly grpcclient_getBalanceByAddress: (a: number, b: number, c: number) => any;
617
+ readonly grpcclient_getBalanceByFirstName: (a: number, b: number, c: number) => any;
618
+ readonly grpcclient_new: (a: number, b: number) => number;
619
+ readonly grpcclient_sendTransaction: (a: number, b: any) => any;
620
+ readonly grpcclient_transactionAccepted: (a: number, b: number, c: number) => any;
621
+ readonly noun_cue: (a: number, b: number) => [number, number, number];
622
+ readonly noun_fromJs: (a: any) => [number, number, number];
623
+ readonly noun_jam: (a: number) => [number, number, number, number];
624
+ readonly noun_toJs: (a: number) => [number, number, number];
601
625
  readonly __wbg_extendedkey_free: (a: number, b: number) => void;
602
626
  readonly __wbg_signature_free: (a: number, b: number) => void;
603
627
  readonly deriveMasterKey: (a: number, b: number) => number;
@@ -611,13 +635,9 @@ export interface InitOutput {
611
635
  readonly hashU64: (a: bigint) => [number, number];
612
636
  readonly signMessage: (a: number, b: number, c: number, d: number) => [number, number, number];
613
637
  readonly signature_c: (a: number) => [number, number];
638
+ readonly signature_new: (a: number, b: number, c: number, d: number) => number;
614
639
  readonly signature_s: (a: number) => [number, number];
615
- readonly __wbg_grpcclient_free: (a: number, b: number) => void;
616
- readonly grpcclient_getBalanceByAddress: (a: number, b: number, c: number) => any;
617
- readonly grpcclient_getBalanceByFirstName: (a: number, b: number, c: number) => any;
618
- readonly grpcclient_new: (a: number, b: number) => number;
619
- readonly grpcclient_sendTransaction: (a: number, b: any) => any;
620
- readonly grpcclient_transactionAccepted: (a: number, b: number, c: number) => any;
640
+ readonly verifySignature: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
621
641
  readonly __wbg_intounderlyingsource_free: (a: number, b: number) => void;
622
642
  readonly intounderlyingsource_cancel: (a: number) => void;
623
643
  readonly intounderlyingsource_pull: (a: number, b: any) => any;
package/iris_wasm.js CHANGED
@@ -254,17 +254,17 @@ function passArray8ToWasm0(arg, malloc) {
254
254
  return ptr;
255
255
  }
256
256
  /**
257
- * Hash a public key to get its digest (for use in PKH)
258
- * @param {Uint8Array} public_key_bytes
257
+ * Hash a noun (jam as input)
258
+ * @param {Uint8Array} noun
259
259
  * @returns {string}
260
260
  */
261
- export function hashPublicKey(public_key_bytes) {
261
+ export function hashNoun(noun) {
262
262
  let deferred3_0;
263
263
  let deferred3_1;
264
264
  try {
265
- const ptr0 = passArray8ToWasm0(public_key_bytes, wasm.__wbindgen_malloc);
265
+ const ptr0 = passArray8ToWasm0(noun, wasm.__wbindgen_malloc);
266
266
  const len0 = WASM_VECTOR_LEN;
267
- const ret = wasm.hashPublicKey(ptr0, len0);
267
+ const ret = wasm.hashNoun(ptr0, len0);
268
268
  var ptr2 = ret[0];
269
269
  var len2 = ret[1];
270
270
  if (ret[3]) {
@@ -280,29 +280,37 @@ export function hashPublicKey(public_key_bytes) {
280
280
  }
281
281
 
282
282
  /**
283
- * Derive master key from seed bytes
284
- * @param {Uint8Array} seed
285
- * @returns {ExtendedKey}
283
+ * Verify a signature with a public key
284
+ * @param {Uint8Array} public_key_bytes
285
+ * @param {Signature} signature
286
+ * @param {string} message
287
+ * @returns {boolean}
286
288
  */
287
- export function deriveMasterKey(seed) {
288
- const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc);
289
+ export function verifySignature(public_key_bytes, signature, message) {
290
+ const ptr0 = passArray8ToWasm0(public_key_bytes, wasm.__wbindgen_malloc);
289
291
  const len0 = WASM_VECTOR_LEN;
290
- const ret = wasm.deriveMasterKey(ptr0, len0);
291
- return ExtendedKey.__wrap(ret);
292
+ _assertClass(signature, Signature);
293
+ const ptr1 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
294
+ const len1 = WASM_VECTOR_LEN;
295
+ const ret = wasm.verifySignature(ptr0, len0, signature.__wbg_ptr, ptr1, len1);
296
+ if (ret[2]) {
297
+ throw takeFromExternrefTable0(ret[1]);
298
+ }
299
+ return ret[0] !== 0;
292
300
  }
293
301
 
294
302
  /**
295
- * Hash a noun (jam as input)
296
- * @param {Uint8Array} noun
303
+ * Hash a public key to get its digest (for use in PKH)
304
+ * @param {Uint8Array} public_key_bytes
297
305
  * @returns {string}
298
306
  */
299
- export function hashNoun(noun) {
307
+ export function hashPublicKey(public_key_bytes) {
300
308
  let deferred3_0;
301
309
  let deferred3_1;
302
310
  try {
303
- const ptr0 = passArray8ToWasm0(noun, wasm.__wbindgen_malloc);
311
+ const ptr0 = passArray8ToWasm0(public_key_bytes, wasm.__wbindgen_malloc);
304
312
  const len0 = WASM_VECTOR_LEN;
305
- const ret = wasm.hashNoun(ptr0, len0);
313
+ const ret = wasm.hashPublicKey(ptr0, len0);
306
314
  var ptr2 = ret[0];
307
315
  var len2 = ret[1];
308
316
  if (ret[3]) {
@@ -318,21 +326,33 @@ export function hashNoun(noun) {
318
326
  }
319
327
 
320
328
  /**
321
- * Hash a u64 value
322
- * @param {bigint} value
323
- * @returns {string}
329
+ * Derive master key from seed bytes
330
+ * @param {Uint8Array} seed
331
+ * @returns {ExtendedKey}
324
332
  */
325
- export function hashU64(value) {
326
- let deferred1_0;
327
- let deferred1_1;
328
- try {
329
- const ret = wasm.hashU64(value);
330
- deferred1_0 = ret[0];
331
- deferred1_1 = ret[1];
332
- return getStringFromWasm0(ret[0], ret[1]);
333
- } finally {
334
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
333
+ export function deriveMasterKey(seed) {
334
+ const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc);
335
+ const len0 = WASM_VECTOR_LEN;
336
+ const ret = wasm.deriveMasterKey(ptr0, len0);
337
+ return ExtendedKey.__wrap(ret);
338
+ }
339
+
340
+ /**
341
+ * Sign a message string with a private key
342
+ * @param {Uint8Array} private_key_bytes
343
+ * @param {string} message
344
+ * @returns {Signature}
345
+ */
346
+ export function signMessage(private_key_bytes, message) {
347
+ const ptr0 = passArray8ToWasm0(private_key_bytes, wasm.__wbindgen_malloc);
348
+ const len0 = WASM_VECTOR_LEN;
349
+ const ptr1 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
350
+ const len1 = WASM_VECTOR_LEN;
351
+ const ret = wasm.signMessage(ptr0, len0, ptr1, len1);
352
+ if (ret[2]) {
353
+ throw takeFromExternrefTable0(ret[1]);
335
354
  }
355
+ return Signature.__wrap(ret[0]);
336
356
  }
337
357
 
338
358
  /**
@@ -354,21 +374,21 @@ export function deriveMasterKeyFromMnemonic(mnemonic, passphrase) {
354
374
  }
355
375
 
356
376
  /**
357
- * Sign a message string with a private key
358
- * @param {Uint8Array} private_key_bytes
359
- * @param {string} message
360
- * @returns {Signature}
377
+ * Hash a u64 value
378
+ * @param {bigint} value
379
+ * @returns {string}
361
380
  */
362
- export function signMessage(private_key_bytes, message) {
363
- const ptr0 = passArray8ToWasm0(private_key_bytes, wasm.__wbindgen_malloc);
364
- const len0 = WASM_VECTOR_LEN;
365
- const ptr1 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
366
- const len1 = WASM_VECTOR_LEN;
367
- const ret = wasm.signMessage(ptr0, len0, ptr1, len1);
368
- if (ret[2]) {
369
- throw takeFromExternrefTable0(ret[1]);
381
+ export function hashU64(value) {
382
+ let deferred1_0;
383
+ let deferred1_1;
384
+ try {
385
+ const ret = wasm.hashU64(value);
386
+ deferred1_0 = ret[0];
387
+ deferred1_1 = ret[1];
388
+ return getStringFromWasm0(ret[0], ret[1]);
389
+ } finally {
390
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
370
391
  }
371
- return Signature.__wrap(ret[0]);
372
392
  }
373
393
 
374
394
  function wasm_bindgen__convert__closures_____invoke__hbf186e27576c509b(arg0, arg1, arg2) {
@@ -1526,6 +1546,80 @@ export class NoteDataEntry {
1526
1546
  }
1527
1547
  if (Symbol.dispose) NoteDataEntry.prototype[Symbol.dispose] = NoteDataEntry.prototype.free;
1528
1548
 
1549
+ const NounFinalization = (typeof FinalizationRegistry === 'undefined')
1550
+ ? { register: () => {}, unregister: () => {} }
1551
+ : new FinalizationRegistry(ptr => wasm.__wbg_noun_free(ptr >>> 0, 1));
1552
+
1553
+ export class Noun {
1554
+
1555
+ static __wrap(ptr) {
1556
+ ptr = ptr >>> 0;
1557
+ const obj = Object.create(Noun.prototype);
1558
+ obj.__wbg_ptr = ptr;
1559
+ NounFinalization.register(obj, obj.__wbg_ptr, obj);
1560
+ return obj;
1561
+ }
1562
+
1563
+ __destroy_into_raw() {
1564
+ const ptr = this.__wbg_ptr;
1565
+ this.__wbg_ptr = 0;
1566
+ NounFinalization.unregister(this);
1567
+ return ptr;
1568
+ }
1569
+
1570
+ free() {
1571
+ const ptr = this.__destroy_into_raw();
1572
+ wasm.__wbg_noun_free(ptr, 0);
1573
+ }
1574
+ /**
1575
+ * @param {Uint8Array} jam
1576
+ * @returns {Noun}
1577
+ */
1578
+ static cue(jam) {
1579
+ const ptr0 = passArray8ToWasm0(jam, wasm.__wbindgen_malloc);
1580
+ const len0 = WASM_VECTOR_LEN;
1581
+ const ret = wasm.noun_cue(ptr0, len0);
1582
+ if (ret[2]) {
1583
+ throw takeFromExternrefTable0(ret[1]);
1584
+ }
1585
+ return Noun.__wrap(ret[0]);
1586
+ }
1587
+ /**
1588
+ * @returns {Uint8Array}
1589
+ */
1590
+ jam() {
1591
+ const ret = wasm.noun_jam(this.__wbg_ptr);
1592
+ if (ret[3]) {
1593
+ throw takeFromExternrefTable0(ret[2]);
1594
+ }
1595
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1596
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1597
+ return v1;
1598
+ }
1599
+ /**
1600
+ * @param {any} value
1601
+ * @returns {Noun}
1602
+ */
1603
+ static fromJs(value) {
1604
+ const ret = wasm.noun_fromJs(value);
1605
+ if (ret[2]) {
1606
+ throw takeFromExternrefTable0(ret[1]);
1607
+ }
1608
+ return Noun.__wrap(ret[0]);
1609
+ }
1610
+ /**
1611
+ * @returns {any}
1612
+ */
1613
+ toJs() {
1614
+ const ret = wasm.noun_toJs(this.__wbg_ptr);
1615
+ if (ret[2]) {
1616
+ throw takeFromExternrefTable0(ret[1]);
1617
+ }
1618
+ return takeFromExternrefTable0(ret[0]);
1619
+ }
1620
+ }
1621
+ if (Symbol.dispose) Noun.prototype[Symbol.dispose] = Noun.prototype.free;
1622
+
1529
1623
  const PkhFinalization = (typeof FinalizationRegistry === 'undefined')
1530
1624
  ? { register: () => {}, unregister: () => {} }
1531
1625
  : new FinalizationRegistry(ptr => wasm.__wbg_pkh_free(ptr >>> 0, 1));
@@ -1919,6 +2013,20 @@ export class Signature {
1919
2013
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1920
2014
  return v1;
1921
2015
  }
2016
+ /**
2017
+ * @param {Uint8Array} c
2018
+ * @param {Uint8Array} s
2019
+ */
2020
+ constructor(c, s) {
2021
+ const ptr0 = passArray8ToWasm0(c, wasm.__wbindgen_malloc);
2022
+ const len0 = WASM_VECTOR_LEN;
2023
+ const ptr1 = passArray8ToWasm0(s, wasm.__wbindgen_malloc);
2024
+ const len1 = WASM_VECTOR_LEN;
2025
+ const ret = wasm.signature_new(ptr0, len0, ptr1, len1);
2026
+ this.__wbg_ptr = ret >>> 0;
2027
+ SignatureFinalization.register(this, this.__wbg_ptr, this);
2028
+ return this;
2029
+ }
1922
2030
  }
1923
2031
  if (Symbol.dispose) Signature.prototype[Symbol.dispose] = Signature.prototype.free;
1924
2032
 
@@ -2897,6 +3005,16 @@ function __wbg_get_imports() {
2897
3005
  const ret = result;
2898
3006
  return ret;
2899
3007
  };
3008
+ imports.wbg.__wbg_instanceof_Map_8579b5e2ab5437c7 = function(arg0) {
3009
+ let result;
3010
+ try {
3011
+ result = arg0 instanceof Map;
3012
+ } catch (_) {
3013
+ result = false;
3014
+ }
3015
+ const ret = result;
3016
+ return ret;
3017
+ };
2900
3018
  imports.wbg.__wbg_instanceof_Uint8Array_20c8e73002f7af98 = function(arg0) {
2901
3019
  let result;
2902
3020
  try {
@@ -3129,16 +3247,21 @@ function __wbg_get_imports() {
3129
3247
  const ret = getStringFromWasm0(arg0, arg1);
3130
3248
  return ret;
3131
3249
  };
3132
- imports.wbg.__wbindgen_cast_23e23d31be9a5d3c = function(arg0, arg1) {
3133
- // Cast intrinsic for `Closure(Closure { dtor_idx: 252, function: Function { arguments: [Externref], shim_idx: 253, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3134
- const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h20e54f17b0de8c43, wasm_bindgen__convert__closures_____invoke__hbf186e27576c509b);
3135
- return ret;
3136
- };
3137
3250
  imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
3138
3251
  // Cast intrinsic for `U64 -> Externref`.
3139
3252
  const ret = BigInt.asUintN(64, arg0);
3140
3253
  return ret;
3141
3254
  };
3255
+ imports.wbg.__wbindgen_cast_726db96c89a75f21 = function(arg0, arg1) {
3256
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 277, function: Function { arguments: [Externref], shim_idx: 278, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3257
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h20e54f17b0de8c43, wasm_bindgen__convert__closures_____invoke__hbf186e27576c509b);
3258
+ return ret;
3259
+ };
3260
+ imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
3261
+ // Cast intrinsic for `I64 -> Externref`.
3262
+ const ret = arg0;
3263
+ return ret;
3264
+ };
3142
3265
  imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
3143
3266
  // Cast intrinsic for `F64 -> Externref`.
3144
3267
  const ret = arg0;
package/iris_wasm_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "NockBox inc. <tech@nockbox.org>"
6
6
  ],
7
7
  "description": "WASM bindings for Iris wallet",
8
- "version": "0.1.1",
8
+ "version": "0.1.2",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",