@chironbuilder/ootle-sdk 0.1.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/LICENSE +21 -0
- package/README.md +90 -0
- package/dist/accountApi.d.ts +33 -0
- package/dist/accountApi.d.ts.map +1 -0
- package/dist/accountApi.js +1 -0
- package/dist/adapters.d.ts +13 -0
- package/dist/adapters.d.ts.map +1 -0
- package/dist/adapters.js +68 -0
- package/dist/componentAddress.d.ts +27 -0
- package/dist/componentAddress.d.ts.map +1 -0
- package/dist/componentAddress.js +68 -0
- package/dist/confidential.d.ts +50 -0
- package/dist/confidential.d.ts.map +1 -0
- package/dist/confidential.js +86 -0
- package/dist/derivation.d.ts +7 -0
- package/dist/derivation.d.ts.map +1 -0
- package/dist/derivation.js +47 -0
- package/dist/domainHash.d.ts +11 -0
- package/dist/domainHash.d.ts.map +1 -0
- package/dist/domainHash.js +44 -0
- package/dist/htlc.d.ts +26 -0
- package/dist/htlc.d.ts.map +1 -0
- package/dist/htlc.js +69 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/ootleNetwork.d.ts +4 -0
- package/dist/ootleNetwork.d.ts.map +1 -0
- package/dist/ootleNetwork.js +11 -0
- package/dist/ownershipProof.d.ts +4 -0
- package/dist/ownershipProof.d.ts.map +1 -0
- package/dist/ownershipProof.js +53 -0
- package/dist/storage.d.ts +61 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +110 -0
- package/dist/timeout.d.ts +2 -0
- package/dist/timeout.d.ts.map +1 -0
- package/dist/timeout.js +19 -0
- package/dist/vault.d.ts +12 -0
- package/dist/vault.d.ts.map +1 -0
- package/dist/vault.js +44 -0
- package/dist/wallet.d.ts +733 -0
- package/dist/wallet.d.ts.map +1 -0
- package/dist/wallet.js +1964 -0
- package/package.json +46 -0
- package/vendor/ootle-patched/README.md +67 -0
- package/vendor/ootle-patched/dist/index.d.ts +2129 -0
- package/vendor/ootle-patched/dist/index.js +1365 -0
- package/vendor/ootle-patched/package.json +23 -0
- package/vendor/ootle-wasm-patched/README.md +128 -0
- package/vendor/ootle-wasm-patched/ootle_wasm.d.ts +454 -0
- package/vendor/ootle-wasm-patched/ootle_wasm.js +9 -0
- package/vendor/ootle-wasm-patched/ootle_wasm_bg.js +1485 -0
- package/vendor/ootle-wasm-patched/ootle_wasm_bg.wasm +0 -0
- package/vendor/ootle-wasm-patched/ootle_wasm_bg.wasm.d.ts +83 -0
- package/vendor/ootle-wasm-patched/package.json +27 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tari-project/ootle",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"browser": "./dist/index.js",
|
|
14
|
+
"node": "./dist/index.js",
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@tari-project/ootle-ts-bindings": "^1.49.1",
|
|
21
|
+
"@tari-project/ootle-wasm": "^0.39.1"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -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
|
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Decrypted contents of an inbound stealth UTXO.
|
|
6
|
+
*/
|
|
7
|
+
export class DecryptedOutputResult {
|
|
8
|
+
private constructor();
|
|
9
|
+
free(): void;
|
|
10
|
+
[Symbol.dispose](): void;
|
|
11
|
+
/**
|
|
12
|
+
* The 32-byte commitment mask scalar.
|
|
13
|
+
*/
|
|
14
|
+
mask: Uint8Array;
|
|
15
|
+
/**
|
|
16
|
+
* JSON-encoded `Memo` (variants: `U256` / `Message` / `Bytes` / `PayRefAndBytes`), or `null` if
|
|
17
|
+
* the payload carried no memo or `skipMemo` was set.
|
|
18
|
+
*/
|
|
19
|
+
get memo_json(): string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* JSON-encoded `Memo` (variants: `U256` / `Message` / `Bytes` / `PayRefAndBytes`), or `null` if
|
|
22
|
+
* the payload carried no memo or `skipMemo` was set.
|
|
23
|
+
*/
|
|
24
|
+
set memo_json(value: string | null | undefined);
|
|
25
|
+
/**
|
|
26
|
+
* The plaintext value (u64).
|
|
27
|
+
*/
|
|
28
|
+
value: bigint;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A generated keypair (raw bytes).
|
|
33
|
+
*/
|
|
34
|
+
export class KeypairResult {
|
|
35
|
+
private constructor();
|
|
36
|
+
free(): void;
|
|
37
|
+
[Symbol.dispose](): void;
|
|
38
|
+
public_key: Uint8Array;
|
|
39
|
+
secret_key: Uint8Array;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* A pair of Ootle public keys derived from an OotleSecretKey.
|
|
44
|
+
*/
|
|
45
|
+
export class OotlePublicKey {
|
|
46
|
+
private constructor();
|
|
47
|
+
free(): void;
|
|
48
|
+
[Symbol.dispose](): void;
|
|
49
|
+
/**
|
|
50
|
+
* The owner (spending) public key bytes.
|
|
51
|
+
*/
|
|
52
|
+
owner_key: Uint8Array;
|
|
53
|
+
/**
|
|
54
|
+
* The view-only public key bytes.
|
|
55
|
+
*/
|
|
56
|
+
view_key: Uint8Array;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* A pair of Ootle secret keys (owner + view).
|
|
61
|
+
*/
|
|
62
|
+
export class OotleSecretKey {
|
|
63
|
+
private constructor();
|
|
64
|
+
free(): void;
|
|
65
|
+
[Symbol.dispose](): void;
|
|
66
|
+
/**
|
|
67
|
+
* The owner (spending) secret key bytes.
|
|
68
|
+
*/
|
|
69
|
+
owner_key: Uint8Array;
|
|
70
|
+
/**
|
|
71
|
+
* The view-only secret key bytes.
|
|
72
|
+
*/
|
|
73
|
+
view_key: Uint8Array;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Parsed components of an Ootle address.
|
|
78
|
+
*/
|
|
79
|
+
export class ParsedOotleAddress {
|
|
80
|
+
private constructor();
|
|
81
|
+
free(): void;
|
|
82
|
+
[Symbol.dispose](): void;
|
|
83
|
+
/**
|
|
84
|
+
* Optional pay reference / memo bytes.
|
|
85
|
+
*/
|
|
86
|
+
get memo(): Uint8Array | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Optional pay reference / memo bytes.
|
|
89
|
+
*/
|
|
90
|
+
set memo(value: Uint8Array | null | undefined);
|
|
91
|
+
/**
|
|
92
|
+
* The network byte.
|
|
93
|
+
*/
|
|
94
|
+
network: number;
|
|
95
|
+
/**
|
|
96
|
+
* The owner (spending) public key bytes.
|
|
97
|
+
*/
|
|
98
|
+
owner_key: Uint8Array;
|
|
99
|
+
/**
|
|
100
|
+
* The view-only public key bytes.
|
|
101
|
+
*/
|
|
102
|
+
view_key: Uint8Array;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Result of a Schnorr signature operation (raw bytes). Also used for balance proof signatures, which
|
|
107
|
+
* share the `(public_nonce, signature)` shape.
|
|
108
|
+
*/
|
|
109
|
+
export class SchnorrSignatureResult {
|
|
110
|
+
private constructor();
|
|
111
|
+
free(): void;
|
|
112
|
+
[Symbol.dispose](): void;
|
|
113
|
+
public_nonce: Uint8Array;
|
|
114
|
+
signature: Uint8Array;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Result of generating a stealth outputs statement.
|
|
119
|
+
*/
|
|
120
|
+
export class StealthOutputsResult {
|
|
121
|
+
private constructor();
|
|
122
|
+
free(): void;
|
|
123
|
+
[Symbol.dispose](): void;
|
|
124
|
+
/**
|
|
125
|
+
* Sum of all witness masks, suitable for use as the `aggregated_output_mask` argument to
|
|
126
|
+
* `generateStealthBalanceProofSignature`.
|
|
127
|
+
*/
|
|
128
|
+
aggregated_output_mask: Uint8Array;
|
|
129
|
+
/**
|
|
130
|
+
* JSON-serialized `StealthOutputsStatement` (the wire-format payload).
|
|
131
|
+
*/
|
|
132
|
+
statement_json: string;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Add a signer to a transaction (unsigned or unsealed JSON).
|
|
137
|
+
*
|
|
138
|
+
* Accepts either an `UnsignedTransactionV1` or `UnsealedTransactionV1` JSON string.
|
|
139
|
+
* Returns the `UnsealedTransactionV1` (with the new signature appended) as a JSON string.
|
|
140
|
+
*/
|
|
141
|
+
export function addTransactionSigner(tx_json: string, signer_secret_key: Uint8Array, seal_signer_public_key: Uint8Array): string;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Aggregate the commitment masks of stealth inputs into a single 32-byte Ristretto scalar.
|
|
145
|
+
*
|
|
146
|
+
* `masks_concat` is the concatenated bytes of all input masks (32 bytes per mask, so the input
|
|
147
|
+
* length must be a multiple of 32). Pass an empty array to obtain the zero scalar.
|
|
148
|
+
*
|
|
149
|
+
* Returns the sum as 32 bytes, suitable as the `aggregated_input_mask` argument to
|
|
150
|
+
* `generateStealthBalanceProofSignature`. The output side of the same balance proof is aggregated
|
|
151
|
+
* automatically by `generateStealthOutputsStatement` (returned as `aggregated_output_mask`).
|
|
152
|
+
*/
|
|
153
|
+
export function aggregateInputMasks(masks_concat: Uint8Array): Uint8Array;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* BOR-encode a Transaction (JSON string) → base64 string (TransactionEnvelope format).
|
|
157
|
+
*/
|
|
158
|
+
export function borEncodeTransaction(transaction_json: string): string;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Build a script-path `SpendWitness` revealing `leaf` from the committed `conditions` set, optionally
|
|
162
|
+
* supplying a witness `data` blob the leaf's predicate interprets (e.g. a hashlock preimage). Returns a
|
|
163
|
+
* JSON object: `{ "witness": <SpendWitness>, "condition_root": <Hash32> }`.
|
|
164
|
+
*
|
|
165
|
+
* `conditions_json` is the JSON array of `SpendCondition` leaves exactly as passed to
|
|
166
|
+
* `createStealthOutputWitness`'s `PayTo::Conditions` when the output was created; `leaf_json` is the
|
|
167
|
+
* single leaf being revealed. The returned `condition_root` must match the `Script` root recorded in
|
|
168
|
+
* that output's `SpendAuthorization` -- record it against the spent input via
|
|
169
|
+
* `buildStealthInputsStatementFromInputs`.
|
|
170
|
+
*
|
|
171
|
+
* Pass an empty `data` array for a leaf whose predicate needs no spender-supplied data (e.g. a plain
|
|
172
|
+
* timelock refund).
|
|
173
|
+
*/
|
|
174
|
+
export function buildScriptPathWitness(conditions_json: string, leaf_json: string, data: Uint8Array): string;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Build a `StealthInputsStatement` JSON from raw input commitments and a revealed amount.
|
|
178
|
+
*
|
|
179
|
+
* `input_commitments` is the concatenated bytes of all 32-byte commitments (so the length must be a
|
|
180
|
+
* multiple of 32). Pass an empty array for a revealed-only statement.
|
|
181
|
+
*
|
|
182
|
+
* This is a convenience helper so callers don't need to hand-craft the wire JSON; the result is used
|
|
183
|
+
* as the `inputs_statement_json` argument to `generateStealthBalanceProofSignature` and friends.
|
|
184
|
+
*/
|
|
185
|
+
export function buildStealthInputsStatement(input_commitments: Uint8Array, revealed_amount_microtari: bigint): string;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Build a `StealthInputsStatement` JSON from a JSON array of per-input `{commitment, witness}` pairs
|
|
189
|
+
* and a revealed amount.
|
|
190
|
+
*
|
|
191
|
+
* Unlike `buildStealthInputsStatement`, which only builds key-path inputs from raw commitment bytes,
|
|
192
|
+
* this accepts a caller-supplied `witness` per input -- the only way to spend an output committed with
|
|
193
|
+
* `PayTo::Conditions` (e.g. claiming or refunding an HTLC-style hashlock/timelock output). Build each
|
|
194
|
+
* script-path input's witness with `buildScriptPathWitness` first; a plain key-path input can still be
|
|
195
|
+
* included in the same call, either with `"witness":"KeyPath"` or by omitting `witness` entirely
|
|
196
|
+
* (defaults to key path).
|
|
197
|
+
*
|
|
198
|
+
* `inputs_json` shape: `[{ "commitment": <hex 32 bytes>, "witness"?: <SpendWitness> }, ...]`.
|
|
199
|
+
*/
|
|
200
|
+
export function buildStealthInputsStatementFromInputs(inputs_json: string, revealed_amount_microtari: bigint): string;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Build a complete `StealthTransferStatement` JSON from unblinded input/output witnesses.
|
|
204
|
+
*
|
|
205
|
+
* Unlike `generateStealthOutputsStatement` / `buildStealthInputsStatementFromInputs` +
|
|
206
|
+
* `generateStealthBalanceProofSignature`, which build and sign each half of a transfer
|
|
207
|
+
* separately, this wraps the single primitive that produces the *entire*, internally-consistent
|
|
208
|
+
* statement in one call, including a covenant balance-integrity proof for any script-path input
|
|
209
|
+
* whose revealed leaf gates on `Covenant::BalancePreserved` (see `ootle_wasm_core::stealth::
|
|
210
|
+
* transfer::build_stealth_transfer_statement` for when a claim is and isn't needed).
|
|
211
|
+
*
|
|
212
|
+
* `input_witnesses_json` is a JSON array of `{ "mask_and_value": { "value": <u64>, "mask": <hex
|
|
213
|
+
* 32 bytes> }, "witness"?: <SpendWitness>, "condition_root"?: <Hash32> }` -- each entry's
|
|
214
|
+
* `witness`/`condition_root` are the exact pair `buildScriptPathWitness` returns, for a
|
|
215
|
+
* script-path input; omit both for a plain key-path input. Mixing key-path and script-path
|
|
216
|
+
* inputs in one call is supported.
|
|
217
|
+
*
|
|
218
|
+
* `output_witnesses_json` is a JSON array of the same `{ "witness": {...}, "auth": ..., "tag":
|
|
219
|
+
* ... }` shape `createStealthOutputWitness` returns -- collect one entry per output (including
|
|
220
|
+
* change).
|
|
221
|
+
*/
|
|
222
|
+
export function buildStealthTransferStatement(input_witnesses_json: string, revealed_input_amount_microtari: bigint, output_witnesses_json: string, revealed_output_amount_microtari: bigint): string;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Builds a `ConfidentialWithdrawProof` for the Account template's `withdraw_confidential` /
|
|
226
|
+
* `join_confidential` methods, and returns it `tari_bor`-encoded -- ready to hex-encode and wrap
|
|
227
|
+
* as an instruction `Literal` arg exactly like `microTariLiteral`/`amountLiteral` do for simpler
|
|
228
|
+
* types. Unlike those, this is NOT re-encoded on the JS side: the bytes are already the encoding
|
|
229
|
+
* the chain itself decodes, produced by the same derive-generated `Encode` impl.
|
|
230
|
+
*
|
|
231
|
+
* `inputs_json` is a JSON array of `{ value, mask }` for each confidential UTXO being spent — `"[]"`
|
|
232
|
+
* for a revealed-only withdrawal (depositing into the vault). `output_json` / `change_json` are each
|
|
233
|
+
* an optional JSON object (see `createStealthOutputWitness`'s `OutputWitnessJson` shape) — omit to
|
|
234
|
+
* skip that side. `*_revealed_amount` is the plaintext portion on each side; confidential and
|
|
235
|
+
* revealed amounts can be mixed on either side.
|
|
236
|
+
*
|
|
237
|
+
* Throws if `inputs_json`/`output_json`/`change_json` don't parse, or if any mask isn't a valid
|
|
238
|
+
* 32-byte Ristretto scalar.
|
|
239
|
+
*/
|
|
240
|
+
export function createConfidentialWithdrawProofLiteral(inputs_json: string, input_revealed_amount: bigint, output_json: string | null | undefined, output_revealed_amount: bigint, change_json: string | null | undefined, change_revealed_amount: bigint): Uint8Array;
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Build a single stealth output witness entirely client-side (sender side), mirroring the wallet
|
|
244
|
+
* daemon's `create_output_witness`.
|
|
245
|
+
*
|
|
246
|
+
* A fresh commitment mask and ephemeral nonce are generated internally; the recipient recovers the
|
|
247
|
+
* value and mask by decrypting `encrypted_data`. Returns one witness as a JSON string with the shape:
|
|
248
|
+
* ```text
|
|
249
|
+
* {
|
|
250
|
+
* "witness": {
|
|
251
|
+
* "amount": <u64>,
|
|
252
|
+
* "mask": <hex 32 bytes>,
|
|
253
|
+
* "sender_public_nonce": <hex 32 bytes>,
|
|
254
|
+
* "minimum_value_promise": <u64>,
|
|
255
|
+
* "encrypted_data": <hex variable-length>,
|
|
256
|
+
* "resource_view_key": <hex 32 bytes | null>
|
|
257
|
+
* },
|
|
258
|
+
* "auth": <SpendAuthorization>,
|
|
259
|
+
* "tag": <u32>
|
|
260
|
+
* }
|
|
261
|
+
* ```
|
|
262
|
+
* Collect one witness per output (including change) into a JSON array and pass it to
|
|
263
|
+
* `generateStealthOutputsStatement`.
|
|
264
|
+
*
|
|
265
|
+
* - `network` is the network byte (0x00 = MainNet, 0x10 = LocalNet, 0x26 = Esmeralda, ...).
|
|
266
|
+
* - `destination_account_public_key` / `destination_view_public_key` are the recipient's 32-byte keys.
|
|
267
|
+
* - `resource_address` is the `resource_<hex>` string of the resource being sent.
|
|
268
|
+
* - `resource_view_key` is the resource view-key holder's 32-byte public key, or `null` for resources without a
|
|
269
|
+
* viewable balance (when set, the output receives an ElGamal proof at statement time).
|
|
270
|
+
* - `memo_json` is an optional JSON-encoded `Memo` to embed in the encrypted payload.
|
|
271
|
+
* - `pay_to_json` is an optional JSON-encoded `PayTo`: `"StealthPublicKey"` (the default when `null`, producing a
|
|
272
|
+
* one-time stealth spend key) or `{"AccessRule": <AccessRule>}`.
|
|
273
|
+
* - `minimum_value_promise` is the range-proof lower bound and must be `<= amount` (use `0` normally).
|
|
274
|
+
*/
|
|
275
|
+
export function createStealthOutputWitness(network: number, destination_account_public_key: Uint8Array, destination_view_public_key: Uint8Array, amount: bigint, resource_address: string, resource_view_key: Uint8Array | null | undefined, memo_json: string | null | undefined, pay_to_json: string | null | undefined, minimum_value_promise: bigint): string;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Brute-force decrypt an ElGamal viewable-balance proof to recover the bound value.
|
|
279
|
+
*
|
|
280
|
+
* Tries each value in `[min_value, max_value]` (inclusive). Returns `null` (via `Option`) if no
|
|
281
|
+
* candidate matches. Uses an on-the-fly value lookup — there is no precomputed table dependency, so
|
|
282
|
+
* callers should keep the range tight (large ranges produce proportional CPU cost).
|
|
283
|
+
*
|
|
284
|
+
* `commitment` is the Pedersen commitment the proof is bound to. Both the view public key and the
|
|
285
|
+
* view secret key are required: the public key is used to re-verify the ZK proof (rejecting tampered
|
|
286
|
+
* proofs before decrypting), the secret key performs the ElGamal decryption itself.
|
|
287
|
+
*/
|
|
288
|
+
export function decryptElgamalViewableBalance(proof_json: string, commitment: Uint8Array, view_public_key: Uint8Array, view_secret_key: Uint8Array, min_value: bigint, max_value: bigint): bigint | undefined;
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Derive the AEAD encryption key for `encrypted_data` from a Diffie-Hellman shared secret: `H(DH(s, P))`.
|
|
292
|
+
* Sender derives it with `(sender_secret_nonce, recipient_view_pub)`; receiver derives the same key
|
|
293
|
+
* with `(recipient_view_secret, sender_public_nonce)`.
|
|
294
|
+
*/
|
|
295
|
+
export function encryptedDataDhKdfAead(private_key: Uint8Array, public_key: Uint8Array): Uint8Array;
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Generate an ElGamal viewable-balance proof: a zero-knowledge proof that `amount` is the value bound
|
|
299
|
+
* by `commitment`, encrypted to the resource view-key holder.
|
|
300
|
+
*
|
|
301
|
+
* Returns the JSON-encoded `ViewableBalanceProof` (8 × 32-byte fields).
|
|
302
|
+
*/
|
|
303
|
+
export function generateElgamalViewableBalanceProof(mask: Uint8Array, amount: bigint, commitment: Uint8Array, view_public_key: Uint8Array): string;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Generate an extended bulletproof aggregating range proofs for a set of output witnesses, proving
|
|
307
|
+
* each amount is in `[minimum_value_promise, 2^64)`. The number of witnesses is padded to the next
|
|
308
|
+
* power of two internally.
|
|
309
|
+
*
|
|
310
|
+
* `witnesses_json` is a JSON array of "flat" output witnesses (the `witness` field shape from
|
|
311
|
+
* [`generate_stealth_outputs_statement`] — without the surrounding `auth` / `tag`).
|
|
312
|
+
*
|
|
313
|
+
* Returns the raw range proof bytes (may be empty if the input array is empty).
|
|
314
|
+
*/
|
|
315
|
+
export function generateExtendedBulletProof(witnesses_json: string): Uint8Array;
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Generate a new random Ristretto keypair.
|
|
319
|
+
* Returns { secret_key: Uint8Array, public_key: Uint8Array }.
|
|
320
|
+
*/
|
|
321
|
+
export function generateKeypair(): KeypairResult;
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Generate an Ootle address (bech32m string) from public keys.
|
|
325
|
+
*
|
|
326
|
+
* `network` is the network byte (0x00 = MainNet, 0x10 = LocalNet, 0x26 = Esmeralda, etc.).
|
|
327
|
+
* `memo` is an optional pay reference (max 64 bytes).
|
|
328
|
+
*/
|
|
329
|
+
export function generateOotleAddress(owner_public_key: Uint8Array, view_public_key: Uint8Array, network: number, memo?: Uint8Array | null): string;
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Generate a new random pair of Ootle secret keys (owner + view).
|
|
333
|
+
* Returns { owner_key: Uint8Array, view_key: Uint8Array }.
|
|
334
|
+
*/
|
|
335
|
+
export function generateOotleSecretKey(): OotleSecretKey;
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Sign the balance proof for a stealth transfer.
|
|
339
|
+
*
|
|
340
|
+
* `aggregated_input_mask` and `aggregated_output_mask` are the 32-byte sums of all input / output
|
|
341
|
+
* commitment masks respectively. Returns a `(public_nonce, signature)` pair (each 32 bytes); the pair
|
|
342
|
+
* may be all-zeros for revealed-only transfers — callers normally omit the balance proof in that case.
|
|
343
|
+
*/
|
|
344
|
+
export function generateStealthBalanceProofSignature(aggregated_input_mask: Uint8Array, aggregated_output_mask: Uint8Array, inputs_statement_json: string, outputs_statement_json: string): SchnorrSignatureResult;
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Generate the output side of a stealth transfer: per-output Pedersen commitments and encrypted data,
|
|
348
|
+
* optional ElGamal viewable-balance proofs (for outputs with a `resource_view_key`), and an aggregated
|
|
349
|
+
* bulletproof range proof.
|
|
350
|
+
*
|
|
351
|
+
* `witnesses_json` is a JSON array of stealth output witnesses. Each entry has the shape:
|
|
352
|
+
* ```text
|
|
353
|
+
* {
|
|
354
|
+
* "witness": {
|
|
355
|
+
* "amount": <u64>,
|
|
356
|
+
* "mask": <hex 32 bytes>,
|
|
357
|
+
* "sender_public_nonce": <hex 32 bytes>,
|
|
358
|
+
* "minimum_value_promise": <u64>,
|
|
359
|
+
* "encrypted_data": <hex variable-length>,
|
|
360
|
+
* "resource_view_key": <hex 32 bytes | null>
|
|
361
|
+
* },
|
|
362
|
+
* "auth": <SpendAuthorization>,
|
|
363
|
+
* "tag": <u32>
|
|
364
|
+
* }
|
|
365
|
+
* ```
|
|
366
|
+
*
|
|
367
|
+
* Returns the serialized statement plus the aggregated output mask, which the sender feeds to
|
|
368
|
+
* `generateStealthBalanceProofSignature` together with the aggregated input mask.
|
|
369
|
+
*/
|
|
370
|
+
export function generateStealthOutputsStatement(witnesses_json: string, revealed_output_amount_microtari: bigint): StealthOutputsResult;
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Hash an UnsignedTransactionV1 (JSON string) for signing.
|
|
374
|
+
* Returns the 64-byte signing message that must be Schnorr-signed.
|
|
375
|
+
*
|
|
376
|
+
* `seal_signer_public_key` is the raw bytes of the seal signer's public key (account owner).
|
|
377
|
+
*/
|
|
378
|
+
export function hashUnsignedTransaction(unsigned_tx_json: string, seal_signer_public_key: Uint8Array): Uint8Array;
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Called automatically when the WASM module is instantiated. Do not call directly.
|
|
382
|
+
*/
|
|
383
|
+
export function on_start(): void;
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Derive the Ootle public keys from a pair of secret keys.
|
|
387
|
+
* Returns { owner_key: Uint8Array, view_key: Uint8Array }.
|
|
388
|
+
*/
|
|
389
|
+
export function ootlePublicKeyFromSecretKey(owner_key: Uint8Array, view_key: Uint8Array): OotlePublicKey;
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Parse a bech32m Ootle address string into its components.
|
|
393
|
+
* Returns { owner_key: Uint8Array, view_key: Uint8Array, network: number, memo: Uint8Array | undefined }.
|
|
394
|
+
*/
|
|
395
|
+
export function parseOotleAddress(address: string): ParsedOotleAddress;
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Derive the public key from a secret key (both raw bytes).
|
|
399
|
+
*/
|
|
400
|
+
export function publicKeyFromSecretKey(secret_key: Uint8Array): Uint8Array;
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Schnorr-sign a message with a secret key.
|
|
404
|
+
* Returns { public_nonce: Uint8Array, signature: Uint8Array }.
|
|
405
|
+
*/
|
|
406
|
+
export function schnorrSign(secret_key: Uint8Array, message: Uint8Array): SchnorrSignatureResult;
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Seal a transaction (unsigned or unsealed JSON) with the seal signer's secret key.
|
|
410
|
+
*
|
|
411
|
+
* Accepts either an `UnsignedTransactionV1` or `UnsealedTransactionV1` JSON string.
|
|
412
|
+
* Returns the sealed `Transaction` as a JSON string.
|
|
413
|
+
*/
|
|
414
|
+
export function sealTransaction(tx_json: string, seal_signer_secret_key: Uint8Array): string;
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Derive the recipient's stealth spending scalar `c + k`, where `c = H(network || k.G * r)`. The
|
|
418
|
+
* receiver runs this with their account secret key (`private_key`) and the sender-provided public
|
|
419
|
+
* nonce to obtain the one-time secret that controls the stealth output.
|
|
420
|
+
*
|
|
421
|
+
* `network` is the network byte (0x00 = MainNet, 0x10 = LocalNet, 0x26 = Esmeralda, ...).
|
|
422
|
+
*/
|
|
423
|
+
export function stealthDhSecret(network: number, private_key: Uint8Array, public_nonce: Uint8Array): Uint8Array;
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Decrypt and verify the AEAD payload of an inbound stealth UTXO.
|
|
427
|
+
*
|
|
428
|
+
* `output_commitment` is the 32-byte Pedersen commitment; `encrypted_data` is the variable-length
|
|
429
|
+
* XChaCha20Poly1305-encrypted blob; `encryption_key` is the 32-byte AEAD key derived via
|
|
430
|
+
* `encryptedDataDhKdfAead`. Setting `skip_memo` to `true` returns no memo even if the payload carries
|
|
431
|
+
* one (useful when only the value / mask are needed).
|
|
432
|
+
*
|
|
433
|
+
* Throws on AEAD failure or on a commitment mismatch — either indicates the payload was not produced
|
|
434
|
+
* for this view key.
|
|
435
|
+
*/
|
|
436
|
+
export function unblindOutput(output_commitment: Uint8Array, encrypted_data: Uint8Array, encryption_key: Uint8Array, skip_memo: boolean): DecryptedOutputResult;
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Pre-flight check that a balance proof signature is cryptographically valid for the given input /
|
|
440
|
+
* output statements. Returns `false` on a malformed proof or invalid signature; the engine performs
|
|
441
|
+
* the authoritative check at submission.
|
|
442
|
+
*/
|
|
443
|
+
export function validateBalanceProofSignature(public_nonce: Uint8Array, signature: Uint8Array, inputs_statement_json: string, outputs_statement_json: string): boolean;
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Run the same validation the engine performs on a complete `StealthTransferStatement` envelope:
|
|
447
|
+
* structural sanity, commitment well-formedness, range and balance-proof verification.
|
|
448
|
+
*
|
|
449
|
+
* `view_key` is the 32-byte resource view public key, required for resources with a viewable balance
|
|
450
|
+
* and rejected otherwise. Pass `null` for resources without a view key.
|
|
451
|
+
*
|
|
452
|
+
* Throws on a validation failure; returns successfully on a valid statement.
|
|
453
|
+
*/
|
|
454
|
+
export function validateStealthTransfer(transfer_json: string, view_key?: Uint8Array | null): void;
|
|
@@ -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
|
+
DecryptedOutputResult, KeypairResult, OotlePublicKey, OotleSecretKey, ParsedOotleAddress, SchnorrSignatureResult, StealthOutputsResult, addTransactionSigner, aggregateInputMasks, borEncodeTransaction, buildScriptPathWitness, buildStealthInputsStatement, buildStealthInputsStatementFromInputs, buildStealthTransferStatement, createConfidentialWithdrawProofLiteral, createStealthOutputWitness, decryptElgamalViewableBalance, encryptedDataDhKdfAead, generateElgamalViewableBalanceProof, generateExtendedBulletProof, generateKeypair, generateOotleAddress, generateOotleSecretKey, generateStealthBalanceProofSignature, generateStealthOutputsStatement, hashUnsignedTransaction, on_start, ootlePublicKeyFromSecretKey, parseOotleAddress, publicKeyFromSecretKey, schnorrSign, sealTransaction, stealthDhSecret, unblindOutput, validateBalanceProofSignature, validateStealthTransfer
|
|
9
|
+
} from "./ootle_wasm_bg.js";
|