Deterministically recover keypair for a given vaultId and publicSeed
| 136 | |
| 137 | // Deterministically recover keypair for a given vaultId and publicSeed |
| 138 | std::pair<WinternitzAddress, std::vector<std::array<uint8_t, 32>>> |
| 139 | recoverKeyPair(const std::array<uint8_t, 32> &vaultId, |
| 140 | const std::array<uint8_t, 32> &publicSeed) { |
| 141 | // Create the private seed by concatenating the quantum secret and |
| 142 | // the vaultId, then hash it (matching TypeScript implementation) |
| 143 | std::vector<uint8_t> concat(quantum_secret_.begin(), |
| 144 | quantum_secret_.end()); |
| 145 | concat.insert(concat.end(), vaultId.begin(), vaultId.end()); |
| 146 | std::array<uint8_t, 32> private_seed_array = keccak256(concat); |
| 147 | std::vector<uint8_t> private_seed(private_seed_array.begin(), private_seed_array.end()); |
| 148 | |
| 149 | |
| 150 | // Generate keypair using the two-parameter interface (protocol-compatible) |
| 151 | auto [public_key, private_key] = |
| 152 | wots_.generate_key_pair(private_seed, publicSeed); |
| 153 | |
| 154 | // Create WinternitzAddress from the generated public key |
| 155 | WinternitzAddress pqAddress; |
| 156 | std::copy(public_key.begin(), public_key.begin() + 32, |
| 157 | pqAddress.publicSeed.begin()); |
| 158 | std::copy(public_key.begin() + 32, public_key.end(), |
| 159 | pqAddress.publicKeyHash.begin()); |
| 160 | return {pqAddress, private_key}; |
| 161 | } |
| 162 | |
| 163 | // Sign a message using a recovered keypair |
| 164 | Signature sign(const std::array<uint8_t, 32> &message, |
no test coverage detected