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

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
feat: use Basic scheme only for public key serialization in bls_ies
It also removes unused ToByteVector from CBLSWrapper
  • Loading branch information
knst committed Dec 27, 2024
commit 99e9c65484e935d56132da99a549d0ccd26dd90a
5 changes: 0 additions & 5 deletions src/bls/bls.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,6 @@ class CBLSWrapper
return impl.Serialize(specificLegacyScheme);
}

std::vector<uint8_t> ToByteVector() const
{
return ToByteVector(bls::bls_legacy_scheme.load());
}

const uint256& GetHash() const
{
if (cachedHash.IsNull()) {
Expand Down
9 changes: 4 additions & 5 deletions src/bls/bls_ies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

#include <crypto/aes.h>

template <typename Out>
static bool EncryptBlob(const void* in, size_t inSize, Out& out, const void* symKey, const void* iv)
static bool EncryptBlob(const void* in, size_t inSize, std::vector<unsigned char>& out, const void* symKey, const void* iv)
{
out.resize(inSize);

Expand Down Expand Up @@ -45,7 +44,7 @@ bool CBLSIESEncryptedBlob::Decrypt(size_t idx, const CBLSSecretKey& secretKey, C
return false;
}

std::vector<unsigned char> symKey = pk.ToByteVector();
std::vector<unsigned char> symKey = pk.ToByteVector(false);
symKey.resize(32);

uint256 iv = GetIV(idx);
Expand Down Expand Up @@ -81,7 +80,7 @@ bool CBLSIESMultiRecipientBlobs::Encrypt(size_t idx, const CBLSPublicKey& recipi
return false;
}

std::vector<uint8_t> symKey = pk.ToByteVector();
std::vector<uint8_t> symKey = pk.ToByteVector(false);
symKey.resize(32);

return EncryptBlob(blob.data(), blob.size(), blobs[idx], symKey.data(), ivVector[idx].begin());
Expand All @@ -98,7 +97,7 @@ bool CBLSIESMultiRecipientBlobs::Decrypt(size_t idx, const CBLSSecretKey& sk, Bl
return false;
}

std::vector<uint8_t> symKey = pk.ToByteVector();
std::vector<uint8_t> symKey = pk.ToByteVector(false);
symKey.resize(32);

uint256 iv = ivSeed;
Expand Down
5 changes: 5 additions & 0 deletions src/bls/bls_ies.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
#include <bls/bls.h>
#include <streams.h>

/**
* All objects in this module working from assumption that basic scheme is
* available on all masternodes. Serialization of public key for Encrypt and
* Decrypt by bls_ies.h done using Basic Scheme.
*/
class CBLSIESEncryptedBlob
{
public:
Expand Down