Context
Once #935 lands and vats can request crypto, SubtleCrypto, and Math in their globals array, several workarounds in packages/evm-wallet-experiment become obsolete. They were added because SES Compartments previously had no access to crypto.getRandomValues or the stock Math.random.
What to simplify
1. Drop the throwaway-keyring entropy option (high value)
makeKeyring({ type: 'throwaway', entropy?: Hex }) in src/lib/keyring.ts exists only so callers can supply entropy externally when the vat has no crypto global. With crypto endowed in the keyring vat, the workaround is dead weight.
Files touched:
src/lib/keyring.ts — drop the entropy branch, the globalThis.crypto?.getRandomValues guard, and the "throwaway keyring requires…" error path; tighten the KeyringInitOptions type
src/lib/keyring.test.ts — remove the entropy-validation and crypto-required test cases
src/vats/coordinator-vat.ts — remove entropy from the initializeKeyring RPC signature / KeyringInitOptions plumbing
src/vats/keyring-vat.ts — verify it still works without the plumbed-through entropy
src/cluster-config.ts — add 'crypto' and 'SubtleCrypto' to the keyring vat's globals (this is the change that unblocks the rest)
scripts/setup-home.sh, scripts/setup-away.sh, scripts/home-interactive.mjs — drop the openssl rand-based entropy generation and stop passing entropy into initializeKeyring
test/e2e/docker/helpers/wallet-setup.ts — mirror the cluster-config changes
README.md (root of the package) — remove the "Throwaway keyring needs secure entropy" caveat
docs/setup-guide.md — remove the "Under SES lockdown…" entropy section
2. Simplify makeSaltGenerator (medium value)
src/lib/delegation.ts::makeSaltGenerator has a crypto-available branch and a counter-fallback branch. With crypto endowed, the fallback becomes unreachable.
- Collapse to a single crypto-only implementation
- Drop the optional
entropy parameter
- Remove the counter-fallback tests (keep a test that two generators produce distinct salts)
- Update the JSDoc that describes the SES fallback
The coordinator-vat wiring at coordinator-vat.ts:377-383 can also drop its explanatory comment.
3. Reconsider raw-fetch clients vs viem (speculative, lower priority)
src/lib/bundler-client.ts and src/lib/provider.ts reimplement JSON-RPC over raw fetch to avoid viem's createClient/createPublicClient, which internally use Math.random(). With Math endowed in the provider vat, viem's clients should work — but the raw-fetch wrappers are small and focused, and migration is a refactor rather than a simplification. Recommend evaluating whether the ergonomic wins from viem's higher-level clients (retries, batching, typed RPC methods) are worth the churn; if not, just drop the "Math.random() is blocked under SES lockdown" comments that will no longer be true.
Depends on
Context
Once #935 lands and vats can request
crypto,SubtleCrypto, andMathin theirglobalsarray, several workarounds inpackages/evm-wallet-experimentbecome obsolete. They were added because SES Compartments previously had no access tocrypto.getRandomValuesor the stockMath.random.What to simplify
1. Drop the throwaway-keyring
entropyoption (high value)makeKeyring({ type: 'throwaway', entropy?: Hex })insrc/lib/keyring.tsexists only so callers can supply entropy externally when the vat has nocryptoglobal. Withcryptoendowed in the keyring vat, the workaround is dead weight.Files touched:
src/lib/keyring.ts— drop theentropybranch, theglobalThis.crypto?.getRandomValuesguard, and the "throwaway keyring requires…" error path; tighten theKeyringInitOptionstypesrc/lib/keyring.test.ts— remove the entropy-validation and crypto-required test casessrc/vats/coordinator-vat.ts— removeentropyfrom theinitializeKeyringRPC signature /KeyringInitOptionsplumbingsrc/vats/keyring-vat.ts— verify it still works without the plumbed-through entropysrc/cluster-config.ts— add'crypto'and'SubtleCrypto'to the keyring vat'sglobals(this is the change that unblocks the rest)scripts/setup-home.sh,scripts/setup-away.sh,scripts/home-interactive.mjs— drop theopenssl rand-based entropy generation and stop passingentropyintoinitializeKeyringtest/e2e/docker/helpers/wallet-setup.ts— mirror the cluster-config changesREADME.md(root of the package) — remove the "Throwaway keyring needs secure entropy" caveatdocs/setup-guide.md— remove the "Under SES lockdown…" entropy section2. Simplify
makeSaltGenerator(medium value)src/lib/delegation.ts::makeSaltGeneratorhas a crypto-available branch and a counter-fallback branch. Withcryptoendowed, the fallback becomes unreachable.entropyparameterThe coordinator-vat wiring at
coordinator-vat.ts:377-383can also drop its explanatory comment.3. Reconsider raw-fetch clients vs viem (speculative, lower priority)
src/lib/bundler-client.tsandsrc/lib/provider.tsreimplement JSON-RPC over rawfetchto avoid viem'screateClient/createPublicClient, which internally useMath.random(). WithMathendowed in the provider vat, viem's clients should work — but the raw-fetch wrappers are small and focused, and migration is a refactor rather than a simplification. Recommend evaluating whether the ergonomic wins from viem's higher-level clients (retries, batching, typed RPC methods) are worth the churn; if not, just drop the "Math.random() is blocked under SES lockdown" comments that will no longer be true.Depends on
crypto,SubtleCrypto, andMath)