-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1538 from AntelopeIO/bls_cleanup_test_changes
IF: Clean up of bls_private_key, bls_public_key and bls_signature, …
- Loading branch information
Showing
12 changed files
with
289 additions
and
450 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#pragma once | ||
#include <fc/crypto/common.hpp> | ||
|
||
namespace fc::crypto::blslib { | ||
|
||
template <typename Container> | ||
static Container serialize_base58(const std::string& data_str) | ||
{ | ||
|
||
using wrapper = checksummed_data<Container>; | ||
|
||
wrapper wrapped; | ||
|
||
auto bin = fc::from_base58(data_str); | ||
fc::datastream<const char*> unpacker(bin.data(), bin.size()); | ||
fc::raw::unpack(unpacker, wrapped); | ||
FC_ASSERT(!unpacker.remaining(), "decoded base58 length too long"); | ||
auto checksum = wrapper::calculate_checksum(wrapped.data, nullptr); | ||
FC_ASSERT(checksum == wrapped.check); | ||
|
||
return wrapped.data; | ||
} | ||
|
||
template <typename Container> | ||
static std::string deserialize_base58( Container data, const yield_function_t& yield) { | ||
|
||
using wrapper = checksummed_data<Container>; | ||
|
||
wrapper wrapped; | ||
|
||
wrapped.data = data; | ||
yield(); | ||
wrapped.check = wrapper::calculate_checksum(wrapped.data, nullptr); | ||
yield(); | ||
auto packed = raw::pack( wrapped ); | ||
yield(); | ||
auto data_str = to_base58( packed.data(), packed.size(), yield ); | ||
yield(); | ||
|
||
return data_str; | ||
} | ||
|
||
} // fc::crypto::blslib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.