monad-keystore: add v3 keystores (v1 secret key plus PQ seed)
The driver here is wanting to support additional (post-quantum) keys on each peer. The current default v2 key store mechanism is ideal for this; the store is just a 32 byte random seed, and the secp256k1 key is derived by hashing the seed with a domain separator. This extends very naturally to supporting any number of post-quantum schemes; just hash with "monad-derive-key-mldsa-87", "monad-derive-key-mlkem-1024", and so on to generate new key material.
However the legacy v1 format does not support this. It stores the secp256k1 secret scalar directly. Here, we don't have anything we can safely derive from because an attacker who can compute ECDLP can recover that scalar. If we derived the PQ keys by hashing the scalar the PQ schemes would be broken through ECDLP. So this extends the keystore with "v3" which stores both the secret scalar and a PQ seed.
Right now this just extends the system to be able to read v3 keys; nothing yet uses the PQ seed. There is also an upgrade path, which is disabled by default, with the expectation that we'll want to deploy this for a release or two before upgrading, since you can't rollback to a v1 key store without losing the key material.
The v3 format also versions the hash so you cannot rollback keystores to an older version. The v1/v2 formats remain unchanged.
It's not entirely clear if this is necessary. The v2 keystore format was added in 0.11.0 (Sept 2025) which is quite a while before mainnet launch. It seems possible that literally no v1 keystores are in production use anywhere. In which case a much simpler approach would be to just drop the v1 keystore support. However it was not clear to me if we have sufficient visibility into such things to have any way of answering this question.
Code by Claude