-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
38 lines (23 loc) · 838 Bytes
/
main.js
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
const ElGamal = require('basic_simple_elgamal');
const Schnorr = require('../schnorr');
const debug = require('debug');
const crypto = require('crypto');
const bigInteger = require('big-integer');
const log = debug('app::Test');
const hash = crypto.createHash('SHA3-512');
async function test(){
const elgamal = new ElGamal();
await elgamal.initializeRemotely(2048);
elgamal.checkSecurity();
const m = await elgamal.randomGropuMember();
let cipher = await elgamal.encrypt(m);
let schnorr = new Schnorr(elgamal);
let cryptoInfo = elgamal.export(true);
let secret = cryptoInfo.r;
//log('secret: ', secret);
let proof = await schnorr.prove(secret, cipher.c1);
//log('proof: ', proof);
let result = schnorr.verify(cipher.c1, proof);
log('result: ', result);
}
test();