@tokamak-private-dapps/private-state-cli 0.1.8 → 1.0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,90 @@
1
1
  # Changelog
2
2
 
3
+ ## Unreleased
4
+
5
+ - Changed the channel-bound L2 identity derivation signing domain and mode from password wording
6
+ to wallet-secret wording. Existing local wallets from the pre-1.0.0 cleanup path are not
7
+ compatibility targets.
8
+ - Centralized CLI command option schemas used by validation, while keeping the existing command
9
+ implementations in the single CLI entrypoint.
10
+ - Moved private-state Tokamak L2 snapshot, storage, and leaf-index helpers into a shared CLI library
11
+ reused by the CLI and registration materialization scripts.
12
+ - Moved runtime install, artifact install, and doctor report helpers out of the CLI entrypoint.
13
+ - Reused the same command registry for CLI help text and the browser command assistant so command
14
+ additions no longer require three separate hardcoded updates.
15
+ - Made live Docker/NVIDIA GPU probing in `doctor` opt-in through `doctor --gpu`; the default doctor
16
+ run now reports runtime metadata without launching GPU containers.
17
+ - Shared private-state registration fixture builders between DApp registration materialization and
18
+ the CLI end-to-end scenario.
19
+ - Moved note receive key derivation and note value encryption/decryption into a CLI library helper
20
+ reused by the CLI, DApp registration materializer, and CLI end-to-end scenario.
21
+ - Removed the CLI end-to-end runner's trailing-JSON fallback now that CLI progress logs are kept off
22
+ stdout in `--json` mode.
23
+ - Required public-network private-state DApp deployment scripts to receive an explicit `--rpc-url`
24
+ instead of deriving deployment RPC endpoints from environment-only Alchemy settings.
25
+ - Replaced local wallet recovery hint string matching with typed CLI error codes for local RPC,
26
+ wallet, artifact, registration, and stale-workspace failures.
27
+ - Removed unused replay/synthetic snapshot helpers from the CLI end-to-end script.
28
+ - Added deterministic anvil account and wallet secret cleanup to the CLI end-to-end runner so
29
+ repeated local runs do not fail on stale canonical secret files.
30
+ - Stopped parsing the `install --include-local-artifacts` end-to-end step as JSON because runtime
31
+ package installation legitimately writes installer logs to stdout.
32
+ - Reused a shared artifact selection helper for Drive and local private-state artifact installs.
33
+ - Removed stale `--install` and `--doctor` compatibility aliases after the command syntax was
34
+ standardized around positional command names.
35
+ - Tightened local wallet loading to require the current wallet format instead of silently filling
36
+ legacy defaults.
37
+ - Renamed stale internal wallet-secret terminology consistently around wallet secrets and moved the
38
+ canonical wallet secret path from `password` to `secret`.
39
+ - Reused private-state CLI shared helpers in the CLI end-to-end test instead of duplicating channel
40
+ ID, wallet path, and L2 identity derivation logic.
41
+ - Fixed the browser CLI assistant's `create-channel` builder to include required `--join-toll`.
42
+ - Preserved the resolved network name in CLI runtime contexts so account-backed commands and
43
+ wallet-backed commands can pass the correct network selector into downstream recovery helpers.
44
+ - Routed Groth16 prover package root, entrypoint, and proof-manifest path resolution through
45
+ runtime management instead of leaving the CLI entrypoint to call internal runtime helper names.
46
+ - Routed Tokamak CLI invocation resolution through runtime management instead of calling internal
47
+ runtime helper names from the CLI entrypoint.
48
+ - Kept Groth16 prover stdout quiet during `--json` proof-backed commands so machine-readable output
49
+ remains valid JSON.
50
+ - Verified the full private-state CLI end-to-end flow through channel exit and bridge withdrawal
51
+ after the runtime-management refactor.
52
+
53
+ ## 1.0.0 - 2026-05-04
54
+
55
+ - Stabilized the private-state CLI command contract for the first mainnet-ready release.
56
+ - Removed routine raw `--private-key` and `--password` command arguments.
57
+ - Added named local L1 account management through `account import --private-key-file`, with later
58
+ signing commands using `--account`.
59
+ - Moved wallet commands to wallet-local canonical secret files instead of explicit password input.
60
+ - Added the wallet secret source-file flow for `join-channel --wallet-secret-path <PATH>`.
61
+ - Removed `join-channel --random-wallet-secret`; channel joins now always require
62
+ `--wallet-secret-path <PATH>`.
63
+ - Relaxed imported source secret file permission checks while keeping canonical CLI secrets
64
+ protected with POSIX `0600` or Windows ACL repair and inspection.
65
+ - Added per-network RPC URL persistence under the private-state workspace, with `--rpc-url` as
66
+ the optional bridge-facing override.
67
+ - Renamed private-state CLI commands `--install` and `--doctor` to `install` and `doctor` so
68
+ commands consistently omit a leading `--`.
69
+ - Replaced the old zk-EVM-only uninstall command with interactive `uninstall`, which removes local
70
+ private-state data, Tokamak zk-EVM runtime data, and the global CLI package when installed.
71
+ - Added `guide` as the state-aware workflow assistant command.
72
+ - Added `get-channel` for channel policy, toll, refund schedule, and immutable policy snapshot
73
+ inspection.
74
+ - Added CLI-wide `--json`; commands print human-readable output by default and structured output
75
+ when requested.
76
+ - Made `doctor` human-readable by default while preserving full machine-readable diagnostics through
77
+ `doctor --json`.
78
+ - Added durable progress phases for proof-backed commands: `loading`, `proving`, `submitting`,
79
+ `persisting`, and `done`.
80
+ - Added centralized recovery hints for common RPC, artifact, account, wallet, channel selector,
81
+ registration, and local-state errors.
82
+
83
+ ## 0.1.9 - 2026-05-03
84
+
85
+ - Used the bundled Groth16 package version as the default `private-state-cli --install` Groth16 runtime version.
86
+ - Treated stale local Groth16 CRS metadata without `compatibleBackendVersion` as a cache miss so the matching public CRS can be reinstalled.
87
+
3
88
  ## 0.1.8 - 2026-04-30
