2020-11-19 13:22:41 +00:00
|
|
|
import {PublicKey, PrivateKey, initBLS, destroy} from "../../src";
|
2020-11-05 20:55:25 +00:00
|
|
|
import {expect} from "chai";
|
2019-11-27 20:58:41 +00:00
|
|
|
|
|
|
|
describe("public key", function () {
|
|
|
|
before(async function f() {
|
2020-11-19 13:22:41 +00:00
|
|
|
await initBLS();
|
2019-11-27 20:58:41 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
after(function () {
|
|
|
|
destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("from hex", function () {
|
|
|
|
const publicKey =
|
2020-11-04 17:40:36 +00:00
|
|
|
"0xb6f21199594b56d77670564bf422cb331d5281ca2c1f9a45588a56881d8287ef8619efa6456d6cd2ef61306aa5b21311";
|
2020-11-19 00:23:34 +00:00
|
|
|
expect(PublicKey.fromHex(publicKey).toHex()).to.be.equal(publicKey);
|
2019-11-27 20:58:41 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("from bytes", function () {
|
|
|
|
const publicKey =
|
2020-11-04 17:40:36 +00:00
|
|
|
"b6f21199594b56d77670564bf422cb331d5281ca2c1f9a45588a56881d8287ef8619efa6456d6cd2ef61306aa5b21311";
|
2020-11-19 00:23:34 +00:00
|
|
|
expect(PublicKey.fromBytes(Buffer.from(publicKey, "hex")).toHex()).to.be.equal(`0x${publicKey}`);
|
2019-11-27 20:58:41 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("from private key", function () {
|
2020-11-19 00:23:34 +00:00
|
|
|
PrivateKey.fromKeygen().toPublicKey();
|
2019-11-27 20:58:41 +00:00
|
|
|
});
|
2020-11-04 17:40:36 +00:00
|
|
|
});
|