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
940 B
TypeScript
Raw Normal View History

2020-11-30 18:01:13 +00:00
import {expect} from "chai";
import {IBls} from "../../src/interface";
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", () => {
expect(bls.SecretKey.fromHex(secretKey).toHex()).to.be.equal(secretKey);
});
it("should export secret key to hex string from non-prefixed hex", () => {
expect(bls.SecretKey.fromHex(secretKey).toHex()).to.be.equal(secretKey);
});
it("should not accept too short secret key", () => {
expect(() => bls.SecretKey.fromHex("0x2123")).to.throw();
});
});
}