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 🙏

© 2025 – Pkg Stats / Ryan Hefner

demo-keys

v0.5.3

Published

Key management for Democracy, a minimalist framework for distributed countries

Downloads

172

Readme

Democracy.js Keys

The package demo-keys of the Democracy.js framework manages key management, especially the enciphering, deciphering, storage, and retrieval of Ethereum private keys. It also includes transaction signing, which is the chief activity of a private key.

We make use of the keythereum project from ethereumjs and ethjs-signer.

Account

The key concept in demo-keys is an account, an Immutable Map which contains the following members

  • privateBuffer
  • publicBuffer
  • addressBuffer
  • ivBuffer
  • saltBuffer

Wallet

Just like a wallet is a container for your credit cards and physical ID cards (not your metal house/car keys, the analogy is not perfect), a wallet in demo-keys is a top-level manager for your Ethereum private keys.

A wallet is a singleton and exists only in-memory. You only ever import and use one in any program.

const { wallet } = require('demo-keys')

It manages four basic functions:

  • Enciphering an account to a geth-compatible JSON form with a String password. Also known as "locking."
  • Deciphering an account from a geth-compatible JSON form with a String password Also known as "unlocking."
  • Storing the JSON form
  • Retrieving the JSON form

It also contains three convenience methods, which can be done in other ways but are included here in an easy-to-use format.

  • Transferring ETH from one account (possibly a test account) to another
  • Creating a transaction signer (a signerEth) that uses a single account and its funds to sign and broadcast transactions to an Ethereum network.

A wallet contains the following state:

Initialization

Before using a wallet for the first time, it should be initialized. This connects it to a key-value store, possibly remotely, where all persistent data is stored.

Accounts Map

accountsMap: `0x`-prefixed Ethereum address strings => ( account | enciphered JSON )

The accounts map associates to an Ethereum address one of two objects: a deciphered / unlocked account ready for tx signing, or an enciphered / locked JSON that has been retrieved / created and is waiting to be unlocked.

Signers Map

The deciphered account form is the one that is needed to sign transactions and spend funds. A signerEth is a web3 network object (such as provided by ethjs or web3 although the actual methods provided vary)

signersMap: `0x`-prefixed Ethereum address strings => a signerEth

The signers map associated to an Ethereum address a signerEth that uses that address (and its private key if it's unlocked) to sign transactions. The signerEth is passed to deployers, for example, instead of the default configured eth from getNetwork(), which will only allow test accounts.

Usage Notes

The typical workflow in using a wallet is to first initialize it, telling it to connect to the configured key-value store.

await wallet.init({ autoConfig, unlockSeconds })
await wallet.loadEncryptedAccount({ address })
await wallet.unlockEncryptedAccount({ address })
const { address, password, signerEth } = await createSignerEth({
  autoCreate: boolean,
  address: string,
  password: string,
})