General purpose library for private key storage and key management.

Usage no npm install needed!

<script type="module">
  import snaxfoundationSnaxjsKeygen from 'https://cdn.skypack.dev/@snaxfoundation/snaxjs-keygen';




The purpose of this library is for managing keys in local storage. This is designed to derive and cache keys but also needs a password manager to store a "root" key. This library does not have secure or password protected storage. It does however figure out permission hierarchies and is configurable enough to only store keys you feel are safe to store.

General purpose cryptography is found in snaxjs-ecc library. Hierarchical deterministic key generation uses PrivateKey.getChildKey in snaxjs-ecc.


let {Keystore, Keygen} = require('snaxjs-keygen')
Snax = require('snaxjs')

sessionConfig = {
  timeoutInMin: 30,
  uriRules: {
    'owner' : '/account_recovery',
    'active': '/(transfer|contracts)',
    'active/**': '/producers'

keystore = Keystore('myaccount', sessionConfig)
snax = Snax.Testnet({keyProvider: keystore.keyProvider})

Keygen.generateMasterKeys().then(keys => {
  // create blockchain account called 'myaccount'

  snax.getAccount('myaccount').then(account => {
      parent: keys.masterPrivateKey,
      accountPermissions: account.permissions


See ./API


let {Keystore, Keygen} = require('./src')

Use Node v8+ (updates package-lock.json)


git clone https://github.com/SNAX/snaxjs-keygen.git
cd snaxjs-keygen
npm install
npm run build
# builds: ./dist/snaxjs-keygen.js
<script src="snaxjs-keygen.js"></script>

Runtime Environment

Node 6+ and browser (browserify, webpack, etc)

Built with React Native in mind, create an issue if you find a bug.