Recover four of the seven keys behind this record
Seven signers hold one private key each, and a Solidity contract stores 672 signed messages of theirs, called heartbeats. Find four of the seven keys, which is the threshold, and prove to the contract that you know them.
All the values are in heartbeats.json and, as hexadecimal words, in instance.flat.json.
How the challenge works
Each signer has one private key. Once per epoch, every signer publishes a heartbeat, which shows that the key is still in use. The organiser writes all the heartbeats to the contract and seals them, so that nobody can change them afterwards. From then on anyone can read the record and submit a proof.
| Stage | Who acts | What happens in the contract |
|---|---|---|
| Open | Organiser | The contract is deployed with the seven public keys. Heartbeats are added in batches of 16, with publishHeartbeats |
| Sealed | Everyone | After sealRecord the record is frozen and proofs are accepted |
| Solved | Participant | The first valid call to verifyAndExecute stores the address of the caller as firstSolver |
The parts
| Part | What it does | File |
|---|---|---|
| Contract | Holds the seven public keys and the record, and decides whether you have won | src/MultisigChallenge.sol |
| Record | The 672 heartbeats, 96 from each signer | data/heartbeats.json |
| Proof verifier | Checks that you know four of the seven keys. It does not learn the keys, or which four they are | src/crypto/CDSThreshold.sol |
| Curve computation | Scalar multiplication on secp256k1, through ecrecover | src/crypto/Secp256k1.sol |
| Deployment script | Deploys the contract, uploads the record and seals it | script/DeployChallenge.s.sol |
| Tests | 23 tests of the contract and the proof, with a prover written in Solidity that you can read | test/ |
What is in a heartbeat
A heartbeat has two halves. The first is an ECDSA signature on the message hash of the epoch, which is the same for all seven signers.
The second is a liveness point. The signer takes a public base point C and publishes Y = dC, where d is the private key, as in a Diffie-Hellman exchange.
| Field | Meaning |
|---|---|
epoch | From 0 to 95 |
msg_hash | The 32 bytes that are signed |
v, r, s | The signature, in Ethereum's format |
cx, cy | The base point C |
yx, yy | The liveness point Y |
What it takes to win
You win when the contract accepts your call to verifyAndExecute. The call carries a proof that you know four of the seven private keys, which is the threshold, and a message of your choice.
The contract stores the address of the first caller who succeeds. Others can still submit a proof of their own afterwards.
| The instance | Value |
|---|---|
| Curve | secp256k1 |
| Signers | 7 |
| Keys needed | 4 |
| Epochs | 96 |
| Chain id | 31337, a local Anvil chain |
| Contract address | 0x5FbDB2315678afecb367f032d93F642f64180aa3 |
| Size of a proof | 11 numbers modulo N |
How four keys become one proof
Publishing four private keys would let anyone copy them. The contract asks for a zero-knowledge proof instead, due to Cramer, Damgård and Schoenmakers.
The proof has one challenge per signer, and the seven challenges lie on a polynomial of degree three. Its value at 0 comes from a hash that the prover cannot control. Three more values are free. That fixes the polynomial, so the other four challenges have to be taken as they come, and each can be answered only with that signer's key.
The hash covers the address of the caller, the chain, the contract and a counter. A proof copied by somebody else fails, and an accepted proof cannot be sent twice. The specification has the full protocol.
Take part
The archive contains the contract, its tests, the deployment script, the record and the specification. The instructions go from the download to a submitted proof.