0.3.10 • Published 4 years ago

@meey-sdk-js/crypto v0.3.10

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

Multi-purpose javascript crypto library for meey

npm readthedocs

It is used by Meey dApps to manage keys and sign transactions offline.

Features:

  • Key generation and importing
  • Hashing
  • Signing
  • Simple AES-GCM encryption

How to use

npm install --save @meey-sdk-js/crypto

Transaction signing

import { createIdentity, signTransaction, hashTransaction } from '@meey-sdk-js/crypto';

async () => {
    const identity = createIdentity();
    const tx = {
        nonce: 1,
        from: identity.address,
        to: identity.address,
        amount: '100 aer',
        payload: '',
    };
    tx.sign = await signTransaction(tx, identity.keyPair);
    tx.hash = await hashTransaction(tx);
    console.log(JSON.stringify(tx));
}()

Arbitrary message signing

import { createIdentity, signMessage, verifySignature, publicKeyFromAddress } from '@meey-sdk-js/crypto';

async () => {
    const identity = createIdentity();
    const msg = Buffer.from('hello');
    const signature = await signMessage(msg, identity.keyPair);
    const pubkey = publicKeyFromAddress(identity.address);
    const check = await verifySignature(msg, pubkey, signature);
    console.log(check);
}()