-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
blockchain_integration/pi_network/dapi/crypto/hash_based/crypto.cpp
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,31 @@ | ||
#include "crypto.h" | ||
#include <NTL/SHA.h> | ||
#include <NTL/Keccak.h> | ||
|
||
Crypto::Crypto() {} | ||
|
||
Crypto::~Crypto() {} | ||
|
||
std::vector<NTL::ZZ> Crypto::sha256(const std::vector<NTL::ZZ>& input) { | ||
NTL::SHA256 sha256; | ||
sha256.update(input); | ||
std::vector<NTL::ZZ> hash = sha256.final(); | ||
return hash; | ||
} | ||
|
||
std::vector<NTL::ZZ> Crypto::keccak256(const std::vector<NTL::ZZ>& input) { | ||
NTL::Keccak keccak; | ||
keccak.update(input); | ||
std::vector<NTL::ZZ> hash = keccak.final(); | ||
return hash; | ||
} | ||
|
||
std::vector<NTL::ZZ> Crypto::sign(const std::vector<NTL::ZZ>& message, const NTL::ZZ& privateKey) { | ||
// Implement digital signature algorithm (e.g. ECDSA) | ||
return std::vector<NTL::ZZ>(); | ||
} | ||
|
||
bool Crypto::verify(const std::vector<NTL::ZZ>& message, const std::vector<NTL::ZZ>& signature, const NTL::ZZ& publicKey) { | ||
// Implement digital signature verification algorithm (e.g. ECDSA) | ||
return true; | ||
} |