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/src/keypair.ts

32 lines
663 B
TypeScript
Raw Normal View History

2019-08-05 15:48:26 +00:00
import {PublicKey} from "./publicKey";
import {PrivateKey} from "./privateKey";
export class Keypair {
private _publicKey: PublicKey;
private _privateKey: PrivateKey;
public constructor(privateKey: PrivateKey, publicKey?: PublicKey) {
this._privateKey = privateKey;
if(!publicKey) {
this._publicKey = PublicKey.fromPrivateKey(this._privateKey);
} else {
this._publicKey = publicKey;
}
}
public get publicKey(): PublicKey {
return this._publicKey;
}
public get privateKey(): PrivateKey {
return this._privateKey;
}
public static generate(): Keypair {
return new Keypair(PrivateKey.random());
}
}