@lindorm-io/key-pair
TypeScript icon, indicating that this package has built-in type declarations

0.8.2 • Public • Published

@lindorm-io/key-pair

ECC and RSA key-pair tools for lindorm.io packages.

Installation

npm install --save @lindorm-io/key-pair

Usage

KeyPair

const eccData = await generateECCKeys();
const eccKeyPair = new KeyPair(eccData);
eccKeyPair.create();
eccKeyPair.expire();

const rsaData = await generateRSAKeys();
const rsaKeyPair = new KeyPair(rsaData);
rsaKeyPair.create();

Keystore

const keystore = new KeyStore({ keys: [eccKeyPair, rsaKeyPair] });

keystore.getCurrentKey(); // -> rsaKeyPair entity
keystore.getKey(eccKeyPair.id); // -> eccKeyPair entity

KeyPairHandler

const handler = new KeyPairHandler({
  algorithm: rsaKeyPair.algorithm,
  privateKey: rsaKeyPair.privateKey,
  publicKey: rsaKeyPair.publicKey,
});
const signature = handler.sign("input");

const verify = handler.verify("input", signature);
handler.assert("input", signature);

const privateSignature = handler.encrypt(SignMethod.PRIVATE_SIGN, "input");
const publicDecrypt = handler.decrypt(SignMethod.PRIVATE_SIGN, privateSignature);

const publicSignature = handler.encrypt(SignMethod.PUBLIC_SIGN, "input");
const privateDecrypt = handler.decrypt(SignMethod.PUBLIC_SIGN, publicSignature);

Readme

Keywords

none

Package Sidebar

Install

npm i @lindorm-io/key-pair

Weekly Downloads

19

Version

0.8.2

License

AGPL-3.0-or-later

Unpacked Size

117 kB

Total Files

128

Last publish

Collaborators

  • princejonn