|
1 |
| -import { CommitteeMember } from './CommitteeMember'; |
| 1 | +import { Field, Group, PrivateKey, PublicKey } from 'o1js'; |
| 2 | +import { |
| 3 | + CommitteeMember, |
| 4 | + Round1Contribution, |
| 5 | + Round2Contribution, |
| 6 | + SecretPolynomial, |
| 7 | + getMerkleWitnessType, |
| 8 | +} from './CommitteeMember'; |
| 9 | +import { emptyWitness } from 'o1js/dist/node/lib/proof_system'; |
2 | 10 |
|
3 | 11 | describe('CommitteeMember', () => {
|
4 |
| - let committeeMember: CommitteeMember; |
5 |
| - it('1', async () => { |
| 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 | + } |
| 53 | + |
| 54 | + publicKey = CommitteeMember.getPublicKey(round1Contributions); |
| 55 | + console.log(publicKey.x.toBigInt()); |
| 56 | + console.log(publicKey.toJSON()); |
| 57 | + }); |
| 58 | + it('Test Key Generation', async () => { |
6 | 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 | + // } |
7 | 79 | });
|
8 | 80 | });
|
0 commit comments