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

@neon-exchange/nash-protocol-legacy

v0.1.3

Published

TypeScript implementation of Nash crypto routines

Downloads

343

Readme

nash-protocol

Implementation of Nash cryptographic routines.

Documentation available here

Getting started

yarn install
yarn build
yarn test

Usage Summary

Onboarding

The Nash Protocol contains functions necessary to create, setup, and authenticate into an account.

Account creation

This step registers a new user with Nash's Central Accounts System.

  1. A user signs up for an account and provides a password.
  2. hashPassword() should be called to hash the password, and getHKDFKeysFromPassword() should be called on the hashed password to get an authentication key and encryption key.
  3. The authentication key is sent to Nash's Central Accounts System in lieu of the original password, and is what is used hereafter for authentication. The encryption key is never sent to Nash, and must be computed on the fly from the user's password by the client.

Account setup

This step creates blockchain wallets for a user.

  1. getEntropy() is called to generate a secret key.
  2. secretKeyToMnemonic() is called on the secret key to provide a user's mnemonic. The user should persist this and never share this value.
  3. mnemonicToMasterSeed() is called on the mnemonic to create the master seed, which is the seed value for BIP-44 HD wallet generation.
  4. generateWallet is called using the master seed for all supported coin types.
  5. Wallet public keys are sent to Nash. Private keys are never sent to Nash, and should be computed on the fly by the client.
  6. The secret key is encrypted with encryptSecretKey(), which produces an encrypted secret key AEAD object. This is sent to Nash.

Authentication

  1. User provides their password.
  2. getHKDFKeysFromPassword() is used to get the authentication key and encryption key.
  3. The authentication key is sent to Nash, which responds with the encrypted secret key AEAD object and some wallet metadata (public keys and chain heights).
  4. The client calls initialize() with the encrypted secret key AEAD object, encryption key, wallet metadata, and some Nash Matching Engine market and asset data to receive a config.
  5. This config contains all necessary values to interact with the Nash Matching Engine, including the ability to sign payloads needed for operations such as order placement, viewing private account information, asset transfers, and staking.

Glossary

Secret values are never sent to Nash. Values that are visible to Nash are. A combination of secret values and values accessible by Nash are needed for all sensitive operations. Both types of values are sensitive and should be carefully guarded.

  • Authentication key: Derived from password. Used to authentcate into Nash's systems. Visible to Nash.
  • BIP-39: Protocol for generating master seed from private key.
  • BIP-44: Protocol for generating wallet addresses from master seed.
  • Chain: an ID for each blockchain we want to generate a private key for. Constant. Nash uses the coin types as defined by BIP044.
  • Encrypted secret key: The secret key encrypted via the encryption key via AEAD. Cannot be decrypted without the encryption key. Visible to Nash.
  • Encryption key: Derived from password. Used to encrypt the private key for server side storage. Secret.
  • Master seed: Value used to generate wallets. Derived from mnemonic. Secret.
  • Mnemonic: A n-word phrase generated from the secret key using a wordlist. Can be used along with passphrase to (re)generate the master seed. Secret.
  • Password: User's login credential. Used to generate encryption key and auth key via HKDF. Secret.
  • Secret key: A random value. Abstracted into the mnemonic for better user experience. We use this as the "master key" -- the ultimate password from which everything is derived, that should be protected at all costs. Secret. (An encrypted version is visible to Nash.)

Notes

External wallet keys

We will NOT support the user supplying their own wallet keys. While users will control their own wallets, we will generate the wallets for them. This is partially because we want wallets to be deterministically derivable from the master seed.

References