const EntropySize
EntropySize is the size, in bytes, of the entropy a kit is derived from.
Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.
Package qrcsigner derives the one-time keys of a Quantum Recovery Commit from 32 bytes of entropy and signs with them.
Package qrcsigner derives the one-time keys of a Quantum Recovery Commit from 32 bytes of entropy and signs with them.
It is the reference signer: the key derivation written as running code, used by the tests of the registry, and by anyone who wants to check another implementation against it. Run it off-chain, with `gno test` or `gno run`. Never call it from a transaction: everything a transaction computes is public, and so would be the entropy.
Nothing on chain depends on how secrets are derived. A commit made by any other signer verifies just the same, as long as its keys are Lamport keys arranged as package qrc describes.
Each of the two trees first gets a seed of its own, computed with the hash function of the other tree:
1seed(SHA256) = Keccak256("QuantumRecoveryCommit/v1/seed/sha256" || 0x00 || entropy)
2seed(Keccak256) = SHA256( "QuantumRecoveryCommit/v1/seed/keccak256" || 0x00 || entropy)
Each seed thus rests on the function of the other tree. Should one function ever be broken badly enough to walk back from the published hashes of its tree to that tree's seed, the entropy still sits behind the other function, and with it the seed of the other tree.
From there on a tree only uses its own function. The secret number side (0 or 1) of digest bit number bit, in the one-time key number leaf, is
1info = "QuantumRecoveryCommit/v1/secret" || 0x00 || id.Bytes()
2 || uint32 leaf || uint16 bit || uint8 side
3secret(SHA256) = HMAC-SHA256(key = seed, message = info)
4secret(Keccak256) = Keccak256(seed || info)
with big-endian integers. Because info holds the commit ID, two commits never share a key, whatever the chain, registry, account or generation. The height is not part of info: a commit ID goes with a single height, since a kit derived for the same ID at another height shares its keys. A generation's keys are derived with the chain ID in force when the generation began; its messages carry the chain ID in force when they are sent.
EntropySize is the size, in bytes, of the entropy a kit is derived from.
Kit holds both trees of a Quantum Recovery Commit.
1type Tree struct {
2 h qrc.Hash
3 height int
4
5 // Input buffers of the secret derivation. The last tailSize bytes of
6 // inner change with every secret, everything before them is fixed.
7 // SHA256: inner = (seed ^ ipad) || info, outer = (seed ^ opad) || inner digest
8 // Keccak256: inner = seed || info
9 inner []byte
10 outer []byte
11
12 // levels[0] holds the leaf hashes side by side, levels[height] the root.
13 levels [][]byte
14}Tree holds the one-time keys of one of the two commits of an account.
Hash returns the hash function the tree is built on.
Height returns the height of the tree.
Root returns the commit: the root of the tree.
Sign signs msg with one-time key number leaf and returns the proof qrc.Verify expects.
A one-time key must sign a single message. Signing two different messages with the same leaf weakens the key, and a few more signatures give it away.