· 9 years ago · Jan 25, 2017, 05:46 PM
1 /**
2 * constructor in which signer generate secret key and write his public key to file
3 * @param id
4 */
5 Signer(int id, BigInteger[] A, ECPoint[] R, BigInteger[] hash, ECPoint[] Y, BigInteger[] X) {
6 secretKey = generateSecretKey();
7 G = Main.ec.createPoint(Main.Gx, Main.Gy).normalize();
8 publicKey = G.multiply(secretKey).normalize();
9 System.out.println("SIGNER secretKey: " + secretKey);
10 AOwner = generateRandom();
11 A[id] = AOwner;
12 ROwner = G.multiply(AOwner);
13 R[id] = ROwner;
14 System.out.println("SIGNER R" + id + ": " + R[id]);
15 System.out.println("Do hasha: M: " + Main.M + ", Rx: " + ROwner.normalize().getAffineXCoord().toBigInteger() + ", Ry: " + ROwner.normalize().getAffineYCoord().toBigInteger());
16 hashOwner = hash(Main.M, new BigInteger(ROwner.normalize().getAffineXCoord().toString(),16), new BigInteger(ROwner.normalize().getAffineYCoord().toString(),16));
17 System.out.println("hashOwner: " + hashOwner);
18 //hashOwner = new BigInteger(Hashing.sha1().hashString(Main.M + ROwner.toString(), Charsets.UTF_8 ).toString(), 16).mod(Main.Q);
19 hash[id] = hashOwner;
20 System.out.println("SIGNER hash: " + id + ": " + hash[id]);
21 Y[id] = publicKey;
22 System.out.println("SIGNER Y" + id + ": " + Y[id]);
23 X[id] = secretKey;
24 //writeToFile(id, publicKey);
25 System.out.println("A"+id + ": " + AOwner);
26
27 }