2020-11-05 20:55:25 +00:00
|
|
|
import {expect} from "chai";
|
2020-11-20 19:03:17 +00:00
|
|
|
import {IBls} from "../../src/interface";
|
2019-08-05 15:48:26 +00:00
|
|
|
|
2020-11-20 19:35:32 +00:00
|
|
|
export function runPrivateKeyTests(bls: IBls): void {
|
2020-11-19 14:41:45 +00:00
|
|
|
describe("PrivateKey", () => {
|
|
|
|
it("should generate fromKeygen private key", () => {
|
|
|
|
const privateKey1 = bls.PrivateKey.fromKeygen();
|
|
|
|
const privateKey2 = bls.PrivateKey.fromKeygen();
|
|
|
|
expect(privateKey1.toHex()).to.not.be.equal(privateKey2.toHex());
|
|
|
|
});
|
2019-11-27 18:21:37 +00:00
|
|
|
|
2020-11-05 20:55:25 +00:00
|
|
|
const privateKey = "0x07656fd676da43883d163f49566c72b9cbf0a5a294f26808c807700732456da7";
|
2019-11-27 18:21:37 +00:00
|
|
|
|
2020-11-19 14:41:45 +00:00
|
|
|
it("should export private key to hex string", () => {
|
|
|
|
expect(bls.PrivateKey.fromHex(privateKey).toHex()).to.be.equal(privateKey);
|
|
|
|
});
|
2019-11-27 18:21:37 +00:00
|
|
|
|
2020-11-19 14:41:45 +00:00
|
|
|
it("should export private key to hex string from non-prefixed hex", () => {
|
2020-11-28 19:52:32 +00:00
|
|
|
expect(bls.PrivateKey.fromHex(privateKey).toHex()).to.be.equal(privateKey);
|
2020-11-19 14:41:45 +00:00
|
|
|
});
|
2020-11-04 17:40:36 +00:00
|
|
|
|
2020-11-19 14:41:45 +00:00
|
|
|
it("should not accept too short private key", () => {
|
|
|
|
expect(() => bls.PrivateKey.fromHex("0x2123")).to.throw();
|
|
|
|
});
|
2019-11-27 18:21:37 +00:00
|
|
|
});
|
2020-11-20 19:03:17 +00:00
|
|
|
}
|