Skip to content

Commit e14e37a

Browse files
committed
BLS: fix types
1 parent d0d7b62 commit e14e37a

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/abstract/bls.ts

+17-13
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,19 @@ export type SignatureCoder<Fp2> = {
4343
toHex(point: ProjPointType<Fp2>): string;
4444
};
4545

46+
type Fp2Bls<Fp, Fp2> = IField<Fp2> & {
47+
reim: (num: Fp2) => { re: Fp; im: Fp };
48+
multiplyByB: (num: Fp2) => Fp2;
49+
frobeniusMap(num: Fp2, power: number): Fp2;
50+
};
51+
52+
type Fp12Bls<Fp2, Fp12> = IField<Fp12> & {
53+
frobeniusMap(num: Fp12, power: number): Fp12;
54+
multiplyBy014(num: Fp12, o0: Fp2, o1: Fp2, o4: Fp2): Fp12;
55+
conjugate(num: Fp12): Fp12;
56+
finalExponentiate(num: Fp12): Fp12;
57+
};
58+
4659
export type CurveType<Fp, Fp2, Fp6, Fp12> = {
4760
G1: Omit<CurvePointsType<Fp>, 'n'> & {
4861
ShortSignature: SignatureCoder<Fp>;
@@ -57,18 +70,9 @@ export type CurveType<Fp, Fp2, Fp6, Fp12> = {
5770
fields: {
5871
Fp: IField<Fp>;
5972
Fr: IField<bigint>;
60-
Fp2: IField<Fp2> & {
61-
reim: (num: Fp2) => { re: bigint; im: bigint };
62-
multiplyByB: (num: Fp2) => Fp2;
63-
frobeniusMap(num: Fp2, power: number): Fp2;
64-
};
73+
Fp2: Fp2Bls<Fp, Fp2>;
6574
Fp6: IField<Fp6>;
66-
Fp12: IField<Fp12> & {
67-
frobeniusMap(num: Fp12, power: number): Fp12;
68-
multiplyBy014(num: Fp12, o0: Fp2, o1: Fp2, o4: Fp2): Fp12;
69-
conjugate(num: Fp12): Fp12;
70-
finalExponentiate(num: Fp12): Fp12;
71-
};
75+
Fp12: Fp12Bls<Fp2, Fp12>;
7276
};
7377
params: {
7478
x: bigint;
@@ -134,9 +138,9 @@ export type CurveFn<Fp, Fp2, Fp6, Fp12> = {
134138
};
135139
fields: {
136140
Fp: IField<Fp>;
137-
Fp2: IField<Fp2>;
141+
Fp2: Fp2Bls<Fp, Fp2>;
138142
Fp6: IField<Fp6>;
139-
Fp12: IField<Fp12>;
143+
Fp12: Fp12Bls<Fp2, Fp12>;
140144
Fr: IField<bigint>;
141145
};
142146
utils: {

0 commit comments

Comments
 (0)