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

IF: Update signature-provider parsing for base64 BLS public keys #2066

Merged
merged 3 commits into from
Jan 10, 2024

Conversation

heifner
Copy link
Member

@heifner heifner commented Jan 10, 2024

BLS public keys are base64 encoded which include trailing =. Update the signature-provider parsing to expect these "extra" =s.
Shutdown on startup for malformed signature-provider arguments. Previously nodeos would log an error and continue.

Resolves #2060

@heifner heifner added the OCI Work exclusive to OCI team label Jan 10, 2024
@heifner heifner linked an issue Jan 10, 2024 that may be closed by this pull request
Copy link
Member

@linh2931 linh2931 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Later tests can be added.

@@ -42,6 +42,9 @@ class signature_provider_plugin_impl {
std::tuple<std::string, std::string, std::string> parse_spec(const std::string& spec) const {
auto delim = spec.find("=");
EOS_ASSERT(delim != std::string::npos, chain::plugin_config_exception, "Missing \"=\" in the key spec pair");
// public_key can be base64 encoded with trailing `=`
while( spec.size() > delim+1 && spec[delim+1] == '=' )
++delim;
auto pub_key_str = spec.substr(0, delim);
auto spec_str = spec.substr(delim + 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this be out of range if = is the last char in spec and delim points to =?

@@ -42,6 +42,9 @@ class signature_provider_plugin_impl {
std::tuple<std::string, std::string, std::string> parse_spec(const std::string& spec) const {
auto delim = spec.find("=");
EOS_ASSERT(delim != std::string::npos, chain::plugin_config_exception, "Missing \"=\" in the key spec pair");
// public_key can be base64 encoded with trailing `=`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add in the comment what spec looks like when the public_key has trailing =?

@heifner heifner requested a review from greg7mdp January 10, 2024 16:42
// e.g. --signature-provider PUB_BLS_Fmgk<snip>iuA===KEY:PVT_BLS_NZhJ<snip>ZHFu
while( spec.size() > delim+1 && spec[delim+1] == '=' )
++delim;
EOS_ASSERT(delim < spec.size() + 1, chain::plugin_config_exception, "Missing spec data in the key spec pair");
auto pub_key_str = spec.substr(0, delim);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't pub_key_str potentially end with multiple = characters? Maybe it is not an issue?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, which like the example comment shows is rather ugly. We will likely move to base64url in the future partly do to this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So should we do something like this:

         auto delim_end = delim;
         while( spec.size() > delim_end+1 && spec[delim_end+1] == '=' )
            ++delim_end;
         EOS_ASSERT(delim_end < spec.size() + 1, chain::plugin_config_exception, "Missing spec data in the key spec pair");
         auto pub_key_str = spec.substr(0, delim);
         auto spec_str = spec.substr(delim_end + 1);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, The public key is PUB_BLS_Fmgk<snip>iuA== the separator is =KEY:. Also note the separator can also be =KEOSD: and =SE:.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, OK. No spaces possible, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, no spaces allowed.

@heifner heifner merged commit 59532df into hotstuff_integration Jan 10, 2024
26 checks passed
@heifner heifner deleted the GH-2060-bls-sig-provider branch January 10, 2024 17:19
@ericpassmore
Copy link
Contributor

Note:start
group: IF
category: INTERNALS
summary: Better support for BLS signatures by expecting and dealing correctly with '='. In addition, nodeos will shutdown during a startup, when invalid signature-provider arguments are detected.
Note: end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCI Work exclusive to OCI team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IF: signature-provider for BLS keys
4 participants