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

Method handleGenerateKeypair

src/cli.cpp:884–915  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

882}
883
884bool CLI::handleGenerateKeypair(const std::vector<std::string> &args) {
885 if (args.size() != 2) {
886 std::cerr << "Usage: generate-keypair <quantum_secret> <vault_id>"
887 << std::endl;
888 std::cerr << " quantum_secret: 32-byte hex string (0x...)" << std::endl;
889 std::cerr << " vault_id: 32-byte hex string (0x...)" << std::endl;
890 return false;
891 }
892 try {
893 std::vector<uint8_t> quantum_secret_vec = fromHex(args[0]);
894 std::vector<uint8_t> vault_id_vec = fromHex(args[1]);
895 if (quantum_secret_vec.size() != 32 || vault_id_vec.size() != 32) {
896 throw std::runtime_error("quantum_secret and vault_id must be 32 bytes");
897 }
898 std::array<uint8_t, 32> quantum_secret;
899 std::copy(quantum_secret_vec.begin(), quantum_secret_vec.end(),
900 quantum_secret.begin());
901 std::array<uint8_t, 32> vault_id;
902 std::copy(vault_id_vec.begin(), vault_id_vec.end(), vault_id.begin());
903 QuipSigner signer(quantum_secret);
904 auto [pqAddress, private_key] = signer.generateKeyPair(vault_id);
905 std::cout << "Winternitz Public Seed: " << toHex(pqAddress.publicSeed)
906 << std::endl;
907 std::cout << "Winternitz Public Key Hash: "
908 << toHex(pqAddress.publicKeyHash) << std::endl;
909 std::cout << "Winternitz Private Key: " << toHex(private_key) << std::endl;
910 return true;
911 } catch (const std::exception &e) {
912 std::cerr << "Error: " << e.what() << std::endl;
913 return false;
914 }
915}
916
917bool CLI::handleRecoverKeypair(const std::vector<std::string> &args) {
918 if (args.size() != 3) {

Callers

nothing calls this directly

Calls 3

fromHexFunction · 0.85
toHexFunction · 0.85
generateKeyPairMethod · 0.80

Tested by

no test coverage detected