Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: deglobalization of bls_legacy_scheme 3/N #6508

Merged
merged 17 commits into from
Jan 7, 2025
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
style: clang suggestion for bls rpcs
  • Loading branch information
knst committed Dec 27, 2024
commit 7cbb26b39c85b5580ca3a7a705146b9b155a1d91
95 changes: 46 additions & 49 deletions src/rpc/evo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1702,71 +1702,68 @@ static RPCHelpMan protx_help()

static RPCHelpMan bls_generate()
{
return RPCHelpMan{"bls generate",
return RPCHelpMan{
"bls generate",
"\nReturns a BLS secret/public key pair.\n",
{
{"legacy", RPCArg::Type::BOOL, RPCArg::Default{false}, "Set it true if need in legacy BLS scheme"},
},
RPCResult{
RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::STR_HEX, "secret", "BLS secret key"},
{RPCResult::Type::STR_HEX, "public", "BLS public key"},
{RPCResult::Type::STR_HEX, "scheme", "BLS scheme (valid schemes: legacy, basic)"}
}},
RPCExamples{
HelpExampleCli("bls generate", "")
},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
CBLSSecretKey sk;
sk.MakeNewKey();
bool bls_legacy_scheme{false};
if (!request.params[0].isNull()) {
bls_legacy_scheme = ParseBoolV(request.params[0], "bls_legacy_scheme");
}
UniValue ret(UniValue::VOBJ);
ret.pushKV("secret", sk.ToString());
ret.pushKV("public", sk.GetPublicKey().ToString(bls_legacy_scheme));
std::string bls_scheme_str = bls_legacy_scheme ? "legacy" : "basic";
ret.pushKV("scheme", bls_scheme_str);
return ret;
},
RPCResult{RPCResult::Type::OBJ,
"",
"",
{{RPCResult::Type::STR_HEX, "secret", "BLS secret key"},
{RPCResult::Type::STR_HEX, "public", "BLS public key"},
{RPCResult::Type::STR_HEX, "scheme", "BLS scheme (valid schemes: legacy, basic)"}}},
RPCExamples{HelpExampleCli("bls generate", "")},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue {
CBLSSecretKey sk;
sk.MakeNewKey();
bool bls_legacy_scheme{false};
if (!request.params[0].isNull()) {
bls_legacy_scheme = ParseBoolV(request.params[0], "bls_legacy_scheme");
}
UniValue ret(UniValue::VOBJ);
ret.pushKV("secret", sk.ToString());
ret.pushKV("public", sk.GetPublicKey().ToString(bls_legacy_scheme));
std::string bls_scheme_str = bls_legacy_scheme ? "legacy" : "basic";
ret.pushKV("scheme", bls_scheme_str);
return ret;
},
};
}

static RPCHelpMan bls_fromsecret()
{
return RPCHelpMan{"bls fromsecret",
return RPCHelpMan{
"bls fromsecret",
"\nParses a BLS secret key and returns the secret/public key pair.\n",
{
{"secret", RPCArg::Type::STR, RPCArg::Optional::NO, "The BLS secret key"},
{"legacy", RPCArg::Type::BOOL, RPCArg::Default{false}, "Pass true if you need in legacy scheme"},
},
RPCResult{
RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::STR_HEX, "secret", "BLS secret key"},
{RPCResult::Type::STR_HEX, "public", "BLS public key"},
{RPCResult::Type::STR_HEX, "scheme", "BLS scheme (valid schemes: legacy, basic)"},
}},
RPCResult{RPCResult::Type::OBJ,
"",
"",
{
{RPCResult::Type::STR_HEX, "secret", "BLS secret key"},
{RPCResult::Type::STR_HEX, "public", "BLS public key"},
{RPCResult::Type::STR_HEX, "scheme", "BLS scheme (valid schemes: legacy, basic)"},
}},
RPCExamples{
HelpExampleCli("bls fromsecret", "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f")
HelpExampleCli("bls fromsecret", "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f")},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue {
bool bls_legacy_scheme{false};
if (!request.params[1].isNull()) {
bls_legacy_scheme = ParseBoolV(request.params[1], "bls_legacy_scheme");
}
CBLSSecretKey sk = ParseBLSSecretKey(request.params[0].get_str(), "secretKey");
UniValue ret(UniValue::VOBJ);
ret.pushKV("secret", sk.ToString());
ret.pushKV("public", sk.GetPublicKey().ToString(bls_legacy_scheme));
std::string bls_scheme_str = bls_legacy_scheme ? "legacy" : "basic";
ret.pushKV("scheme", bls_scheme_str);
return ret;
},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
bool bls_legacy_scheme{false};
if (!request.params[1].isNull()) {
bls_legacy_scheme = ParseBoolV(request.params[1], "bls_legacy_scheme");
}
CBLSSecretKey sk = ParseBLSSecretKey(request.params[0].get_str(), "secretKey");
UniValue ret(UniValue::VOBJ);
ret.pushKV("secret", sk.ToString());
ret.pushKV("public", sk.GetPublicKey().ToString(bls_legacy_scheme));
std::string bls_scheme_str = bls_legacy_scheme ? "legacy" : "basic";
ret.pushKV("scheme", bls_scheme_str);
return ret;
},
};
}

Expand Down