bubichain-encryption-nodejs

4.0.1 • Public • Published

bubichain-encryption-nodejs

bubichain-encryption Sub module of bubichain-sdk-js.

bubichain-encryption-nodejs Installation

npm install bubichain-encryption-nodejs --save

bubichain-encryption-nodejs Test

npm test

bubichain-encryption-nodejs Usage

'use strict';

const encryption = require('bubichain-encryption-nodejs');

const KeyPair = encryption.keypair;
const signature = encryption.signature;
const keystore = encryption.keystore;

let kp = new KeyPair();
// Get encPrivateKey, encPublicKey, address
let encPrivateKey = kp.getEncPrivateKey();
let encPublicKey = kp.getEncPublicKey();
let address = kp.getAddress();


console.log('============= bof: ==============');
console.log(`EncPrivateKey is : ${encPrivateKey}`);
console.log(`EncPublicKey is : ${encPublicKey}`);
console.log(`Address hash is : ${address}`);
console.log('============= eof: ==============');

// Get keypair
let keypair = KeyPair.getKeyPair();

// Get encPublicKey
let encPublicKey = KeyPair.getEncPublicKey(encPrivateKey);

// Get address
let address = KeyPair.getAddress(encPublicKey);

// check encPrivateKey
KeyPair.checkEncPrivateKey(encPrivateKey);

// check encPublicKey
KeyPair.checkEncPublicKey(encPublicKey);

// check address
KeyPair.checkAddress(address);

// signature sign and verify
let sign = signature.sign('test', encPrivateKey);
let verify = signature.verify('test', sign, encPublicKey);

// keystore
keystore.encrypt(encPrivateKey, 'test', function(encData) {
  keystore.decrypt(encData, 'test', function(descData) {
    console.log(descData);
  });
});

License

MIT

Package Sidebar

Install

npm i bubichain-encryption-nodejs

Weekly Downloads

0

Version

4.0.1

License

ISC

Unpacked Size

198 kB

Total Files

12

Last publish

Collaborators

  • hunan36