MCPcopy Create free account
hub / github.com/QuipNetwork/cpp-sdk / recoverKeyPair

Method recoverKeyPair

src/cli.cpp:138–161  ·  view source on GitHub ↗

Deterministically recover keypair for a given vaultId and publicSeed

Source from the content-addressed store, hash-verified

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,

Callers 5

handleTransferMethod · 0.80
handleExecuteMethod · 0.80
handleChangePqOwnerMethod · 0.80
handleRecoverKeypairMethod · 0.80
handleSignMethod · 0.80

Calls 1

keccak256Function · 0.85

Tested by

no test coverage detected