Countersign alpha

Stop blind signing.

Read the transaction on a second screen before you sign it.

A command-line tool for people who run agents and sign with a hardware wallet. The agent stages the transaction in the terminal. Your phone decodes the raw bytes on its own. You approve on the device when the two hashes match.

npm install -g csign Open the verifier
The verifier runs on your phone. Scan to open it there, then add it to the home screen.
Terminal not relied on
agent csign stage tx --to 0x8617…070D --sig 'transferOwnership(address)' -- 0x5290…9EE7
      staged 9c41d2a07b3e. Nothing signed.
you   csign sign 9c41d2a07b3e
From the computer by QR code
raw fields, nothing else
Countersign
Call
transferOwnership
On contract
0x8617E340B3D01FA5F11F306F4090FD50E238070D
newOwner
0x52908400098527886E0F7030069857D2E4169EE7
Hash to match
40defafb76a02fa1cb679e5bbf3dfb2313fa31827830479b39839e0f6cf39964

Your phone reads the call

From the computer by USB
the same bytes
Review transaction
Transaction hash
40defafb76a02fa1cb679e5bbf3dfb2313fa31827830479b39839e0f6cf39964
Hold to sign

Your hardware wallet shows a hash

The same hash on both screens: what you read on the phone is what gets signed. Any difference: reject on the device.

Why

How it works

  1. Stage

    csign stage tx …

    Run by the agent. Fixes every field: nonce, gas limit, fees. Simulates the transaction, signs nothing, prints an id.

  2. Sign

    csign sign <id>

    Run by you. The raw transaction appears as an animated QR code while the wallet waits with exactly the staged bytes.

  3. Read

    on the phone

    The verifier recomputes the hash with its own code and decodes the call and any batch inside it. A bundle carrying a label or description is refused.

  4. Approve

    on the device

    When the hashes match. The signed result is kept only if it equals the staged transaction field by field, then published.

Plain transactions, contract deployments, Safe owner signatures and Safe executions, on Ethereum, Base, BNB Chain, X Layer and GenLayer. For an agent, the whole brief is one file: AGENTS.md.

Threat model

Relied on

  • The hardware wallet: its key, and what its own screen shows.
  • The phone and the verifier page on it. The page computes the hash with code that shares nothing with the computer's.
  • Your own eyes on two screens.

Not relied on

  • The computer.
  • The agent or person who prepared the transaction.
  • csign itself, and anything it prints.
  • Any app front end. None is in the path.

Why it holds

The wallet signs exactly the bytes whose hash it displays. The phone shows what those bytes do and what their hash is. If the two hashes match, what you read on the phone is what gets signed, whatever the computer did. To cheat, an attacker has to control the computer and the phone at once.

It always takes two

To get a bad transaction signed, an attacker needs the side that prepares it and the side that reads it, at the same moment. Then you still have to hold the button.

If this is compromisedWhat happensAlso needed
The computer, the agent, csign or its npm packageThe phone decodes what was really staged. The wrong call or address is there on its screen.The phone
An app front endNothing. None is in the path.Not applicable
The verifier's server or domainA new version of the page shows both hashes and waits for you. Assume the worst, a swapped page: it still cannot change what the wallet signs.The computer
The phoneIt can show you a false reading. The wallet still signs only the transaction the computer staged.The computer
A name lookup serviceArgument names may be wrong, and each decode says where its names came from. The hash cannot change.The computer and the phone

The verifier keeps its own copy

  • It is one file with no outside code. Your phone saves it on first use and runs that copy from then on, offline too.
  • The copy is saved only if it matches its published hash. The hash is at the bottom of the page and in the repository, and npm run build reproduces it.
  • A new version shows both hashes and waits until you accept it.
  • Or host it yourself. It is a single HTML file.

It needs a wallet with its own screen that shows a hash. Signing on a Ledger has been run by hand; a Trezor goes through Foundry's cast and has not been run yet. The first load of the verifier on a phone trusts the server. The security model in the repository lists where it stops.

Install

# needs Node 20 or later and Foundry
npm install -g csign

# on the phone: add to the home screen, open only from that icon
https://countersign.genlayer.foundation/verify/

# on a Ledger: Ethereum app, Settings, always show the transaction hash