1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

Improve creating channels in adnl (#1108)

* Improve creating channels in adnl

* Improve handling of cryptographic keys
This commit is contained in:
SpyCheese 2024-08-15 15:25:16 +03:00 committed by GitHub
parent 0cff1c88f7
commit 77a816e461
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 109 additions and 80 deletions

View file

@ -31,7 +31,6 @@ class Encryptor {
virtual td::Result<td::BufferSlice> encrypt(td::Slice data) = 0;
virtual td::Status check_signature(td::Slice message, td::Slice signature) = 0;
virtual ~Encryptor() = default;
static td::Result<std::unique_ptr<Encryptor>> create(const ton_api::PublicKey *id);
};
class Decryptor {
@ -40,7 +39,6 @@ class Decryptor {
virtual td::Result<td::BufferSlice> sign(td::Slice data) = 0;
virtual std::vector<td::Result<td::BufferSlice>> sign_batch(std::vector<td::Slice> data);
virtual ~Decryptor() = default;
static td::Result<std::unique_ptr<Decryptor>> create(const ton_api::PrivateKey *id);
};
class EncryptorAsync : public td::actor::Actor {
@ -61,16 +59,6 @@ class EncryptorAsync : public td::actor::Actor {
void encrypt(td::BufferSlice data, td::Promise<td::BufferSlice> promise) {
promise.set_result(encryptor_->encrypt(data.as_slice()));
}
template <class T>
static td::Result<td::actor::ActorOwn<EncryptorAsync>> create(T &id) {
TRY_RESULT(d, Encryptor::create(id));
return td::actor::create_actor<EncryptorAsync>("encryptor", std::move(d));
}
template <class T>
static td::Result<td::actor::ActorOwn<EncryptorAsync>> create(T *id) {
TRY_RESULT(d, Encryptor::create(id));
return td::actor::create_actor<EncryptorAsync>("encryptor", std::move(d));
}
};
class DecryptorAsync : public td::actor::Actor {
@ -94,16 +82,6 @@ class DecryptorAsync : public td::actor::Actor {
}
return decryptor_->sign_batch(v);
}
template <class T>
static td::Result<td::actor::ActorOwn<DecryptorAsync>> create(T &id) {
TRY_RESULT(d, Decryptor::create(id));
return td::actor::create_actor<DecryptorAsync>("decryptor", std::move(d));
}
template <class T>
static td::Result<td::actor::ActorOwn<DecryptorAsync>> create(T *id) {
TRY_RESULT(d, Decryptor::create(id));
return td::actor::create_actor<DecryptorAsync>("decryptor", std::move(d));
}
};
} // namespace ton