4
89
 
5
90
  - Reused common proof backend version helpers for Tokamak and Groth16 compatibility checks.
package/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  Command-line client for the Tokamak private-state DApp.
4
4
 
5
+ The full private-state DApp documentation is published with the repository:
6
+
7
+ - https://github.com/tokamak-network/Tokamak-zk-EVM-contracts/tree/main/packages/apps/private-state/docs
8
+
5
9
  ## Install
6
10
 
7
11
  ```bash
@@ -12,14 +16,15 @@ Install the local Tokamak zk-EVM runtime workspace, Groth16 runtime workspace, a
12
16
  artifacts:
13
17
 
14
18
  ```bash
15
- private-state-cli --install
19
+ private-state-cli install
16
20
  ```
17
21
 
18
- By default, `--install` resolves the latest `@tokamak-zk-evm/cli` and `@tokamak-private-dapps/groth16` versions from
19
- the npm registry. To pin exact proof backend versions for a channel, pass explicit versions:
22
+ By default, `install` resolves the latest `@tokamak-zk-evm/cli` from the npm registry and uses the bundled
23
+ `@tokamak-private-dapps/groth16` dependency version selected by the installed private-state CLI package. To pin exact
24
+ proof backend versions for a channel, pass explicit versions:
20
25
 
21
26
  ```bash
