@mey-sdk-js/crypto
TypeScript icon, indicating that this package has built-in type declarations

0.3.12 • Public • Published

Multi-purpose javascript crypto library for mey

npm readthedocs

It is used by MeyCoin 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 @mey-sdk-js/crypto

Transaction signing

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

async () => {
    const identity = createIdentity();
    const tx = {
        nonce: 1,
        from: identity.address,
        to: identity.address,
        amount: '100 gas',
        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 '@mey-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);
}()

Readme

Keywords

none

Package Sidebar

Install

npm i @mey-sdk-js/crypto

Weekly Downloads

1

Version

0.3.12

License

MIT

Unpacked Size

2.19 MB

Total Files

28

Last publish

Collaborators

  • giactan