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

@cmdcode/signer

v1.4.7

Published

Signer, Wallet and other tools for cryptography.

Downloads

89

Readme

Signer

Provides Seed, Signer, and Wallet tools for handling Bitcoin transactions.

Note: This README is outdated. Updated readme coming soon!

Seed API

import { Seed } from '@cmdcode/signer'

interface Seed {
  // Generate random seed (256 bits).
  gen_random () => Buff
  // Generate random seed words (12 / 24).
  gen_words (size :? 12 | 24) => string
  // Import a seed from a password-encrypted payload.
  from_encrypted (
    payload : Bytes,
    secret  : Bytes
  ) => Promise<Buff>
  // Import a seed from a list of seed words.
  from_words (
    words     : string | string[],
    password ?: string
  ) => Buff
  // Export a seed as a password-encrypted payload.
  to_encrypted (
    seed   : Bytes,
    secret : Bytes
  ) => Promise<Buff>
}

Signer API

import { KeyPair, Signer } from '@cmdcode/signer'

class Signer {
  // Generate a signer from a random seed.
  static generate () => Signer
  // Import a signer from a password-encrypted payload.
  static from_encrypted (
    payload: string,
    secret: string
  ) => Promise<Signer>
  // Import a signer from a seed phrase.
  static from_words (
    words: string | string[], 
    pass?: string
  ) => Signer
  // Create a new Signer class.
  constructor (seed: Bytes) => Signer
  // Get the sha256 hash of the pubkey.
  get id     () => string
  // Get the pubkey of the signer.
  get pubkey () => string
  // Get a BIP32 wallet using the signer's internal seed.
  get wallet () => Wallet
  // Get a Diffe-Hellman shared secret from another pubkey.
  ecdh (pubkey: Bytes) => Buff
  // Export the signer's seed as a password-encrypted payload.
  export_seed (secret: string) => Promise<string>
  // Export the signer's seed as an encrypted nip-04 nostr note.
  export_note (pubkey: string) => Promise<SignedEvent>
  // Generate a pubnonce for a given message.
  gen_nonce (
    message  : Bytes, 
    options ?: SignOptions
  ) => Buff
  // Generate an HMAC signature for a given message.
  hmac (message: Bytes) => Buff
  // Create a partial signature from a musig context object.
  musign (
    context  : MusigContext, 
    auxdata  : Bytes, 
    options ?: SignOptions
  ) => Buff
  // Create a compact digital proof for a given content string.
  notarize (
    content : string, 
    params  : Params
  ): Promise<string>
  // Sign a message using BIP340-schnorr scheme.
  sign (
    message  : Bytes,
    options ?: SignOptions
  ) => string
}

interface SignOptions {
  aux         ?: Bytes | null // Add aux data to nonce generation.
  nonce_tweak ?: Bytes        // Add a tweak to the nonce value.
  key_tweak   ?: Bytes        // Add a tweak to the key value.
}

Wallet API

import { ExtendedKey, Wallet, MasterWallet } from '@cmdcode/signer'

/**
 * Base class method for defining an extended key.
 */

class ExtendedKey {
  constructor(hd : HDKey)
  
  get hd()     : HDKey  // Get internal HDKey object.
  get index()  : number // Get index value of current key.
  get pubkey() : string // Get pubkey value of current key.
  get xpub()   : string // Get xpub value of current key.

  // Get an address for the curent key.
  address (network?: Network) => string
}

/**
 * Wallet class for creating and managing accounts.
 */

class Wallet extends ExtendedKey {
  // Import a wallet from a raw seed.
  static from_seed  (seed: Bytes) => Wallet
  // Import a wallet from BIP39 seed words.
  static from_words (words: string | string[]) => Wallet
  // Import a wallet from an xpub.
  static from_xpub  (xpub: string) => Wallet
  // Create a wallet from an HDKey object.
  constructor (hdkey: HDKey)
  // Check if a given account exists within the wallet.
  has_account (extkey: string | HDKey) => boolean
  // Get an account key at the given account (index) number.
  get_account (acct: number, index?: number) => KeyRing
  // Generate a new account with a random index.
  new_account () => KeyRing
}