22
- private-state-cli --install --tokamak-zk-evm-cli-version 2.0.8 --groth16-cli-version 0.1.1
27
+ private-state-cli install --tokamak-zk-evm-cli-version 2.1.0 --groth16-cli-version 0.2.0
23
28
  ```
24
29
 
25
30
  The Groth16 installer downloads the public Google Drive CRS archive whose major.minor compatibility version matches the
@@ -27,11 +32,11 @@ selected Groth16 CLI package version.
27
32
  The Tokamak zk-EVM installer requires the selected CLI package to declare
28
33
  `tokamakZkEvm.compatibleBackendVersion` as a canonical major.minor version matching the selected package version.
29
34
 
30
- `--install` downloads public deployment artifacts from the configured artifact index. It does not read repository-local
35
+ `install` downloads public deployment artifacts from the configured artifact index. It does not read repository-local
31
36
  `deployment/` outputs by default. Repository development workflows that need local anvil artifacts can opt in explicitly:
32
37
 
33
38
  ```bash
34
- private-state-cli --install --include-local-artifacts
39
+ private-state-cli install --include-local-artifacts
35
40
  ```
36
41
 
37
42
  Run the CLI with:
@@ -43,9 +48,20 @@ private-state-cli <command> ...
43
48
  Check the installed package and runtime state with:
44
49
 
45
50
  ```bash
46
- private-state-cli --doctor
51
+ private-state-cli doctor
52
+ ```
53
+
54
+ Remove all local private-state CLI data with:
55
+
56
+ ```bash
57
+ private-state-cli uninstall
47
58
  ```
48
59
 
60
+ `uninstall` is intentionally interactive. It requires typing
61
+ `I understand that the wallet secrets deleted due to this decision cannot be recovered` before deleting
62
+ `~/tokamak-private-channels/`, the Tokamak zk-EVM runtime cache, and the global CLI npm package when npm reports that it
63
+ is globally installed.
64
+
49
65
  ## Commands
50
66
 
51
67
  A common private-state flow is:
@@ -59,27 +75,62 @@ A common private-state flow is:
59
75
  7. `get-my-notes`
60
76
  8. `redeem-notes`
61
77
  9. `withdraw-channel`
62
- 10. `withdraw-bridge`
78
+ 10. `exit-channel`
79
+ 11. `withdraw-bridge`
63
80
 
64
81
  Use `private-state-cli --help` for the full command list and required options.
65
82
 
66
- `private-state-cli --doctor` reports the CLI package version, dependency versions recorded by the last
67
- `private-state-cli --install`, selected proof backend runtime versions, current dependency versions through `tokamak-l2js`, and Tokamak zk-EVM runtime
83
+ Channel policy warning:
84
+
85
+ - `create-channel` commits to an immutable channel policy: verifier bindings, DApp execution metadata, function layout,
86
+ managed storage vector, and refund policy are fixed for that channel.
87
+ - `join-channel` means the user accepts the channel's current policy. Later policy-level fixes require a new channel or
88
+ migration; the existing channel is intentionally not mutated in place without renewed user consent.
89
+ - Before sending a channel-creation transaction or a first channel-registration transaction, the CLI prints the policy
90
+ snapshot that will be accepted: DApp metadata digest, digest schema, Groth16 verifier address, Groth16 compatible
91
+ backend version, Tokamak verifier address, and Tokamak compatible backend version.
92
+ - Users and operators must review this snapshot before signing. If any digest, schema, verifier address, or compatible
93
+ backend version is unexpected or has not been reviewed, do not create or join the channel. A later correction creates
94
+ a new channel; it does not rewrite the policy of an already-created channel.
95
+
96
+ `private-state-cli doctor` reports the CLI package version, dependency versions recorded by the last
97
+ `private-state-cli install`, selected proof backend runtime versions, current dependency versions through `tokamak-l2js`, and Tokamak zk-EVM runtime
68
98
  install mode, Docker mode, CUDA runtime metadata, live `nvidia-smi` and Docker GPU probe results, and Groth16
69
99
  runtime health. The doctor check fails when the Tokamak Docker `useGpus` metadata does not match the live GPU probes.
70
100
 
71
101
  Local helper commands:
72
102
 
73
103
  ```bash
104
+ private-state-cli account import --account <ACCOUNT_NAME> --network sepolia --private-key-file <PATH>
74
105
  private-state-cli list-local-wallets --network sepolia --channel-name cuda
