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: Clean up of bls_private_key, bls_public_key and bls_signature, … #1538

Merged
merged 20 commits into from
Aug 29, 2023

Conversation

systemzax
Copy link
Member

…removed string prefix, added base58 to_string + parsing code for bls_private_key + unit test, removed old unit test

…d string prefix, added base58 to_string + parsing code for bls_private_key + unit test, removed old unit test
@heifner heifner changed the title Clean up of bls_private_key, bls_public_key and bls_signature, … IF: Clean up of bls_private_key, bls_public_key and bls_signature, … Aug 21, 2023
libraries/libfc/src/crypto/bls_private_key.cpp Outdated Show resolved Hide resolved
libraries/libfc/src/crypto/bls_public_key.cpp Outdated Show resolved Hide resolved
libraries/libfc/test/test_bls.cpp Show resolved Hide resolved
@systemzax
Copy link
Member Author

systemzax commented Aug 21, 2023

Added checksum + wif import / export based on fc::crypto::private_key

@greg7mdp greg7mdp self-requested a review August 21, 2023 21:18
libraries/libfc/src/crypto/bls_private_key.cpp Outdated Show resolved Hide resolved
libraries/libfc/src/crypto/bls_private_key.cpp Outdated Show resolved Hide resolved
libraries/libfc/src/crypto/bls_private_key.cpp Outdated Show resolved Hide resolved
libraries/libfc/src/crypto/bls_private_key.cpp Outdated Show resolved Hide resolved
libraries/libfc/src/crypto/bls_private_key.cpp Outdated Show resolved Hide resolved
libraries/libfc/include/fc/crypto/bls_signature.hpp Outdated Show resolved Hide resolved
libraries/libfc/include/fc/crypto/bls_signature.hpp Outdated Show resolved Hide resolved
libraries/libfc/src/crypto/bls_public_key.cpp Outdated Show resolved Hide resolved
libraries/libfc/src/crypto/bls_public_key.cpp Outdated Show resolved Hide resolved
libraries/libfc/src/crypto/bls_signature.cpp Outdated Show resolved Hide resolved
@greg7mdp
Copy link
Contributor

Why do we recompute the secret key every time we sign?

   bls_signature bls_private_key::sign( const vector<uint8_t>& message ) const
   {
      std::array<uint64_t, 4> sk = bls12_381::secret_key(_seed);
      bls12_381::g2 sig = bls12_381::sign(sk, message);
      return bls_signature(sig);
   }

@arhag arhag linked an issue Aug 22, 2023 that may be closed by this pull request
@heifner heifner linked an issue Aug 22, 2023 that may be closed by this pull request
@systemzax
Copy link
Member Author

systemzax commented Aug 25, 2023

Why do we recompute the secret key every time we sign?

   bls_signature bls_private_key::sign( const vector<uint8_t>& message ) const
   {
      std::array<uint64_t, 4> sk = bls12_381::secret_key(_seed);
      bls12_381::g2 sig = bls12_381::sign(sk, message);
      return bls_signature(sig);
   }

I changed the storage type from vector<uint8_t> to array<uint64_t, 4>, which allows us to avoid recomputing the key every time we sign

libraries/libfc/include/fc/crypto/bls_private_key.hpp Outdated Show resolved Hide resolved
libraries/libfc/include/fc/crypto/bls_public_key.hpp Outdated Show resolved Hide resolved
libraries/libfc/src/crypto/bls_signature.cpp Outdated Show resolved Hide resolved
libraries/libfc/include/fc/crypto/bls_public_key.hpp Outdated Show resolved Hide resolved
libraries/libfc/include/fc/crypto/bls_public_key.hpp Outdated Show resolved Hide resolved
libraries/libfc/include/fc/crypto/bls_signature.hpp Outdated Show resolved Hide resolved
libraries/libfc/src/crypto/bls_private_key.cpp Outdated Show resolved Hide resolved
libraries/libfc/src/crypto/bls_public_key.cpp Outdated Show resolved Hide resolved
libraries/libfc/src/crypto/bls_public_key.cpp Outdated Show resolved Hide resolved
libraries/libfc/src/crypto/bls_signature.cpp Outdated Show resolved Hide resolved
libraries/libfc/src/crypto/bls_signature.cpp Outdated Show resolved Hide resolved
libraries/libfc/include/fc/crypto/bls_private_key.hpp Outdated Show resolved Hide resolved
libraries/libfc/include/fc/crypto/bls_signature.hpp Outdated Show resolved Hide resolved
libraries/libfc/include/fc/crypto/bls_private_key.hpp Outdated Show resolved Hide resolved
libraries/libfc/test/test_bls.cpp Outdated Show resolved Hide resolved
libraries/libfc/src/crypto/bls_private_key.cpp Outdated Show resolved Hide resolved
libraries/libfc/include/fc/crypto/bls_signature.hpp Outdated Show resolved Hide resolved
libraries/libfc/src/crypto/bls_signature.cpp Outdated Show resolved Hide resolved
@greg7mdp
Copy link
Contributor

@heifner can we merge this one?

@greg7mdp
Copy link
Contributor

@systemzax please push the merge button!

@heifner heifner merged commit ddb9ac4 into hotstuff_integration Aug 29, 2023
22 checks passed
@heifner heifner deleted the bls_cleanup_test_changes branch August 29, 2023 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IF: Implement string serialization for bls_* types IF: Fix failing test bls_sig_verif_string_multi
5 participants