1.0.15 • Published 4 years ago

aioz-js v1.0.15

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

AIOZ Keytool

A javascript library allows to manipulate keys/wallet on browser.

Features

The code is ported from aiozd keytool, written in Javascript in order to:

  • generate new wallet
  • restore wallet from mnemonic
  • support generating ECDH key from private key JSON
  • generate shared key of ECDH

Installation

    npm install aioz-js

And use in code:

    const aioz = require('aioz-js');

Usage

Generate private/public key with a random 24-word mnemonic, encrypted with or without a passphrase:

    const key1 = aioz.newKey("12345678");   // encrypt private key with passphrase
    const key2 = aioz.newKey();   // no encryption for private key 

Recover wallet and private/public keys from 24-word mnemonic:

    const recoveredKeys = aioz.recover("pair that turn trash leave problem snap fork innocent symptom case please party stomach fly mirror panel stand possible decade soul strike poem feature");

From aioz key, create corresponding ECDH key:

    const ecdh1 = aioz.generateEcdhFromKeytool(key1.priv_key);
    const ecdh2 = aioz.generateEcdhFromKeytool(key2.priv_key);

Exchange public key to get shared key between 2 partners:

    const shared12 = ecdh1.derive(ecdh2.pub);
    const shared21 = ecdh2.derive(ecdh1.pub);
    console.log(shared12.toString(16);  // this should be the same as shared21
    console.log(shared21.toString(16);

Two partners can derive shared key using other's public key under JSON format

    const sharedKeyUsingJSON = ecdh1.deriveFromJSON("{\"type\":\"tendermint/PubKeySecp256k1\",\"value\":\"A6g+QlHU9iFpJNeAEtmCOD0wTw3jfDRpiHn4ARe8MGBz\"}");
1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.11

4 years ago

1.0.12

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago