Skip to content

Remove SES-lockdown workarounds in evm-wallet-experiment now that vats can request crypto/Math #938

@sirtimid

Description

@sirtimid

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions