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
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2cfd42c
Clean up of bls_private_key, bls_public_key and bls_signature, remove…
systemzax Aug 21, 2023
4b373a0
Added wif import / export + checksum based on the fc::private_key model
systemzax Aug 21, 2023
23d049d
remove cout statements
systemzax Aug 21, 2023
a1ced9c
Added back prefixes for bls_private_key, bls_public_key and bls_signa…
systemzax Aug 23, 2023
a82c129
Renamed serialization tests in test_bls.cpp
systemzax Aug 23, 2023
5f5ebe1
Fixed serialization / deserialization and checksum, key / signatures …
systemzax Aug 25, 2023
cf2920e
Changed private key storage type from vector<uint8_t> to array<uint64…
systemzax Aug 25, 2023
3cef6f1
Removed commented code
systemzax Aug 25, 2023
fae6f9e
Merge branch 'hotstuff_integration' into bls_cleanup_test_changes
systemzax Aug 25, 2023
44f76c4
Fixed prefix verfication + various cosmetic / style improvements
systemzax Aug 25, 2023
14fc742
Added correct prefix verification for bls signature
systemzax Aug 25, 2023
0b181fb
Merge branch 'bls_cleanup_test_changes' of https://github.com/Antelop…
systemzax Aug 25, 2023
f198385
Added == operator to bls_private_key + unit test for binary construct…
systemzax Aug 25, 2023
02abeb4
Added tests for public key encoding, use std::string for key prefixes
systemzax Aug 26, 2023
8966a29
Expanded bls unit tests to include additional format + checksum tests…
systemzax Aug 27, 2023
a0650f4
Updated bls_public_key and bls_signature == operator to use the corre…
systemzax Aug 27, 2023
d169dee
Updated bls_public_key and bls_signature == operator to use the corre…
systemzax Aug 27, 2023
1a05a40
Update libraries/libfc/src/crypto/bls_signature.cpp
systemzax Aug 27, 2023
98e1ae8
Update libraries/libfc/include/fc/crypto/bls_signature.hpp
systemzax Aug 27, 2023
22aac3b
Replace constexpr with const keyword for bls_signature_prefix declara…
systemzax Aug 27, 2023
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
1 change: 1 addition & 0 deletions libraries/libfc/include/fc/crypto/bls_private_key.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace fc::crypto::blslib {
private:
std::array<uint64_t, 4> _sk;

friend bool operator == ( const bls_private_key& pk1, const bls_private_key& pk2);
friend struct reflector<bls_private_key>;
}; // bls_private_key

Expand Down
1 change: 0 additions & 1 deletion libraries/libfc/include/fc/crypto/bls_public_key.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ namespace fc::crypto::blslib {
bls12_381::g1 _pkey;

private:
friend std::ostream& operator<< (std::ostream& s, const bls_public_key& k);
friend struct reflector<bls_public_key>;
friend class bls_private_key;
}; // bls_public_key
Expand Down
4 changes: 4 additions & 0 deletions libraries/libfc/src/crypto/bls_private_key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ namespace fc::crypto::blslib {
return std::string(config::bls_private_key_prefix) + data_str;
}

bool operator == ( const bls_private_key& pk1, const bls_private_key& pk2) {
return std::memcmp(&pk1, &pk2, sizeof(pk1)) == 0;
greg7mdp marked this conversation as resolved.
Show resolved Hide resolved
}

} // fc::crypto::blslib

namespace fc
Expand Down
5 changes: 0 additions & 5 deletions libraries/libfc/src/crypto/bls_public_key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ namespace fc::crypto::blslib {

}

std::ostream& operator<<(std::ostream& s, const bls_public_key& k) {
s << "bls_public_key(" << k.to_string() << ')';
return s;
}

} // fc::crypto::blslib

namespace fc
Expand Down
5 changes: 0 additions & 5 deletions libraries/libfc/src/crypto/bls_signature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ namespace fc::crypto::blslib {

}

std::ostream& operator<<(std::ostream& s, const bls_signature& k) {
s << "bls_signature(" << k.to_string() << ')';
return s;
}

bool operator == ( const bls_signature& p1, const bls_signature& p2) {

// until `bls12_381::g2` has an `operator==`, do binary comparison
Expand Down
18 changes: 18 additions & 0 deletions libraries/libfc/test/test_bls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,22 @@ BOOST_AUTO_TEST_CASE(bls_pub_key_sig_serialization) try {

} FC_LOG_AND_RETHROW();


BOOST_AUTO_TEST_CASE(bls_cbinary_keys_encoding_check) try {

bls_private_key sk = bls_private_key(seed_1);

bool ok1 = bls_private_key(sk.to_string()) == sk;

std::string str = sk.to_string();

bool ok2 = bls_private_key(str).to_string() == str;

BOOST_CHECK_EQUAL(ok1, true);
BOOST_CHECK_EQUAL(ok2, true);

} FC_LOG_AND_RETHROW();
greg7mdp marked this conversation as resolved.
Show resolved Hide resolved



BOOST_AUTO_TEST_SUITE_END()