Repository navigation
wallet: deriveKey — an origin-bound key a site can ask for (perps trading keys on durian.market) - #16
Merged
Merged
Conversation
…ding keys on durian.market)
window.rand.deriveKey({ purpose }) → { key }: 32 bytes (64 lowercase hex) derived in the
background by HKDF-SHA-256 (WebCrypto) from the wallet's spend key, salt
"rand-wallet/site-key/v1", info = length-prefixed (domain, sender origin, purpose, connected
address). Same wallet + origin + purpose gives the same key on any device restored from the
same key; another origin, purpose or wallet gives an unrelated one. The viewing key (which
provers receive) is never an input.
Policy beside connect/invoke in provider-host.js: connected origin (NOT_CONNECTED), unlocked
(LOCKED), purpose ^[a-z0-9./-]{1,64}$ (BAD_REQUEST); the first request per (origin, purpose)
is parked like an invoke (shared BUSY rule) and approved in derive.html; the yes is stored as
sites[origin].siteKeys[purpose] = {address, at} and later requests answer at once; disconnect
forgets it; Reject or a closed window is USER_REJECTED. The key is in no store and no message
but the answer to the asking frame; the window hears only {ok: true}.
inpage.js adds deriveKey; content.js relays the method and its purpose string only. New
lib/derive-key.js (classic script; Chrome importScripts, Firefox background.scripts) with a
pinned vector recomputed by node:crypto. Nine new window strings in all twenty languages.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YGaYNNSAAQZWcccfnqCmLS
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
window.rand.deriveKey({ purpose }) → { key }: an origin-bound 32-byte key a connected site can ask the wallet for. durian.market's perps terminal (web/lib/perps/session.ts) uses it for its trading keys.rand-wallet/site-key/v1, info = length-prefixed (domain, origin, purpose, connected address). The viewing key is never an input.provider-host.js: connected origin, unlocked wallet, purpose^[a-z0-9./-]{1,64}$. The first request per (origin, purpose) waits for approval inderive.html. Later requests answer at once. Disconnecting forgets the approval.inpage.js/content.jsrelay the method and the purpose string; newlib/derive-key.jswith a pinned vector.en.jsis regenerated (1132 strings,extract-strings.mjs --checkclean). Thecore/vendor/fullnodepointer is unchanged from main.Local: extension + ui unit tests 1259/1260 pass. The one failure is
rpc-methods.test.mjs, which needs thecore/vendor/fullnodesubmodule, and the submodule is not checked out in the local worktree.smoke.mjsneeds the wasm build and was not run.🤖 Generated with Claude Code
https://claude.ai/code/session_01GFs5gyuBMf1nCmyHCP3AT8