Skip to content

Add viewing-public-key, RAILGUN-address, and CLEAR_SIGN transact builders - #24

Merged
zy0n merged 2 commits into
mainfrom
feat/clear-sign-accessors
Jul 24, 2026
Merged

Add viewing-public-key, RAILGUN-address, and CLEAR_SIGN transact builders#24
zy0n merged 2 commits into
mainfrom
feat/clear-sign-accessors

Conversation

@zy0n

@zy0n zy0n commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Adds the additive command surface from RAILGUN firmware 1.6.1, all capability-gated and non-breaking.

Device read accessors

  • VIEWING_PUBLIC_KEY (INS 0x10, P1=0x01) — returns the 32-byte compressed Ed25519 viewing public key. A display/verify accessor that does not export the viewing secret; wallet loading still uses the viewing private key (INS 0x13).
  • RAILGUN_ADDRESS (INS 0x14, P1=0x01) — returns the 127-byte ASCII 0zk1… address for on-device cross-check of the host-derived address.

CLEAR_SIGN transact protocol (INS 0x11)

Pure APDU builders for the full single-tx clear-sign session — CS_INIT, NULLIFIER, BP_FIELDS, OUT_BROADCASTER, OUT_CHANGE, OUT_TRANSFER, OUT_UNSHIELD, FINALIZE — plus:

  • validateClearSignShape (n,m in [1,3], n+m <= 5), encodeErc20TokenHash, and range guards (minGasPrice uint48, memo <= 32, field widths).
  • parseClearSignFinalize — parses the 129-byte FINALIZE response into an EdDSA signature + echoed message hash.

Builders are pure (request -> ApduCommand); session orchestration and engine wiring are intentionally not included yet, and the capability is marked experimental. Locked with golden-vector tests that reproduce the firmware spec's worked 1x1 unshield example byte-for-byte.

Extends the RAILGUN profile with the new command definitions and capability flags. Typecheck/lint clean; full suite green.

zy0n added 2 commits July 24, 2026 14:54
RAILGUN firmware 1.6.1 adds two display-and-confirm read commands. Expose
them as additive, capability-gated accessors:

- VIEWING_PUBLIC_KEY (INS 0x10, P1=0x01): returns the 32-byte compressed
  Ed25519 viewing *public* key. A display/verify accessor that does not
  export the viewing secret; wallet loading still uses the viewing private
  key (INS 0x13).
- RAILGUN_ADDRESS (INS 0x14, P1=0x01): returns the 127-byte ASCII 0zk1…
  address for on-device cross-check of the host-derived address.

Extends the RAILGUN profile with the two command definitions plus a
railgunClearSign capability flag (reserved for the forthcoming CLEAR_SIGN
protocol), marks CLEAR_SIGN experimental in the capability map, and adds
builders, length-checked response parsers, and RailgunSigner methods.
Locked with golden-vector unit tests from the firmware spec.
Firmware 1.6.1 clear-signs a RAILGUN transact through a stateful, multi-step
session where P1 selects the sub-command. Add pure APDU builders for the full
single-tx flow — CS_INIT, NULLIFIER, BP_FIELDS, OUT_BROADCASTER, OUT_CHANGE,
OUT_TRANSFER, OUT_UNSHIELD, FINALIZE — plus:

- validateClearSignShape: enforces the device limits (n,m in [1,3], n+m <= 5).
- encodeErc20TokenHash: 20-byte address -> 32-byte tokenHash.
- parseClearSignFinalize: parses the 129-byte FINALIZE response (0x60 prefix +
  R8x/R8y/S + echoed msgHash) into an EdDSA signature + message hash.

Builders are pure (request -> ApduCommand); session orchestration and engine
wiring are intentionally not included yet. Range-checks minGasPrice (uint48),
memo length (<= 32), and field widths. Locked with golden-vector tests that
reproduce the firmware spec's worked 1x1 unshield example byte-for-byte, plus
the documented multi-output layouts.
@zy0n
zy0n merged commit ca28981 into main Jul 24, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant