Code Monkey home page Code Monkey logo

password-master's Introduction

Password Master

Password Master is a pure local(offline) personal password manager app writing in Nodejs, it is leveraged by Hierarchical Deterministic(HD) Wallet.

Password Master supports two way of usage:

  1. integrate as a npm dependency
  2. CLI tool

Usage for Integrate as npm dependency

import

    const HDVault = require('password-master');

Master Key Derivation

    const yourMasterKeyPassword = "xxxxxx"; // This is the password to encrypt your master key
    const mnemonicWords = HDVault.mnemonicUtil.mnemonicGenerator24();
    const masterKey = new HDVault.MasterKeySeedManager(mnemonicWords, yourMasterKeyPassword);
    const {encryptedMasterKeySeed} = masterKey.getMasterKeySeedInfo(); // You need to store this encryptedMasterKeySeed for later usage

Oneledger Key Derivation

    const derivedKeyData = {
        keyType: "OLT",
        keyIndex: 0, // key index
        password: yourMasterKeyPassword,
        encryptedMasterKeySeed: encryptedMasterKeySeed
    };
    const {response} = await HDVault.derivedKeyManager.deriveNewKeyPair(derivedKeyData).catch(error => {
        // handler error here
    });
    const {keyIndex, address, publicKey} = response; // Address is the Oneledger address derived based on key index, publicKey is the public key associated to this address

Sign tx with Oneledger Key

    const signData = {
        message: rawTx, // Base64 encoded Oneledger rawTx
        keyType: "OLT",
        keyIndex: 0, // To sign with Oneledger address derived before, please using the same key index here
        password: yourMasterKeyPassword,
        encryptedMasterKeySeed: encryptedMasterKeySeed
    };
    const {response} = await HDVault.derivedKeyManager.signTx(signData).catch(error => {
        // handler error here
    });
    const {signature} = response; // Get Oneledger tx signature

Use the signature with publicKey to broadcast Oneledger tx.
Please note, for broadcast, the publicKey and signature have to be generated by the same key index.

password-master's People

Contributors

freddyli7 avatar okovalov avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.