@tari-project/ootle-wasm 0.2.0
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/README.md +128 -0
- package/ootle_wasm.d.ts +59 -0
- package/ootle_wasm.js +9 -0
- package/ootle_wasm_bg.js +461 -0
- package/ootle_wasm_bg.wasm +0 -0
- package/package.json +30 -0
package/README.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# ootle-wasm
|
|
2
|
+
|
|
3
|
+
Client-side WebAssembly crypto for [Tari Ootle](https://www.tari.com/) L2. Handles BOR encoding, transaction hashing, Schnorr signing, and key management — with output byte-identical to the native Rust implementation.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @tari-project/ootle-wasm
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## API
|
|
12
|
+
|
|
13
|
+
All keys and signatures are **`Uint8Array`** (raw 32-byte values).
|
|
14
|
+
|
|
15
|
+
### `generateKeypair()`
|
|
16
|
+
|
|
17
|
+
Generate a new random Ristretto255 keypair.
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { generateKeypair } from "@tari-project/ootle-wasm";
|
|
21
|
+
|
|
22
|
+
const { secret_key, public_key } = generateKeypair();
|
|
23
|
+
// secret_key: Uint8Array (32 bytes)
|
|
24
|
+
// public_key: Uint8Array (32 bytes)
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### `publicKeyFromSecretKey(secretKey)`
|
|
28
|
+
|
|
29
|
+
Derive the public key from a secret key.
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { publicKeyFromSecretKey } from "@tari-project/ootle-wasm";
|
|
33
|
+
|
|
34
|
+
const publicKey = publicKeyFromSecretKey(secretKey);
|
|
35
|
+
// publicKey: Uint8Array (32 bytes)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### `hashUnsignedTransaction(unsignedTxJson, sealSignerPublicKey)`
|
|
39
|
+
|
|
40
|
+
Hash an `UnsignedTransactionV1` for signing. Returns a 64-byte `Uint8Array` that should be passed to `schnorrSign`.
|
|
41
|
+
|
|
42
|
+
- `unsignedTxJson` — JSON-serialised `UnsignedTransactionV1`
|
|
43
|
+
- `sealSignerPublicKey` — raw public key bytes of the account owner (seal signer)
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import { hashUnsignedTransaction } from "@tari-project/ootle-wasm";
|
|
47
|
+
|
|
48
|
+
const hash = hashUnsignedTransaction(
|
|
49
|
+
JSON.stringify(unsignedTransaction),
|
|
50
|
+
sealSignerPublicKey,
|
|
51
|
+
);
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### `schnorrSign(secretKey, message)`
|
|
55
|
+
|
|
56
|
+
Schnorr-sign a message (typically the hash from `hashUnsignedTransaction`).
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import { schnorrSign } from "@tari-project/ootle-wasm";
|
|
60
|
+
|
|
61
|
+
const { public_nonce, signature } = schnorrSign(secretKey, hash);
|
|
62
|
+
// public_nonce: Uint8Array (32 bytes)
|
|
63
|
+
// signature: Uint8Array (32 bytes)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### `borEncodeTransaction(transactionJson)`
|
|
67
|
+
|
|
68
|
+
BOR-encode a signed `Transaction` into a base64 `TransactionEnvelope` string, ready to submit to the network.
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
import { borEncodeTransaction } from "@tari-project/ootle-wasm";
|
|
72
|
+
|
|
73
|
+
const envelope = borEncodeTransaction(JSON.stringify(transaction));
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Working with keys
|
|
77
|
+
|
|
78
|
+
Keys and signatures are raw `Uint8Array` bytes. Convert to and from hex strings using the built-in methods (Node 22+, modern browsers):
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
import { generateKeypair, publicKeyFromSecretKey } from "@tari-project/ootle-wasm";
|
|
82
|
+
|
|
83
|
+
// Generate a keypair and display as hex
|
|
84
|
+
const { secret_key, public_key } = generateKeypair();
|
|
85
|
+
console.log("Public key:", public_key.toHex());
|
|
86
|
+
|
|
87
|
+
// Load a key from a hex string
|
|
88
|
+
const restored = Uint8Array.fromHex("a1b2c3...");
|
|
89
|
+
const derivedPublicKey = publicKeyFromSecretKey(restored);
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Full example
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
import {
|
|
96
|
+
generateKeypair,
|
|
97
|
+
publicKeyFromSecretKey,
|
|
98
|
+
hashUnsignedTransaction,
|
|
99
|
+
schnorrSign,
|
|
100
|
+
borEncodeTransaction,
|
|
101
|
+
} from "@tari-project/ootle-wasm";
|
|
102
|
+
|
|
103
|
+
// 1. Generate or load a keypair
|
|
104
|
+
const { secret_key, public_key } = generateKeypair();
|
|
105
|
+
|
|
106
|
+
// 2. Build an unsigned transaction (application-specific)
|
|
107
|
+
const unsignedTx = {
|
|
108
|
+
/* ... UnsignedTransactionV1 fields ... */
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
// 3. Hash for signing
|
|
112
|
+
const hash = hashUnsignedTransaction(JSON.stringify(unsignedTx), public_key);
|
|
113
|
+
|
|
114
|
+
// 4. Sign
|
|
115
|
+
const { public_nonce, signature } = schnorrSign(secret_key, hash);
|
|
116
|
+
|
|
117
|
+
// 5. Assemble the signed transaction and BOR-encode
|
|
118
|
+
const signedTx = {
|
|
119
|
+
/* ... Transaction with signature attached ... */
|
|
120
|
+
};
|
|
121
|
+
const envelope = borEncodeTransaction(JSON.stringify(signedTx));
|
|
122
|
+
|
|
123
|
+
// 6. Submit envelope to the Ootle network
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## License
|
|
127
|
+
|
|
128
|
+
BSD-3-Clause
|
package/ootle_wasm.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A generated keypair (raw bytes).
|
|
6
|
+
*/
|
|
7
|
+
export class KeypairResult {
|
|
8
|
+
private constructor();
|
|
9
|
+
free(): void;
|
|
10
|
+
[Symbol.dispose](): void;
|
|
11
|
+
public_key: Uint8Array;
|
|
12
|
+
secret_key: Uint8Array;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Result of a Schnorr signature operation (raw bytes).
|
|
17
|
+
*/
|
|
18
|
+
export class SchnorrSignatureResult {
|
|
19
|
+
private constructor();
|
|
20
|
+
free(): void;
|
|
21
|
+
[Symbol.dispose](): void;
|
|
22
|
+
public_nonce: Uint8Array;
|
|
23
|
+
signature: Uint8Array;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* BOR-encode a Transaction (JSON string) → base64 string (TransactionEnvelope format).
|
|
28
|
+
*/
|
|
29
|
+
export function borEncodeTransaction(transaction_json: string): string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Generate a new random Ristretto keypair.
|
|
33
|
+
* Returns { secret_key: Uint8Array, public_key: Uint8Array }.
|
|
34
|
+
*/
|
|
35
|
+
export function generateKeypair(): KeypairResult;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Hash an UnsignedTransactionV1 (JSON string) for signing.
|
|
39
|
+
* Returns the 64-byte signing message that must be Schnorr-signed.
|
|
40
|
+
*
|
|
41
|
+
* `seal_signer_public_key` is the raw bytes of the seal signer's public key (account owner).
|
|
42
|
+
*/
|
|
43
|
+
export function hashUnsignedTransaction(unsigned_tx_json: string, seal_signer_public_key: Uint8Array): Uint8Array;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Called automatically when the WASM module is instantiated. Do not call directly.
|
|
47
|
+
*/
|
|
48
|
+
export function on_start(): void;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Derive the public key from a secret key (both raw bytes).
|
|
52
|
+
*/
|
|
53
|
+
export function publicKeyFromSecretKey(secret_key: Uint8Array): Uint8Array;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Schnorr-sign a message with a secret key.
|
|
57
|
+
* Returns { public_nonce: Uint8Array, signature: Uint8Array }.
|
|
58
|
+
*/
|
|
59
|
+
export function schnorrSign(secret_key: Uint8Array, message: Uint8Array): SchnorrSignatureResult;
|
package/ootle_wasm.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* @ts-self-types="./ootle_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
import * as wasm from "./ootle_wasm_bg.wasm";
|
|
4
|
+
import { __wbg_set_wasm } from "./ootle_wasm_bg.js";
|
|
5
|
+
__wbg_set_wasm(wasm);
|
|
6
|
+
wasm.__wbindgen_start();
|
|
7
|
+
export {
|
|
8
|
+
KeypairResult, SchnorrSignatureResult, borEncodeTransaction, generateKeypair, hashUnsignedTransaction, on_start, publicKeyFromSecretKey, schnorrSign
|
|
9
|
+
} from "./ootle_wasm_bg.js";
|
package/ootle_wasm_bg.js
ADDED
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A generated keypair (raw bytes).
|
|
3
|
+
*/
|
|
4
|
+
export class KeypairResult {
|
|
5
|
+
static __wrap(ptr) {
|
|
6
|
+
ptr = ptr >>> 0;
|
|
7
|
+
const obj = Object.create(KeypairResult.prototype);
|
|
8
|
+
obj.__wbg_ptr = ptr;
|
|
9
|
+
KeypairResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
10
|
+
return obj;
|
|
11
|
+
}
|
|
12
|
+
__destroy_into_raw() {
|
|
13
|
+
const ptr = this.__wbg_ptr;
|
|
14
|
+
this.__wbg_ptr = 0;
|
|
15
|
+
KeypairResultFinalization.unregister(this);
|
|
16
|
+
return ptr;
|
|
17
|
+
}
|
|
18
|
+
free() {
|
|
19
|
+
const ptr = this.__destroy_into_raw();
|
|
20
|
+
wasm.__wbg_keypairresult_free(ptr, 0);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* @returns {Uint8Array}
|
|
24
|
+
*/
|
|
25
|
+
get public_key() {
|
|
26
|
+
const ret = wasm.__wbg_get_keypairresult_public_key(this.__wbg_ptr);
|
|
27
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
28
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
29
|
+
return v1;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @returns {Uint8Array}
|
|
33
|
+
*/
|
|
34
|
+
get secret_key() {
|
|
35
|
+
const ret = wasm.__wbg_get_keypairresult_secret_key(this.__wbg_ptr);
|
|
36
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
37
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
38
|
+
return v1;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* @param {Uint8Array} arg0
|
|
42
|
+
*/
|
|
43
|
+
set public_key(arg0) {
|
|
44
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
45
|
+
const len0 = WASM_VECTOR_LEN;
|
|
46
|
+
wasm.__wbg_set_keypairresult_public_key(this.__wbg_ptr, ptr0, len0);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* @param {Uint8Array} arg0
|
|
50
|
+
*/
|
|
51
|
+
set secret_key(arg0) {
|
|
52
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
53
|
+
const len0 = WASM_VECTOR_LEN;
|
|
54
|
+
wasm.__wbg_set_keypairresult_secret_key(this.__wbg_ptr, ptr0, len0);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (Symbol.dispose) KeypairResult.prototype[Symbol.dispose] = KeypairResult.prototype.free;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Result of a Schnorr signature operation (raw bytes).
|
|
61
|
+
*/
|
|
62
|
+
export class SchnorrSignatureResult {
|
|
63
|
+
static __wrap(ptr) {
|
|
64
|
+
ptr = ptr >>> 0;
|
|
65
|
+
const obj = Object.create(SchnorrSignatureResult.prototype);
|
|
66
|
+
obj.__wbg_ptr = ptr;
|
|
67
|
+
SchnorrSignatureResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
68
|
+
return obj;
|
|
69
|
+
}
|
|
70
|
+
__destroy_into_raw() {
|
|
71
|
+
const ptr = this.__wbg_ptr;
|
|
72
|
+
this.__wbg_ptr = 0;
|
|
73
|
+
SchnorrSignatureResultFinalization.unregister(this);
|
|
74
|
+
return ptr;
|
|
75
|
+
}
|
|
76
|
+
free() {
|
|
77
|
+
const ptr = this.__destroy_into_raw();
|
|
78
|
+
wasm.__wbg_schnorrsignatureresult_free(ptr, 0);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* @returns {Uint8Array}
|
|
82
|
+
*/
|
|
83
|
+
get public_nonce() {
|
|
84
|
+
const ret = wasm.__wbg_get_schnorrsignatureresult_public_nonce(this.__wbg_ptr);
|
|
85
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
86
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
87
|
+
return v1;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* @returns {Uint8Array}
|
|
91
|
+
*/
|
|
92
|
+
get signature() {
|
|
93
|
+
const ret = wasm.__wbg_get_schnorrsignatureresult_signature(this.__wbg_ptr);
|
|
94
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
95
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
96
|
+
return v1;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* @param {Uint8Array} arg0
|
|
100
|
+
*/
|
|
101
|
+
set public_nonce(arg0) {
|
|
102
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
103
|
+
const len0 = WASM_VECTOR_LEN;
|
|
104
|
+
wasm.__wbg_set_keypairresult_secret_key(this.__wbg_ptr, ptr0, len0);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* @param {Uint8Array} arg0
|
|
108
|
+
*/
|
|
109
|
+
set signature(arg0) {
|
|
110
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
111
|
+
const len0 = WASM_VECTOR_LEN;
|
|
112
|
+
wasm.__wbg_set_keypairresult_public_key(this.__wbg_ptr, ptr0, len0);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (Symbol.dispose) SchnorrSignatureResult.prototype[Symbol.dispose] = SchnorrSignatureResult.prototype.free;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* BOR-encode a Transaction (JSON string) → base64 string (TransactionEnvelope format).
|
|
119
|
+
* @param {string} transaction_json
|
|
120
|
+
* @returns {string}
|
|
121
|
+
*/
|
|
122
|
+
export function borEncodeTransaction(transaction_json) {
|
|
123
|
+
let deferred3_0;
|
|
124
|
+
let deferred3_1;
|
|
125
|
+
try {
|
|
126
|
+
const ptr0 = passStringToWasm0(transaction_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
127
|
+
const len0 = WASM_VECTOR_LEN;
|
|
128
|
+
const ret = wasm.borEncodeTransaction(ptr0, len0);
|
|
129
|
+
var ptr2 = ret[0];
|
|
130
|
+
var len2 = ret[1];
|
|
131
|
+
if (ret[3]) {
|
|
132
|
+
ptr2 = 0; len2 = 0;
|
|
133
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
134
|
+
}
|
|
135
|
+
deferred3_0 = ptr2;
|
|
136
|
+
deferred3_1 = len2;
|
|
137
|
+
return getStringFromWasm0(ptr2, len2);
|
|
138
|
+
} finally {
|
|
139
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Generate a new random Ristretto keypair.
|
|
145
|
+
* Returns { secret_key: Uint8Array, public_key: Uint8Array }.
|
|
146
|
+
* @returns {KeypairResult}
|
|
147
|
+
*/
|
|
148
|
+
export function generateKeypair() {
|
|
149
|
+
const ret = wasm.generateKeypair();
|
|
150
|
+
return KeypairResult.__wrap(ret);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Hash an UnsignedTransactionV1 (JSON string) for signing.
|
|
155
|
+
* Returns the 64-byte signing message that must be Schnorr-signed.
|
|
156
|
+
*
|
|
157
|
+
* `seal_signer_public_key` is the raw bytes of the seal signer's public key (account owner).
|
|
158
|
+
* @param {string} unsigned_tx_json
|
|
159
|
+
* @param {Uint8Array} seal_signer_public_key
|
|
160
|
+
* @returns {Uint8Array}
|
|
161
|
+
*/
|
|
162
|
+
export function hashUnsignedTransaction(unsigned_tx_json, seal_signer_public_key) {
|
|
163
|
+
const ptr0 = passStringToWasm0(unsigned_tx_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
164
|
+
const len0 = WASM_VECTOR_LEN;
|
|
165
|
+
const ptr1 = passArray8ToWasm0(seal_signer_public_key, wasm.__wbindgen_malloc);
|
|
166
|
+
const len1 = WASM_VECTOR_LEN;
|
|
167
|
+
const ret = wasm.hashUnsignedTransaction(ptr0, len0, ptr1, len1);
|
|
168
|
+
if (ret[3]) {
|
|
169
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
170
|
+
}
|
|
171
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
172
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
173
|
+
return v3;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Called automatically when the WASM module is instantiated. Do not call directly.
|
|
178
|
+
*/
|
|
179
|
+
export function on_start() {
|
|
180
|
+
wasm.on_start();
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Derive the public key from a secret key (both raw bytes).
|
|
185
|
+
* @param {Uint8Array} secret_key
|
|
186
|
+
* @returns {Uint8Array}
|
|
187
|
+
*/
|
|
188
|
+
export function publicKeyFromSecretKey(secret_key) {
|
|
189
|
+
const ptr0 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);
|
|
190
|
+
const len0 = WASM_VECTOR_LEN;
|
|
191
|
+
const ret = wasm.publicKeyFromSecretKey(ptr0, len0);
|
|
192
|
+
if (ret[3]) {
|
|
193
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
194
|
+
}
|
|
195
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
196
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
197
|
+
return v2;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Schnorr-sign a message with a secret key.
|
|
202
|
+
* Returns { public_nonce: Uint8Array, signature: Uint8Array }.
|
|
203
|
+
* @param {Uint8Array} secret_key
|
|
204
|
+
* @param {Uint8Array} message
|
|
205
|
+
* @returns {SchnorrSignatureResult}
|
|
206
|
+
*/
|
|
207
|
+
export function schnorrSign(secret_key, message) {
|
|
208
|
+
const ptr0 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);
|
|
209
|
+
const len0 = WASM_VECTOR_LEN;
|
|
210
|
+
const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
|
|
211
|
+
const len1 = WASM_VECTOR_LEN;
|
|
212
|
+
const ret = wasm.schnorrSign(ptr0, len0, ptr1, len1);
|
|
213
|
+
if (ret[2]) {
|
|
214
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
215
|
+
}
|
|
216
|
+
return SchnorrSignatureResult.__wrap(ret[0]);
|
|
217
|
+
}
|
|
218
|
+
export function __wbg_Error_8c4e43fe74559d73(arg0, arg1) {
|
|
219
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
220
|
+
return ret;
|
|
221
|
+
}
|
|
222
|
+
export function __wbg___wbindgen_is_function_0095a73b8b156f76(arg0) {
|
|
223
|
+
const ret = typeof(arg0) === 'function';
|
|
224
|
+
return ret;
|
|
225
|
+
}
|
|
226
|
+
export function __wbg___wbindgen_is_object_5ae8e5880f2c1fbd(arg0) {
|
|
227
|
+
const val = arg0;
|
|
228
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
229
|
+
return ret;
|
|
230
|
+
}
|
|
231
|
+
export function __wbg___wbindgen_is_string_cd444516edc5b180(arg0) {
|
|
232
|
+
const ret = typeof(arg0) === 'string';
|
|
233
|
+
return ret;
|
|
234
|
+
}
|
|
235
|
+
export function __wbg___wbindgen_is_undefined_9e4d92534c42d778(arg0) {
|
|
236
|
+
const ret = arg0 === undefined;
|
|
237
|
+
return ret;
|
|
238
|
+
}
|
|
239
|
+
export function __wbg___wbindgen_throw_be289d5034ed271b(arg0, arg1) {
|
|
240
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
241
|
+
}
|
|
242
|
+
export function __wbg_call_389efe28435a9388() { return handleError(function (arg0, arg1) {
|
|
243
|
+
const ret = arg0.call(arg1);
|
|
244
|
+
return ret;
|
|
245
|
+
}, arguments); }
|
|
246
|
+
export function __wbg_call_4708e0c13bdc8e95() { return handleError(function (arg0, arg1, arg2) {
|
|
247
|
+
const ret = arg0.call(arg1, arg2);
|
|
248
|
+
return ret;
|
|
249
|
+
}, arguments); }
|
|
250
|
+
export function __wbg_crypto_86f2631e91b51511(arg0) {
|
|
251
|
+
const ret = arg0.crypto;
|
|
252
|
+
return ret;
|
|
253
|
+
}
|
|
254
|
+
export function __wbg_getRandomValues_b3f15fcbfabb0f8b() { return handleError(function (arg0, arg1) {
|
|
255
|
+
arg0.getRandomValues(arg1);
|
|
256
|
+
}, arguments); }
|
|
257
|
+
export function __wbg_length_32ed9a279acd054c(arg0) {
|
|
258
|
+
const ret = arg0.length;
|
|
259
|
+
return ret;
|
|
260
|
+
}
|
|
261
|
+
export function __wbg_msCrypto_d562bbe83e0d4b91(arg0) {
|
|
262
|
+
const ret = arg0.msCrypto;
|
|
263
|
+
return ret;
|
|
264
|
+
}
|
|
265
|
+
export function __wbg_new_no_args_1c7c842f08d00ebb(arg0, arg1) {
|
|
266
|
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
267
|
+
return ret;
|
|
268
|
+
}
|
|
269
|
+
export function __wbg_new_with_length_a2c39cbe88fd8ff1(arg0) {
|
|
270
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
271
|
+
return ret;
|
|
272
|
+
}
|
|
273
|
+
export function __wbg_node_e1f24f89a7336c2e(arg0) {
|
|
274
|
+
const ret = arg0.node;
|
|
275
|
+
return ret;
|
|
276
|
+
}
|
|
277
|
+
export function __wbg_process_3975fd6c72f520aa(arg0) {
|
|
278
|
+
const ret = arg0.process;
|
|
279
|
+
return ret;
|
|
280
|
+
}
|
|
281
|
+
export function __wbg_prototypesetcall_bdcdcc5842e4d77d(arg0, arg1, arg2) {
|
|
282
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
283
|
+
}
|
|
284
|
+
export function __wbg_randomFillSync_f8c153b79f285817() { return handleError(function (arg0, arg1) {
|
|
285
|
+
arg0.randomFillSync(arg1);
|
|
286
|
+
}, arguments); }
|
|
287
|
+
export function __wbg_require_b74f47fc2d022fd6() { return handleError(function () {
|
|
288
|
+
const ret = module.require;
|
|
289
|
+
return ret;
|
|
290
|
+
}, arguments); }
|
|
291
|
+
export function __wbg_static_accessor_GLOBAL_12837167ad935116() {
|
|
292
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
293
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
294
|
+
}
|
|
295
|
+
export function __wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f() {
|
|
296
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
297
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
298
|
+
}
|
|
299
|
+
export function __wbg_static_accessor_SELF_a621d3dfbb60d0ce() {
|
|
300
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
301
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
302
|
+
}
|
|
303
|
+
export function __wbg_static_accessor_WINDOW_f8727f0cf888e0bd() {
|
|
304
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
305
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
306
|
+
}
|
|
307
|
+
export function __wbg_subarray_a96e1fef17ed23cb(arg0, arg1, arg2) {
|
|
308
|
+
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
309
|
+
return ret;
|
|
310
|
+
}
|
|
311
|
+
export function __wbg_versions_4e31226f5e8dc909(arg0) {
|
|
312
|
+
const ret = arg0.versions;
|
|
313
|
+
return ret;
|
|
314
|
+
}
|
|
315
|
+
export function __wbindgen_cast_0000000000000001(arg0, arg1) {
|
|
316
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
317
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
318
|
+
return ret;
|
|
319
|
+
}
|
|
320
|
+
export function __wbindgen_cast_0000000000000002(arg0, arg1) {
|
|
321
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
322
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
323
|
+
return ret;
|
|
324
|
+
}
|
|
325
|
+
export function __wbindgen_init_externref_table() {
|
|
326
|
+
const table = wasm.__wbindgen_externrefs;
|
|
327
|
+
const offset = table.grow(4);
|
|
328
|
+
table.set(0, undefined);
|
|
329
|
+
table.set(offset + 0, undefined);
|
|
330
|
+
table.set(offset + 1, null);
|
|
331
|
+
table.set(offset + 2, true);
|
|
332
|
+
table.set(offset + 3, false);
|
|
333
|
+
}
|
|
334
|
+
const KeypairResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
335
|
+
? { register: () => {}, unregister: () => {} }
|
|
336
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_keypairresult_free(ptr >>> 0, 1));
|
|
337
|
+
const SchnorrSignatureResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
338
|
+
? { register: () => {}, unregister: () => {} }
|
|
339
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_schnorrsignatureresult_free(ptr >>> 0, 1));
|
|
340
|
+
|
|
341
|
+
function addToExternrefTable0(obj) {
|
|
342
|
+
const idx = wasm.__externref_table_alloc();
|
|
343
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
344
|
+
return idx;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
348
|
+
ptr = ptr >>> 0;
|
|
349
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function getStringFromWasm0(ptr, len) {
|
|
353
|
+
ptr = ptr >>> 0;
|
|
354
|
+
return decodeText(ptr, len);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
let cachedUint8ArrayMemory0 = null;
|
|
358
|
+
function getUint8ArrayMemory0() {
|
|
359
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
360
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
361
|
+
}
|
|
362
|
+
return cachedUint8ArrayMemory0;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function handleError(f, args) {
|
|
366
|
+
try {
|
|
367
|
+
return f.apply(this, args);
|
|
368
|
+
} catch (e) {
|
|
369
|
+
const idx = addToExternrefTable0(e);
|
|
370
|
+
wasm.__wbindgen_exn_store(idx);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
function isLikeNone(x) {
|
|
375
|
+
return x === undefined || x === null;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
379
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
380
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
381
|
+
WASM_VECTOR_LEN = arg.length;
|
|
382
|
+
return ptr;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
386
|
+
if (realloc === undefined) {
|
|
387
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
388
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
389
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
390
|
+
WASM_VECTOR_LEN = buf.length;
|
|
391
|
+
return ptr;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
let len = arg.length;
|
|
395
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
396
|
+
|
|
397
|
+
const mem = getUint8ArrayMemory0();
|
|
398
|
+
|
|
399
|
+
let offset = 0;
|
|
400
|
+
|
|
401
|
+
for (; offset < len; offset++) {
|
|
402
|
+
const code = arg.charCodeAt(offset);
|
|
403
|
+
if (code > 0x7F) break;
|
|
404
|
+
mem[ptr + offset] = code;
|
|
405
|
+
}
|
|
406
|
+
if (offset !== len) {
|
|
407
|
+
if (offset !== 0) {
|
|
408
|
+
arg = arg.slice(offset);
|
|
409
|
+
}
|
|
410
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
411
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
412
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
413
|
+
|
|
414
|
+
offset += ret.written;
|
|
415
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
WASM_VECTOR_LEN = offset;
|
|
419
|
+
return ptr;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
function takeFromExternrefTable0(idx) {
|
|
423
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
424
|
+
wasm.__externref_table_dealloc(idx);
|
|
425
|
+
return value;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
429
|
+
cachedTextDecoder.decode();
|
|
430
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
431
|
+
let numBytesDecoded = 0;
|
|
432
|
+
function decodeText(ptr, len) {
|
|
433
|
+
numBytesDecoded += len;
|
|
434
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
435
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
436
|
+
cachedTextDecoder.decode();
|
|
437
|
+
numBytesDecoded = len;
|
|
438
|
+
}
|
|
439
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
const cachedTextEncoder = new TextEncoder();
|
|
443
|
+
|
|
444
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
445
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
446
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
447
|
+
view.set(buf);
|
|
448
|
+
return {
|
|
449
|
+
read: arg.length,
|
|
450
|
+
written: buf.length
|
|
451
|
+
};
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
let WASM_VECTOR_LEN = 0;
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
let wasm;
|
|
459
|
+
export function __wbg_set_wasm(val) {
|
|
460
|
+
wasm = val;
|
|
461
|
+
}
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tari-project/ootle-wasm",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"collaborators": [
|
|
5
|
+
"The Tari Development Community"
|
|
6
|
+
],
|
|
7
|
+
"description": "WASM bindings for Tari Ootle client-side crypto — thin wasm-bindgen shell over ootle-wasm-core",
|
|
8
|
+
"version": "0.2.0",
|
|
9
|
+
"license": "BSD-3-Clause",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/tari-project/tari-ootle"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"ootle_wasm_bg.wasm",
|
|
16
|
+
"ootle_wasm.js",
|
|
17
|
+
"ootle_wasm_bg.js",
|
|
18
|
+
"ootle_wasm.d.ts",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
21
|
+
"main": "ootle_wasm.js",
|
|
22
|
+
"types": "ootle_wasm.d.ts",
|
|
23
|
+
"sideEffects": [
|
|
24
|
+
"./ootle_wasm.js",
|
|
25
|
+
"./snippets/*"
|
|
26
|
+
],
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
}
|
|
30
|
+
}
|