75
- private-state-cli get-my-wallet-meta --wallet <WALLET_NAME> --password <PASSWORD> --network sepolia
76
- private-state-cli get-my-l1-address --private-key <HEX>
106
+ private-state-cli get-my-wallet-meta --wallet <WALLET_NAME> --network sepolia
107
+ private-state-cli get-my-l1-address --account <ACCOUNT_NAME> --network sepolia
77
108
  ```
78
109
 
79
- `list-local-wallets` reads only the local workspace and prints saved wallet names that can be reused with `--wallet`.
110
+ `account import` is the only supported way to bring an L1 signing key into the CLI: it reads `--private-key-file` once
111
+ and stores a protected local account secret for later `--account` use. The source file does not need `0600` permissions.
112
+ `join-channel` imports `--wallet-secret-path <PATH>` into the protected wallet-local default secret while creating the
113
+ encrypted local wallet. `list-local-wallets` reads only the local workspace and prints saved wallet names that can be reused with
114
+ `--wallet`.
80
115
  `get-my-wallet-meta` opens an encrypted local wallet and reports the stored L1/L2 identity metadata plus the current
81
116
  on-chain channel registration match state. `get-my-l1-address` is a simple offline helper that derives the L1 address
82
- for a private key.
117
+ for a local account.
118
+
119
+ ### Wallet Secret Source File
120
+
121
+ `join-channel` needs a wallet secret source file because the CLI no longer accepts raw wallet secrets on the command
122
+ line. The source file is arbitrary high-entropy secret text that the CLI reads once and imports into the protected
123
+ wallet-local canonical secret.
124
+
125
+ Create one before joining a channel:
126
+
127
+ ```bash
128
+ openssl rand -hex 32 > ./wallet-secret.txt
129
+ private-state-cli join-channel --channel-name <CHANNEL> --network sepolia --account <ACCOUNT> --wallet-secret-path ./wallet-secret.txt
130
+ ```
131
+
132
+ The import source file does not need `0600` permissions. The canonical wallet-local secret written by the CLI remains
133
+ protected: macOS/Linux uses `0600`, while Windows uses ACL repair and inspection when possible.
83
134
 
84
135
  ## Workspace
85
136
 
@@ -89,7 +140,14 @@ The CLI stores user workspaces under:
89
140
  ~/tokamak-private-channels/workspace/<network>/<channel>/
90
141
  ```
91
142
 
92
- Wallet data is encrypted with the password supplied to `join-channel` or `recover-wallet`.
143
+ Wallet data is encrypted with the wallet-local default secret file under
144
+ `~/tokamak-private-channels/secrets/<network>/wallets/<wallet>/secret`.
145
+
146
+ Bridge-facing commands accept optional `--rpc-url <URL>`. When `--rpc-url` is provided, the CLI stores it in
147
+ `~/tokamak-private-channels/secrets/<network>/.env` as `RPC_URL=<URL>` with protected canonical secret permissions.
148
+ When `--rpc-url` is omitted, the CLI reads `RPC_URL` from that file. The `anvil` network falls back to
149
+ `http://127.0.0.1:8545` when no saved RPC URL exists. Canonical CLI secrets are checked on read: macOS/Linux uses
150
+ `0600`, while Windows uses ACL repair and inspection when possible.
93
151
 
94
152
  ## LLM Agent Guidance
95
153
 
@@ -102,21 +160,24 @@ explaining each step only as much as needed to proceed safely.
102
160
 
103
161
  Operating rules:
104
162
 
105
- - Do not ask the user to reveal raw private keys in chat. Use environment variable placeholders such as `$ADDR6`,
106
- `$CREATOR`, or `$PRIVATE_STATE_TEST_PK`.
163
+ - Do not ask the user to reveal raw private keys or wallet secrets in chat. Use `account import --private-key-file`
164
+ once, then use `--account` for L1 signing commands. Wallet commands use wallet-local default secret files.
107
165
  - Prefer testnet examples unless the user explicitly asks for mainnet.
