-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransaction.hpp
More file actions
39 lines (30 loc) · 1.48 KB
/
Transaction.hpp
File metadata and controls
39 lines (30 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef TRANSACTION_HPP
#define TRANSACTION_HPP
#include <string>
#include <iostream>
#include "SCS/SC.cpp"
class Transaction {
public:
std::string publicKey; // публичный ключ отправителя
int howMany; // количество монет, отправленных в транзакции
std::string receiver_publicKey; // кому предназначены монеты
int signature; // подпись транзакции
Transaction(const std::string& pubKey, const int count, const std::string& recvKey)
: publicKey(pubKey), howMany(count), receiver_publicKey(recvKey), signature(0) {}
// Подписать транзакцию
void signTransaction(int privateKey, int n) {
signature = signMessage(privateKey, n, receiver_publicKey + to_string(howMany));
}
// Проверить транзакцию
bool verifyTransaction(int n) const {
return verifySignature(stoi(publicKey), n, receiver_publicKey + to_string(howMany), signature);
}
// Отобразить детали транзакции
void displayTransaction() const {
std::cout << "Публичный ключ: " << publicKey << std::endl;
std::cout << "Сколько монет: " << howMany << std::endl;
std::cout << "Ключ получателя: " << receiver_publicKey << std::endl;
std::cout << "Подпись: " << signature << std::endl;
}
};
#endif // TRANSACTION_HPP