Skip to content

Commit 91f10b1

Browse files
committed
refactor: removed unused functions from bls_ies
1 parent 26c058a commit 91f10b1

File tree

2 files changed

+0
-72
lines changed

2 files changed

+0
-72
lines changed

src/bls/bls_ies.cpp

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,6 @@ uint256 CBLSIESEncryptedBlob::GetIV(size_t idx) const
3838
return iv;
3939
}
4040

41-
bool CBLSIESEncryptedBlob::Encrypt(size_t idx, const CBLSPublicKey& peerPubKey, const void* plainTextData, size_t dataSize)
42-
{
43-
CBLSSecretKey ephemeralSecretKey;
44-
ephemeralSecretKey.MakeNewKey();
45-
ephemeralPubKey = ephemeralSecretKey.GetPublicKey();
46-
47-
CBLSPublicKey pk;
48-
if (!pk.DHKeyExchange(ephemeralSecretKey, peerPubKey)) {
49-
return false;
50-
}
51-
52-
std::vector<unsigned char> symKey = pk.ToByteVector();
53-
symKey.resize(32);
54-
55-
uint256 iv = GetIV(idx);
56-
return EncryptBlob(plainTextData, dataSize, data, symKey.data(), iv.begin());
57-
}
58-
5941
bool CBLSIESEncryptedBlob::Decrypt(size_t idx, const CBLSSecretKey& secretKey, CDataStream& decryptedDataRet) const
6042
{
6143
CBLSPublicKey pk;
@@ -75,24 +57,6 @@ bool CBLSIESEncryptedBlob::IsValid() const
7557
return ephemeralPubKey.IsValid() && !data.empty() && !ivSeed.IsNull();
7658
}
7759

78-
79-
bool CBLSIESMultiRecipientBlobs::Encrypt(const std::vector<CBLSPublicKey>& recipients, const BlobVector& _blobs)
80-
{
81-
if (recipients.size() != _blobs.size()) {
82-
return false;
83-
}
84-
85-
InitEncrypt(_blobs.size());
86-
87-
for (size_t i = 0; i < _blobs.size(); i++) {
88-
if (!Encrypt(i, recipients[i], _blobs[i])) {
89-
return false;
90-
}
91-
}
92-
93-
return true;
94-
}
95-
9660
void CBLSIESMultiRecipientBlobs::InitEncrypt(size_t count)
9761
{
9862
ephemeralSecretKey.MakeNewKey();

src/bls/bls_ies.h

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class CBLSIESEncryptedBlob
2222
READWRITE(obj.ephemeralPubKey, obj.ivSeed, obj.data);
2323
}
2424

25-
bool Encrypt(size_t idx, const CBLSPublicKey& peerPubKey, const void* data, size_t dataSize);
2625
bool Decrypt(size_t idx, const CBLSSecretKey& secretKey, CDataStream& decryptedDataRet) const;
2726
bool IsValid() const;
2827
};
@@ -40,17 +39,6 @@ class CBLSIESEncryptedObject : public CBLSIESEncryptedBlob
4039
data = dataIn;
4140
}
4241

43-
bool Encrypt(size_t idx, const CBLSPublicKey& peerPubKey, const Object& obj, int nVersion)
44-
{
45-
try {
46-
CDataStream ds(SER_NETWORK, nVersion);
47-
ds << obj;
48-
return CBLSIESEncryptedBlob::Encrypt(idx, peerPubKey, ds.data(), ds.size());
49-
} catch (const std::exception&) {
50-
return false;
51-
}
52-
}
53-
5442
bool Decrypt(size_t idx, const CBLSSecretKey& secretKey, Object& objRet, int nVersion) const
5543
{
5644
CDataStream ds(SER_NETWORK, nVersion);
@@ -80,8 +68,6 @@ class CBLSIESMultiRecipientBlobs
8068
CBLSSecretKey ephemeralSecretKey;
8169
std::vector<uint256> ivVector;
8270

83-
bool Encrypt(const std::vector<CBLSPublicKey>& recipients, const BlobVector& _blobs);
84-
8571
void InitEncrypt(size_t count);
8672
bool Encrypt(size_t idx, const CBLSPublicKey& recipient, const Blob& blob);
8773
bool Decrypt(size_t idx, const CBLSSecretKey& sk, Blob& blobRet) const;
@@ -96,28 +82,6 @@ template <typename Object>
9682
class CBLSIESMultiRecipientObjects : public CBLSIESMultiRecipientBlobs
9783
{
9884
public:
99-
using ObjectVector = std::vector<Object>;
100-
101-
bool Encrypt(const std::vector<CBLSPublicKey>& recipients, const ObjectVector& _objects, int nVersion)
102-
{
103-
BlobVector blobs;
104-
blobs.resize(_objects.size());
105-
106-
try {
107-
CDataStream ds(SER_NETWORK, nVersion);
108-
for (size_t i = 0; i < _objects.size(); i++) {
109-
ds.clear();
110-
111-
ds << _objects[i];
112-
blobs[i].assign(UCharCast(ds.data()), UCharCast(ds.data() + ds.size()));
113-
}
114-
} catch (const std::exception&) {
115-
return false;
116-
}
117-
118-
return CBLSIESMultiRecipientBlobs::Encrypt(recipients, blobs);
119-
}
120-
12185
bool Encrypt(size_t idx, const CBLSPublicKey& recipient, const Object& obj, int nVersion)
12286
{
12387
CDataStream ds(SER_NETWORK, nVersion);

0 commit comments

Comments
 (0)