Add viewing-public-key, RAILGUN-address, and CLEAR_SIGN transact builders - #24
Merged
Conversation
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.
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.
Adds the additive command surface from RAILGUN firmware 1.6.1, all capability-gated and non-breaking.
Device read accessors
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.