|
1 | 1 | import { Field, Group, PrivateKey, PublicKey } from 'o1js';
|
2 | 2 | import {
|
3 |
| - CommitteeMember, |
4 |
| - Round1Contribution, |
5 |
| - Round2Contribution, |
6 |
| - SecretPolynomial, |
7 |
| - getMerkleWitnessType, |
| 3 | + Round1Contribution, |
| 4 | + Round2Contribution, |
| 5 | + SecretPolynomial, |
8 | 6 | } from './CommitteeMember';
|
9 |
| -import { emptyWitness } from 'o1js/dist/node/lib/proof_system'; |
10 | 7 |
|
11 |
| -describe('CommitteeMember', () => { |
12 |
| - let T = 3; |
13 |
| - let N = 5; |
14 |
| - let keyId = Field(0); |
15 |
| - let committees: { |
16 |
| - privateKey: PrivateKey; |
17 |
| - committeeMember: CommitteeMember; |
18 |
| - secretPolynomial: SecretPolynomial; |
19 |
| - round1Contribution: Round1Contribution | any; |
20 |
| - round2Contribution: Round2Contribution | any; |
21 |
| - }[] = []; |
22 |
| - let round1Contributions: Round1Contribution[] = []; |
23 |
| - let publicKey: PublicKey; |
24 |
| - let w = { |
25 |
| - isLeft: false, |
26 |
| - sibling: Field(0), |
27 |
| - }; |
28 |
| - let dummyWitness = Array.from(Array(10).keys()).map(() => w); |
29 |
| - beforeAll(async () => { |
30 |
| - for (let i = 0; i < N; i++) { |
31 |
| - let privateKey = PrivateKey.random(); |
32 |
| - let committeeMember = new CommitteeMember({ |
33 |
| - publicKey: privateKey.toPublicKey(), |
34 |
| - index: i + 1, |
35 |
| - T: T, |
36 |
| - N: N, |
37 |
| - witness: new (getMerkleWitnessType(10))(dummyWitness), |
38 |
| - }); |
39 |
| - let secretPolynomial = committeeMember.getRandomPolynomial(); |
40 |
| - let round1Contribution = committeeMember.getRound1Contribution( |
41 |
| - secretPolynomial, |
42 |
| - keyId |
43 |
| - ); |
44 |
| - round1Contributions.push(round1Contribution); |
45 |
| - committees.push({ |
46 |
| - privateKey: privateKey, |
47 |
| - committeeMember: committeeMember, |
48 |
| - secretPolynomial: secretPolynomial, |
49 |
| - round1Contribution: round1Contribution, |
50 |
| - round2Contribution: null, |
51 |
| - }); |
52 |
| - } |
| 8 | +// describe('CommitteeMember', () => { |
| 9 | +// let T = 3; |
| 10 | +// let N = 5; |
| 11 | +// let keyId = Field(0); |
| 12 | +// let committees: { |
| 13 | +// privateKey: PrivateKey; |
| 14 | +// committeeMember: CommitteeMember; |
| 15 | +// secretPolynomial: SecretPolynomial; |
| 16 | +// round1Contribution: Round1Contribution | any; |
| 17 | +// round2Contribution: Round2Contribution | any; |
| 18 | +// }[] = []; |
| 19 | +// let round1Contributions: Round1Contribution[] = []; |
| 20 | +// let publicKey: PublicKey; |
| 21 | +// let w = { |
| 22 | +// isLeft: false, |
| 23 | +// sibling: Field(0), |
| 24 | +// }; |
| 25 | +// let dummyWitness = Array.from(Array(10).keys()).map(() => w); |
| 26 | +// beforeAll(async () => { |
| 27 | +// for (let i = 0; i < N; i++) { |
| 28 | +// let privateKey = PrivateKey.random(); |
| 29 | +// let committeeMember = new CommitteeMember({ |
| 30 | +// publicKey: privateKey.toPublicKey(), |
| 31 | +// index: i + 1, |
| 32 | +// T: T, |
| 33 | +// N: N, |
| 34 | +// witness: new (getMerkleWitnessType(10))(dummyWitness), |
| 35 | +// }); |
| 36 | +// let secretPolynomial = committeeMember.getRandomPolynomial(); |
| 37 | +// let round1Contribution = committeeMember.getRound1Contribution( |
| 38 | +// secretPolynomial, |
| 39 | +// keyId |
| 40 | +// ); |
| 41 | +// round1Contributions.push(round1Contribution); |
| 42 | +// committees.push({ |
| 43 | +// privateKey: privateKey, |
| 44 | +// committeeMember: committeeMember, |
| 45 | +// secretPolynomial: secretPolynomial, |
| 46 | +// round1Contribution: round1Contribution, |
| 47 | +// round2Contribution: null, |
| 48 | +// }); |
| 49 | +// } |
53 | 50 |
|
54 |
| - publicKey = CommitteeMember.getPublicKey(round1Contributions); |
55 |
| - console.log(publicKey.x.toBigInt()); |
56 |
| - console.log(publicKey.toJSON()); |
57 |
| - }); |
58 |
| - it('Test Key Generation', async () => { |
59 |
| - let m = 1; |
60 |
| - // for (let i = 0; i < N; i++) { |
61 |
| - // let senderIndex = i + 1; |
62 |
| - // let publicKeys: Group[] = []; |
63 |
| - // for (let j = 0; j < N; j++) { |
64 |
| - // let recipientIndex = j + 1; |
65 |
| - // if (senderIndex != recipientIndex) { |
66 |
| - // publicKeys.push( |
67 |
| - // committees[j].privateKey.toPublicKey().toGroup() |
68 |
| - // ); |
69 |
| - // } |
70 |
| - // } |
71 |
| - // let round2Contribution = committees[ |
72 |
| - // i |
73 |
| - // ].committeeMember.getRound2Contribution( |
74 |
| - // committees[i].secretPolynomial, |
75 |
| - // publicKeys, |
76 |
| - // keyId |
77 |
| - // ); |
78 |
| - // } |
79 |
| - }); |
80 |
| -}); |
| 51 | +// publicKey = CommitteeMember.getPublicKey(round1Contributions); |
| 52 | +// console.log(publicKey.x.toBigInt()); |
| 53 | +// console.log(publicKey.toJSON()); |
| 54 | +// }); |
| 55 | +// it('Test Key Generation', async () => { |
| 56 | +// let m = 1; |
| 57 | +// // for (let i = 0; i < N; i++) { |
| 58 | +// // let senderIndex = i + 1; |
| 59 | +// // let publicKeys: Group[] = []; |
| 60 | +// // for (let j = 0; j < N; j++) { |
| 61 | +// // let recipientIndex = j + 1; |
| 62 | +// // if (senderIndex != recipientIndex) { |
| 63 | +// // publicKeys.push( |
| 64 | +// // committees[j].privateKey.toPublicKey().toGroup() |
| 65 | +// // ); |
| 66 | +// // } |
| 67 | +// // } |
| 68 | +// // let round2Contribution = committees[ |
| 69 | +// // i |
| 70 | +// // ].committeeMember.getRound2Contribution( |
| 71 | +// // committees[i].secretPolynomial, |
| 72 | +// // publicKeys, |
| 73 | +// // keyId |
| 74 | +// // ); |
| 75 | +// // } |
| 76 | +// }); |
| 77 | +// }); |
0 commit comments