-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_blinded_hash.cxx
39 lines (32 loc) · 1.16 KB
/
get_blinded_hash.cxx
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
39
#include "includes.h"
using namespace CryptoPP;
#define DOCUMENTATION "Hashes the message and then blinds the hash so it can be sent to the signer."
#define USEAGE "blsig_get_blinded_hash message client_secret public_key.pem"
#define ARGUMENT_COUNT 3
static std::string message;
static Integer client_secret;
static RSA::PublicKey public_key;
int main(int argc, char *argv[])
{
if(ARGUMENT_COUNT != --argc){
std::cerr << "Incorrect useage of " << argv[0]
<< ". Expected " << ARGUMENT_COUNT << " arguments; given " << argc << "." << std::endl
<< "Useage: \n\t" << USEAGE << std::endl
<< DOCUMENTATION << std::endl;
return EXIT_FAILURE;
}
try{
message = argv[1];
client_secret = Integer(argv[2]);
public_key = ReadPEMPublicKey(argv[3]);
}
catch(std::runtime_error& e)
{
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
}
Integer hashed_message = GenerateHash(message);
Integer hidden_message = MessageBlinding(hashed_message, public_key, client_secret);
std::cout << std::hex << hidden_message << std::endl;
return EXIT_SUCCESS;
}