@cloak.dev/sdk 0.1.6 → 0.1.8
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 +96 -183
- package/dist/index.cjs +2290 -289
- package/dist/index.d.cts +1503 -434
- package/dist/index.d.ts +1503 -434
- package/dist/index.js +2200 -250
- package/package.json +1 -2
- package/CHANGELOG.md +0 -173
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloak.dev/sdk",
|
|
3
3
|
"description": "Shield, send, and swap on Solana privately — TypeScript SDK with UTXO-based zero-knowledge transactions",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.8",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -103,7 +103,6 @@
|
|
|
103
103
|
"files": [
|
|
104
104
|
"dist",
|
|
105
105
|
"README.md",
|
|
106
|
-
"CHANGELOG.md",
|
|
107
106
|
"LICENSE"
|
|
108
107
|
],
|
|
109
108
|
"publishConfig": {
|
package/CHANGELOG.md
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to `@cloak.dev/sdk` are documented here. The format
|
|
4
|
-
follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the
|
|
5
|
-
project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
-
|
|
7
|
-
## [0.1.6] — 2026-04-27
|
|
8
|
-
|
|
9
|
-
### Removed (BREAKING)
|
|
10
|
-
|
|
11
|
-
- **`CloakSDK.deposit / privateTransfer / withdraw / send / swap`** —
|
|
12
|
-
these methods built a legacy `[discriminator: 1, amount: u64,
|
|
13
|
-
commitment: 32]` deposit instruction. The deployed shield-pool program
|
|
14
|
-
has repurposed discriminator `1` to `TransactSwap` (which requires
|
|
15
|
-
`>= 8` accounts), so every external invocation hit `0x1063
|
|
16
|
-
MissingAccounts` at ~112 CU. Reported by the cloak-squads hackathon
|
|
17
|
-
team on 2026-04-26.
|
|
18
|
-
- **`createDepositInstruction` / `validateDepositParams` /
|
|
19
|
-
`DepositInstructionParams`** — the disc-1 instruction builder and its
|
|
20
|
-
validators.
|
|
21
|
-
- **`CloakNote` model and helpers** — `generateNote`, `parseNote`,
|
|
22
|
-
`exportNote`, `findNoteByCommitment`, `filterNotesByNetwork`,
|
|
23
|
-
`filterWithdrawableNotes`, `isWithdrawable`, `updateNoteWithDeposit`,
|
|
24
|
-
`getRecipientAmount`, `generateNoteFromWallet`. The OLD
|
|
25
|
-
`withdraw_regular.circom` model used a 3-input
|
|
26
|
-
`Poseidon(amount, r0, r1, pk_spend)` commitment that is incompatible
|
|
27
|
-
with the deployed `transaction.circom` UTXO circuit (4-input
|
|
28
|
-
`Poseidon(amount, pubkey, blinding, mintAddress)`).
|
|
29
|
-
- **`CloakSDK.loadNotes / saveNote / findNote / getTransactionMetadata`**
|
|
30
|
-
and the `StorageAdapter.notes*` methods. The adapter is now keys-only.
|
|
31
|
-
- **Encrypted-note helpers** — `prepareEncryptedOutput`,
|
|
32
|
-
`prepareEncryptedOutputForRecipient`, `encodeNoteSimple` (legacy
|
|
33
|
-
`CloakNote`-based variants).
|
|
34
|
-
- **Pending-operations helpers** — `savePendingDeposit`/`Withdrawal`
|
|
35
|
-
and friends, plus `PendingDeposit` / `PendingWithdrawal` types.
|
|
36
|
-
- **Legacy proof generation** — `src/utils/proof-generation.ts`
|
|
37
|
-
(`generateWithdrawRegularProof`, `generateWithdrawSwapProof`,
|
|
38
|
-
`verifyCircuitIntegrity`, `verifyAllCircuits`,
|
|
39
|
-
`areCircuitsAvailable`, `getDefaultCircuitsPath`,
|
|
40
|
-
`EXPECTED_CIRCUIT_HASHES`, `DEFAULT_CIRCUITS_URL`).
|
|
41
|
-
- **Legacy bigint hash helpers** in `src/utils/crypto.ts` —
|
|
42
|
-
`computeCommitment` (3-arg), `generateCommitmentAsync`,
|
|
43
|
-
`computeNullifier{,Async,Sync}`, `computeOutputsHash{,Async,Sync,FromLimbs}`,
|
|
44
|
-
`computeSwapOutputsHash{,Async,Sync}`. The UTXO-model
|
|
45
|
-
`computeCommitment(utxo)` / `computeNullifier(utxo)` live in
|
|
46
|
-
`core/utxo` and are re-exported as `computeUtxoCommitment` /
|
|
47
|
-
`computeUtxoNullifier`.
|
|
48
|
-
- **OLD types** in `src/core/types.ts` — `CloakNote`, `Transfer`,
|
|
49
|
-
`MaxLengthArray`, `TransferResult`, `DepositResult`, `DepositOptions`,
|
|
50
|
-
`TransferOptions`, `WithdrawOptions`, `DepositStatus`, `SwapOptions`,
|
|
51
|
-
`SwapParams`, `SwapResult`. Plus `proofTimeout` (was unused on the
|
|
52
|
-
snapshot).
|
|
53
|
-
- **`withdraw_regular_final.zkey`** — the ~10 MB legacy circuit asset.
|
|
54
|
-
|
|
55
|
-
### Changed (BREAKING)
|
|
56
|
-
|
|
57
|
-
- **`CloakConfig` is now a snapshot-only type.** It is the structurally
|
|
58
|
-
narrow value returned by `CloakSDK.getConfig()`: exactly seven
|
|
59
|
-
fields — `network`, `cloakKeys`, `programId`, `poolAddress`,
|
|
60
|
-
`merkleTreeAddress`, `treasuryAddress`, `debug`. The constructor
|
|
61
|
-
input is the new exported `CloakSDKOptions` interface (which still
|
|
62
|
-
accepts `keypairBytes`, `wallet`, and `storage` — they are consumed
|
|
63
|
-
into private SDK state and are *never* persisted on the snapshot).
|
|
64
|
-
`sdk.getConfig().keypairBytes` is now a `TS2339` compile-time error.
|
|
65
|
-
- `CloakConfig.cloakKeys` is now typed as `CloakKeyPair | undefined`
|
|
66
|
-
(was `any`).
|
|
67
|
-
- `LocalStorageAdapter` constructor signature is `(keysKey?: string)`;
|
|
68
|
-
the second `notesKey` parameter is gone.
|
|
69
|
-
- `CloakSDK` constructor now throws `CloakError(_, "validation", false)`
|
|
70
|
-
instead of plain `Error` when no signer is provided; `getPublicKey()`
|
|
71
|
-
throws `CloakError(_, "wallet", false)` when neither keypair nor
|
|
72
|
-
wallet adapter is configured. Consumers' `parseError()` /
|
|
73
|
-
`classifyRelayError()` flows now handle these uniformly.
|
|
74
|
-
|
|
75
|
-
### Added
|
|
76
|
-
|
|
77
|
-
- **`LocalStorageAdapter` auto-purges legacy plaintext secrets.** On
|
|
78
|
-
the first construction in any browser origin, the adapter removes the
|
|
79
|
-
pre-0.1.6 `cloak_notes` localStorage entry (which contained `r`
|
|
80
|
-
randomness and `sk_spend` hex in plaintext) and writes a sentinel at
|
|
81
|
-
`cloak_purged_v0_1_5` so subsequent constructions skip the work.
|
|
82
|
-
Closes the upgrade-time security gap without requiring consumers to
|
|
83
|
-
call any helper. Consumers using a non-default legacy key can still
|
|
84
|
-
call `LocalStorageAdapter.purgeLegacyNoteStorage(customKey)`
|
|
85
|
-
explicitly.
|
|
86
|
-
- `LocalStorageAdapter.LEGACY_PURGE_SENTINEL_KEY` and
|
|
87
|
-
`LocalStorageAdapter.LEGACY_NOTES_KEY` static constants for callers
|
|
88
|
-
that want to inspect / reset the purge state.
|
|
89
|
-
- `LocalStorageAdapter.runLegacyPurgeOnce()` static helper for callers
|
|
90
|
-
that want to force the auto-purge before the first adapter
|
|
91
|
-
instantiation (e.g. during an upgrade boot sequence).
|
|
92
|
-
|
|
93
|
-
### Security
|
|
94
|
-
|
|
95
|
-
- `getConfig()` no longer leaks `keypairBytes`. The constructor
|
|
96
|
-
consumed the secret bytes into a `Keypair` and used to spread the
|
|
97
|
-
whole input onto `this.config`; `getConfig()`'s shallow-copy return
|
|
98
|
-
exposed the original `Uint8Array` by reference. `this.config` is now
|
|
99
|
-
built explicitly without `keypairBytes`/`wallet`/`storage`, and the
|
|
100
|
-
type system enforces the asymmetry (see "Changed" above).
|
|
101
|
-
- `LocalStorageAdapter` upgrade-time auto-purge (see "Added") removes
|
|
102
|
-
the now-unredeemable plaintext secrets that pre-0.1.6 versions left
|
|
103
|
-
in browser localStorage.
|
|
104
|
-
|
|
105
|
-
### Migration guide
|
|
106
|
-
|
|
107
|
-
The supported flow for transaction emission is the functional UTXO API.
|
|
108
|
-
|
|
109
|
-
```ts
|
|
110
|
-
import {
|
|
111
|
-
transact,
|
|
112
|
-
fullWithdraw,
|
|
113
|
-
partialWithdraw,
|
|
114
|
-
transfer,
|
|
115
|
-
swapUtxo,
|
|
116
|
-
createUtxo,
|
|
117
|
-
createZeroUtxo,
|
|
118
|
-
generateUtxoKeypair,
|
|
119
|
-
CLOAK_PROGRAM_ID,
|
|
120
|
-
NATIVE_SOL_MINT,
|
|
121
|
-
} from "@cloak.dev/sdk";
|
|
122
|
-
import { Connection, Keypair } from "@solana/web3.js";
|
|
123
|
-
|
|
124
|
-
const connection = new Connection("https://api.mainnet-beta.solana.com");
|
|
125
|
-
const signer = Keypair.fromSecretKey(/* ... */);
|
|
126
|
-
|
|
127
|
-
// Deposit (positive externalAmount).
|
|
128
|
-
const owner = await generateUtxoKeypair();
|
|
129
|
-
const output = await createUtxo(10_000_000n, owner, NATIVE_SOL_MINT);
|
|
130
|
-
const deposited = await transact(
|
|
131
|
-
{
|
|
132
|
-
inputUtxos: [
|
|
133
|
-
await createZeroUtxo(NATIVE_SOL_MINT),
|
|
134
|
-
await createZeroUtxo(NATIVE_SOL_MINT),
|
|
135
|
-
],
|
|
136
|
-
outputUtxos: [output, await createZeroUtxo(NATIVE_SOL_MINT)],
|
|
137
|
-
externalAmount: 10_000_000n,
|
|
138
|
-
depositor: signer.publicKey,
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
connection,
|
|
142
|
-
programId: CLOAK_PROGRAM_ID,
|
|
143
|
-
relayUrl: "https://api.cloak.ag",
|
|
144
|
-
depositorKeypair: signer,
|
|
145
|
-
},
|
|
146
|
-
);
|
|
147
|
-
|
|
148
|
-
// Reclaim to a public address.
|
|
149
|
-
await fullWithdraw(deposited.outputUtxos, signer.publicKey, {
|
|
150
|
-
connection,
|
|
151
|
-
programId: CLOAK_PROGRAM_ID,
|
|
152
|
-
relayUrl: "https://api.cloak.ag",
|
|
153
|
-
depositorKeypair: signer,
|
|
154
|
-
cachedMerkleTree: deposited.merkleTree,
|
|
155
|
-
});
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
The `CloakSDK` class is retained as a thin config + read-only helper
|
|
159
|
-
(`getPublicKey`, `getCurrentRoot`, `getMerkleProof`,
|
|
160
|
-
`getTransactionStatus`, `importWalletKeys`, `exportWalletKeys`,
|
|
161
|
-
`getConfig`). Construction is unchanged for new fields.
|
|
162
|
-
|
|
163
|
-
### Verification
|
|
164
|
-
|
|
165
|
-
- Mainnet end-to-end smoke (deposit + withdraw cycle) on the patched
|
|
166
|
-
SDK: deposit signature
|
|
167
|
-
`5iGmrMYoSucYJ5PzEo5BCWioqTof4KNfjowq14ZYrbQACicaP2tJdJfRUy2CctsQLyNu6xpYXn8gYBg3EefsmXrv`
|
|
168
|
-
(slot 416038846, leaf 318); withdraw signature
|
|
169
|
-
`37A4T1KNiZLkmRvLAtui5ZN2VCmzjsZMzzGNwMosFA2UM1NGn7kP28p5APTvKRb51rNaLmWF42TJqK9GSZM5xCxn`
|
|
170
|
-
(slot 416055377). Net delta on the test wallet matches the expected
|
|
171
|
-
fee schedule (0.005 fixed + 0.3% var).
|
|
172
|
-
|
|
173
|
-
[0.1.6]: https://github.com/cloak-ag/sdk/pull/11
|