Giter Club home page Giter Club logo

nano-signing's Introduction

nano-signing

A minimalistic public-key signing framework for TS / JS environments based on TweetNaCl and ED25519.


Installation

# Add to your dependencies using yarn
yarn add "nxtep-io/nano-signing";

# Or, using NPM
npm install "github:nxtep-io/nano-signing";

Getting Started


Key Pair Management

Generating a random keypair using the default encoding:

import { NanoSigning } from 'nano-signing';

const helper = new NanoSigning();

// Generates a random signer keypair
const signer = helper.keyPair();

// Dump keys as HEX encoded strings in the console
console.log({
  publicKey: signer.keyPair().publicKey(),
  secretKey: signer.keyPair().secretKey(),
});

// You can also access directly the base `nacl.SignKeyPair` instance
// with the original keys as Uint8Array buffers.
const raw = signer.raw();

Generating a keypair based on existing secretKey.

// Generates a random signer keypair
const signer = helper.keyPair({
  secretKey: myOwnSecret
});

Changing default encoding for the KeyPair.

Supported encodings: ascii, utf8, utf16le/ucs2, base64, binary/latin-1, and hex.

// Generates a random signer keypair
const signer = helper.keyPair({
  encoding: 'base64'
});

Further info at the Node.JS Buffer.toString() official documentation.


Data Signing

Generates simple data signature using a random key pair.

const originalData = { value: 123 }

// Generates a random signer keypair
const signer = helper.keyPair();

// Generates an encoded signature for input data
const signature = signer.sign(originalData, signer);

Validates existing signature against simple data signature using an existing public key.

// Validate candidate signature against the originalData and public key supplied
const signature = signer.verify(originalData, candidateSignature, publicKey);

API Docs

Check the published Github Page at https://nxtep-io.github.io/nano-signing/


License

The project is licensed under the MIT License.

nano-signing's People

Contributors

luiseduardobrito avatar

Stargazers

 avatar  avatar

Watchers

 avatar  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.