npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@zippie/vault-api

v1.2.18

Published

Zippie Vault API

Downloads

76

Readme

Zippie Vault API

Zippie Vault API is the main application interface into Zippie Vault

Zippie Vault API provides a simple interface for interacting with Zippie Vault derived cryptographic keys allowing cryptographic signing and encryption of arbitrary data.

Currently the only cryptographic algorithm implemented is Elliptic Curve secp256k1 suitable for Bitcoin and Ethereum Wallets.

Key Paths

Key paths are to be given in the following format of maximum 16bit integer numbers m/99999/99999/...

Each key is derived from the given path in a hierarchial manner where the parent path is used to generate all children keys eg. m/0/1/2/3; Key 2 is generated by Key 1, which is generated by Key 0 m/0/5; Key 5 is also generated by Key 0

Dependencies

  • Node.js
  • NPM

Install from npm repository

npm install @zippie/vault-api

Building

npm install

Run Tests

Mocha unit tests need to be run through a web browser

npm run test

Example

API Usage examples are available in example.js and can be run with the following command:

npm run example

API

Imports

import Vault from '@zippie/vault-api';
import * as shajs from 'sha.js';

Init Vault

The init call is the entry point to the zippie vault, this call will check for an existing vault service worker and redirect the user to onboarding if required

const vault = new Vault({vault_uri: 'https://vault.dev.zippie.org'})
vault.setup()
.then(_ => vault.signin())
.then(
  result => {
    console.log("Zippie Vault Ready & Signed In");
  })
.catch(
  error => {
    console.error("Init error:", error)
  })

Key Info

Get public key information for a particular vault path. These will be particular to your dapp, and you can have as many as you like eg. 'm/0', 'm/1', 'm/1/1' .etc

vault.secp256k1.keyInfo('m/0')
  .then(result => {
    console.log("keyInfo: " + result.pubkey);
  }
)

Sign

Cryptographically sign a piece of data. The data needs to be summarised in a digest like sha256

vault.secp256k1.sign(
  'm/0',
  shajs('sha256').update("data to sign goes here").digest()
)
.then(signedOutput => {
  console.log("sign: " + signedOutput.signature);
})

Encrypt

Encrypt a piece of data The data needs to be encoded into a hex string before sending

vault.secp256k1.encrypt(publicKey, Buffer.from("message to encrypt").toString('hex'))
  .then(encryptedMessage => {
    console.log("encrypt: " + encryptedMessage.ciphertext);
  }
)

Decrypt

Reverse the encryption process to get back your message

vault.secp256k1.decrypt('m/0', encryptedMessage)
  .then(message => {
    console.log("decrypt: " + Buffer.from(message, 'hex').toString());
  }
)

License

BSD-3-Clause