api configuration
This commit is contained in:
parent
9b8502b90a
commit
7c7cfc332a
|
@ -96,7 +96,7 @@ export class G1point {
|
||||||
const x = new ctx.FP(point.getX());
|
const x = new ctx.FP(point.getX());
|
||||||
const yneg = new ctx.FP(point.getY());
|
const yneg = new ctx.FP(point.getY());
|
||||||
yneg.neg();
|
yneg.neg();
|
||||||
point.setxy(x.redc(), yneg.redc())
|
point.setxy(x.redc(), yneg.redc());
|
||||||
}
|
}
|
||||||
|
|
||||||
return new G1point(point);
|
return new G1point(point);
|
||||||
|
@ -115,7 +115,7 @@ export class G1point {
|
||||||
random.randomBuffer(FP_POINT_LENGTH),
|
random.randomBuffer(FP_POINT_LENGTH),
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
)
|
);
|
||||||
} while (ecp.is_infinity());
|
} while (ecp.is_infinity());
|
||||||
return new G1point(ecp);
|
return new G1point(ecp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import {BIG} from "@chainsafe/milagro-crypto-js/src/big";
|
import {BIG} from "@chainsafe/milagro-crypto-js/src/big";
|
||||||
import {ECP2} from "@chainsafe/milagro-crypto-js/src/ecp2";
|
import {ECP2} from "@chainsafe/milagro-crypto-js/src/ecp2";
|
||||||
import {BLSDomain, bytes32, bytes96} from "../types";
|
import {BLSDomain, bytes32, bytes96} from "../types";
|
||||||
import { sha256 } from 'js-sha256';
|
import {sha256} from 'js-sha256';
|
||||||
import ctx from "../ctx";
|
import ctx from "../ctx";
|
||||||
import * as random from "secure-random";
|
import * as random from "secure-random";
|
||||||
import {calculateYFlag, getModulus, padLeft} from "./utils";
|
import {calculateYFlag, getModulus, padLeft} from "./utils";
|
||||||
|
@ -89,7 +89,7 @@ export class G2point {
|
||||||
xRe.add(one);
|
xRe.add(one);
|
||||||
xRe.norm();
|
xRe.norm();
|
||||||
point = new ctx.ECP2();
|
point = new ctx.ECP2();
|
||||||
point.setx(new ctx.FP2(xRe, xIm))
|
point.setx(new ctx.FP2(xRe, xIm));
|
||||||
}
|
}
|
||||||
return new G2point(G2point.scaleWithCofactor(G2point.normaliseY(point)));
|
return new G2point(G2point.scaleWithCofactor(G2point.normaliseY(point)));
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ export class G2point {
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
);
|
||||||
} while (point.is_infinity());
|
} while (point.is_infinity());
|
||||||
return new G2point(point);
|
return new G2point(point);
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,7 @@ export class G2point {
|
||||||
) {
|
) {
|
||||||
const newPoint = new ctx.ECP2();
|
const newPoint = new ctx.ECP2();
|
||||||
newPoint.setxy(point.getX(), yNeg);
|
newPoint.setxy(point.getX(), yNeg);
|
||||||
return newPoint
|
return newPoint;
|
||||||
} else {
|
} else {
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ export function getModulus(): BIG {
|
||||||
'hex'
|
'hex'
|
||||||
),
|
),
|
||||||
0
|
0
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function calculateYFlag(yIm: BIG): boolean {
|
export function calculateYFlag(yIm: BIG): boolean {
|
||||||
|
|
|
@ -49,7 +49,7 @@ function sign(secretKey: BLSSecretKey, messageHash: bytes32, domain: BLSDomain):
|
||||||
*/
|
*/
|
||||||
function aggregateSignatures(signatures: BLSSignature[]): BLSSignature {
|
function aggregateSignatures(signatures: BLSSignature[]): BLSSignature {
|
||||||
return signatures.map((signature): Signature => {
|
return signatures.map((signature): Signature => {
|
||||||
return Signature.fromCompressedBytes(signature)
|
return Signature.fromCompressedBytes(signature);
|
||||||
}).reduce((previousValue, currentValue): Signature => {
|
}).reduce((previousValue, currentValue): Signature => {
|
||||||
return previousValue.add(currentValue);
|
return previousValue.add(currentValue);
|
||||||
}).toBytesCompressed();
|
}).toBytesCompressed();
|
||||||
|
@ -64,7 +64,7 @@ function aggregatePubkeys(publicKeys: BLSPubkey[]): BLSPubkey {
|
||||||
return new G1point(new ctx.ECP()).toBytesCompressed();
|
return new G1point(new ctx.ECP()).toBytesCompressed();
|
||||||
}
|
}
|
||||||
return publicKeys.map((publicKey): G1point => {
|
return publicKeys.map((publicKey): G1point => {
|
||||||
return G1point.fromBytesCompressed(publicKey)
|
return G1point.fromBytesCompressed(publicKey);
|
||||||
}).reduce((previousValue, currentValue): G1point => {
|
}).reduce((previousValue, currentValue): G1point => {
|
||||||
return previousValue.add(currentValue);
|
return previousValue.add(currentValue);
|
||||||
}).toBytesCompressed();
|
}).toBytesCompressed();
|
||||||
|
@ -129,4 +129,4 @@ export default {
|
||||||
aggregatePubkeys,
|
aggregatePubkeys,
|
||||||
verify,
|
verify,
|
||||||
verifyMultiple
|
verifyMultiple
|
||||||
}
|
};
|
||||||
|
|
|
@ -48,7 +48,7 @@ export class PrivateKey {
|
||||||
),
|
),
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static fromHexString(value: string): PrivateKey {
|
public static fromHexString(value: string): PrivateKey {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import bls from "./index"
|
import bls from "./index";
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
(function (window: any) {
|
(function (window: any) {
|
||||||
window.bls = bls
|
window.bls = bls;
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
})(window);
|
})(window);
|
||||||
|
|
Reference in New Issue