Skip to content

Commit

Permalink
update Committee structs and export default types of Dynamic Array
Browse files Browse the repository at this point in the history
  • Loading branch information
Ho Nguyen Pham authored and Ho Nguyen Pham committed Nov 2, 2023
1 parent 9b7f40e commit b022146
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
20 changes: 19 additions & 1 deletion src/dkg/Committee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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());
}
Expand All @@ -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();
}
Expand Down
20 changes: 18 additions & 2 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -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,
};

0 comments on commit b022146

Please sign in to comment.