From b02214613503a85450b1b099454566e7ede5ad3c Mon Sep 17 00:00:00 2001 From: Ho Nguyen Pham Date: Thu, 2 Nov 2023 16:24:59 +0100 Subject: [PATCH] update Committee structs and export default types of Dynamic Array --- src/dkg/Committee.ts | 20 +++++++++++++++++++- src/utils/index.ts | 20 ++++++++++++++++++-- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/dkg/Committee.ts b/src/dkg/Committee.ts index ff58346..dbdffd5 100644 --- a/src/dkg/Committee.ts +++ b/src/dkg/Committee.ts @@ -44,6 +44,12 @@ type Round2Data = { class Round1Contribution extends Struct({ C: GroupDynamicArray, }) { + static empty(): Round1Contribution { + return new Round1Contribution({ + C: new GroupDynamicArray(), + }); + } + toFields(): Field[] { return this.C.toFields(); } @@ -52,11 +58,17 @@ class Round1Contribution extends Struct({ return Poseidon.hash(this.toFields()); } } - class Round2Contribution extends Struct({ c: ScalarDynamicArray, U: GroupDynamicArray, }) { + static empty(): Round2Contribution { + return new Round2Contribution({ + c: new ScalarDynamicArray(), + U: new GroupDynamicArray(), + }); + } + toFields(): Field[] { return this.c.toFields().concat(this.U.toFields()); } @@ -69,6 +81,12 @@ class Round2Contribution extends Struct({ class TallyContribution extends Struct({ D: GroupDynamicArray, }) { + static empty(): TallyContribution { + return new TallyContribution({ + D: new GroupDynamicArray(), + }); + } + toFields(): Field[] { return this.D.toFields(); } diff --git a/src/utils/index.ts b/src/utils/index.ts index f7671ed..7e60a06 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,5 +1,21 @@ import { CustomScalar } from './CustomScalar.js'; -import { DynamicArray } from './DynamicArray.js'; import * as Elgamal from './Elgamal.js'; +import { + DynamicArray, + BoolDynamicArray, + FieldDynamicArray, + GroupDynamicArray, + ScalarDynamicArray, + PublicKeyDynamicArray, +} from './DynamicArray.js'; -export { CustomScalar, DynamicArray, Elgamal }; +export { + CustomScalar, + Elgamal, + DynamicArray, + BoolDynamicArray, + FieldDynamicArray, + GroupDynamicArray, + ScalarDynamicArray, + PublicKeyDynamicArray, +};