From 523d54717162079d018889a09468e9f0910ae4c3 Mon Sep 17 00:00:00 2001 From: dapplion Date: Thu, 19 Nov 2020 14:50:08 +0000 Subject: [PATCH] Add Keypair test --- src/herumi/privateKey.ts | 4 ---- test/unit/keypair.test.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 test/unit/keypair.test.ts diff --git a/src/herumi/privateKey.ts b/src/herumi/privateKey.ts index a1ba0d9..c791d2f 100644 --- a/src/herumi/privateKey.ts +++ b/src/herumi/privateKey.ts @@ -31,10 +31,6 @@ export class PrivateKey { return this.fromBytes(sk); } - getValue(): SecretKeyType { - return this.value; - } - signMessage(message: Uint8Array): Signature { return new Signature(this.value.sign(message)); } diff --git a/test/unit/keypair.test.ts b/test/unit/keypair.test.ts new file mode 100644 index 0000000..4884217 --- /dev/null +++ b/test/unit/keypair.test.ts @@ -0,0 +1,27 @@ +import {expect} from "chai"; +import {forEachImplementation} from "../switch"; + +forEachImplementation((bls) => { + describe("Keypair", () => { + it("should create from private and public key", () => { + const sk = bls.PrivateKey.fromKeygen(); + const sk2 = bls.PrivateKey.fromKeygen(); + const pk = sk.toPublicKey(); + + const keypair = new bls.Keypair(sk as any, pk as any); + + expect(keypair.publicKey).to.be.equal(pk); + expect(keypair.privateKey).to.be.equal(sk); + expect(keypair.privateKey).to.not.be.equal(sk2); + }); + + it("should create from PrivateKey", () => { + const sk = bls.PrivateKey.fromKeygen(); + const pk = sk.toPublicKey(); + + const keypair = new bls.Keypair(sk as any); + + expect(keypair.publicKey.toHex()).to.equal(pk.toHex()); + }); + }); +});