This repository has been archived on 2023-04-09. You can view files and clone it, but cannot push or open issues or pull requests.
chainsafe-bls/test/unit/secretKey.test.ts

27 lines
929 B
TypeScript
Raw Permalink Normal View History

2020-11-30 18:01:13 +00:00
import {expect} from "chai";
2022-04-14 17:16:06 +00:00
import {IBls} from "../../src/types.js";
2020-11-30 18:01:13 +00:00
export function runSecretKeyTests(bls: IBls): void {
describe("SecretKey", () => {
it("should generate fromKeygen secret key", () => {
const secretKey1 = bls.SecretKey.fromKeygen();
const secretKey2 = bls.SecretKey.fromKeygen();
expect(secretKey1.toHex()).to.not.be.equal(secretKey2.toHex());
});
const secretKey = "0x07656fd676da43883d163f49566c72b9cbf0a5a294f26808c807700732456da7";
it("should export secret key to hex string", () => {
2022-10-07 16:13:50 +00:00
expect(bls.SecretKey.fromHex(secretKey).toHex()).equals(secretKey);
2020-11-30 18:01:13 +00:00
});
it("should export secret key to hex string from non-prefixed hex", () => {
2022-10-07 16:13:50 +00:00
expect(bls.SecretKey.fromHex(secretKey).toHex()).equals(secretKey);
2020-11-30 18:01:13 +00:00
});
it("should not accept too short secret key", () => {
expect(() => bls.SecretKey.fromHex("0x2123")).to.throw();
});
});
}