108
- - Before any proof-backed or bridge-facing workflow, ask the user to run `private-state-cli --doctor` and inspect
166
+ - Before any proof-backed or bridge-facing workflow, ask the user to run `private-state-cli doctor` and inspect
109
167
  whether the runtime, Docker mode, CUDA/GPU probes, Groth16 runtime, and deployment artifacts are healthy.
110
168
  - Use `private-state-cli list-local-wallets` to discover local wallet names instead of asking the user to inspect
111
169
  filesystem paths manually.
112
- - Use `private-state-cli get-my-l1-address --private-key "$KEY_ENV"` to derive the L1 address for a private-key
113
- environment variable when wallet ownership needs to be identified.
114
- - Use `private-state-cli get-my-wallet-meta --wallet <WALLET> --password <PASSWORD> --network <NETWORK>` to inspect
170
+ - Use `private-state-cli get-my-l1-address --account <ACCOUNT> --network <NETWORK>` to derive the L1 address for a
171
+ local account when wallet ownership needs to be identified.
172
+ - Use `private-state-cli get-my-wallet-meta --wallet <WALLET> --network <NETWORK>` to inspect
115
173
  local wallet metadata and on-chain channel registration state.
116
174
  - Use `private-state-cli get-my-bridge-fund` and `private-state-cli get-my-channel-fund` to check balances before
117
175
  telling the user to move funds.
118
176
  - Explain that wallet names are local CLI identifiers, while private transfers use notes owned by L2 addresses
119
177
  registered in the channel.
178
+ - Before guiding a user through `create-channel` or `join-channel`, explain that channel policy is immutable after
179
+ creation and that joining a channel means accepting its current verifier, DApp metadata, function layout, managed
180
+ storage vector, and refund policy.
120
181
  - Do not present one fixed command sequence as universally correct. Some flows start from an existing channel or wallet,
121
182
  while others require creating or joining a channel first.
122
183
  - When the user asks for a transfer, first determine whether the sender has minted notes available. If not, guide them
@@ -128,8 +189,8 @@ Suggested interaction flow:
128
189
 
129
190
  1. Identify the target network, usually `sepolia` for testing.
130
191
  2. Identify whether a channel already exists.
131
- 3. Identify the sender and recipient wallets or private-key environment variables.
132
- 4. Run `--doctor`.
192
+ 3. Identify the sender and recipient wallets or local account names.
193
+ 4. Run `doctor`.
133
194
  5. Run `list-local-wallets` and relevant metadata or balance checks.
134
195
  6. If needed, guide the user through `create-channel`, `deposit-bridge`, `join-channel`, `deposit-channel`, and
135
196
  `mint-notes`.
@@ -144,7 +205,7 @@ command.
144
205
 
145
206
  ## Artifacts
146
207
 
147
- Proof-backed commands require installed bridge, DApp, and Groth16 artifacts. Run `private-state-cli --install` before
208
+ Proof-backed commands require installed bridge, DApp, and Groth16 artifacts. Run `private-state-cli install` before
148
209
  using bridge-facing commands on a new machine.
149
210
 
150
211
  Channel balance commands such as `deposit-channel` and `withdraw-channel` use the installed Groth16 runtime workspace
@@ -161,10 +222,10 @@ Release order matters for npm publication. `@tokamak-private-dapps/common-librar
161
222
  ### What does this package install?
162
223
 
163
224
  It installs the `private-state-cli` terminal command and the local files needed by that command.
164
- It does not install bridge contracts, app contracts, or local deployment outputs. The `private-state-cli --install`
225
+ It does not install bridge contracts, app contracts, or local deployment outputs. The `private-state-cli install`
165
226
  command provisions the local Tokamak zk-EVM and Groth16 runtime workspaces used by proof-backed commands.
166
227
 
167
- ### When should I run `private-state-cli --install`?
228
+ ### When should I run `private-state-cli install`?
168
229
 
169
230
  Run it once on a new machine, or after public bridge, DApp, Groth16, or Tokamak zk-EVM runtime artifacts are updated.
170
231