New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@vegaprotocol/crypto

Package Overview
Dependencies
Maintainers
5
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vegaprotocol/crypto

Crypto operations for Vega supporting Node.js and Browsers

  • 0.12.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
5
Created
Source

@vegaprotocol/crypto

⚠️ Under active development ⚠️

Crypto operations for Vega supporting Node.js and Browsers

Usage

This module supports both CommonJS and ES Modules:

const { VegaWallet, HARDENED } = require('@vegaprotocol/crypto')

VegaWallet.fromMnemonic('...').then(async wallet => {
  const keys = await wallet.keyPair(HARDENED + 0)

  const msg = Buffer.from('Hello world!')
  const signature = await keys.sign(msg)
})
import { VegaWallet, HARDENED } from '@vegaprotocol/crypto'

const wallet = await VegaWallet.fromMnemonic('...')
const keys = await wallet.keyPair(HARDENED + 0)

const msg = Buffer.from('Hello world!')
const signature = await keys.sign(msg)

API

Note: All APIs are async. In some cases they will run sync, eg in Node.js where loading WASM is sync, or where crypto routines are sync, but everything is kept async as a lowest common denominator between browser APIs and future hardware wallet support.

const wallet = await VegaWallet.fromMnemonic(mnemonic)

Derive a new SLIP-10 VegaWallet from a BIP-0039 mnemonic. Note that the mnemonic is not validated before key derivation.

const seed = await VegaWallet.deriveSeed(mnemonic)

Derive a seed from a BIP-0039 mnemonic. In combination with VegaWallet.fromSeed this is equivalent to VegaWallet.fromMnemonic. Note that the mnemonic is not validated before key derivation.

const wallet = await VegaWallet.fromSeed(seed)

Derive a new SLIP-10 VegaWallet from a seed.

const kp = await wallet.keyPair(index)

Generate a new key pair at index, under the Vega specific subtree.

const { name, version } = kp.algorithm

This contains name and version detailing the version used by the instantiated keyPair. Note if this changes in the future other "builder" methods will be exposed to derive newer versions.

const sig = await kp.sign(msg, [chainId])

Sign msg with key pair kp for optional chainId.

const isValid = await kp.verify(sig, msg, [chainId])

Verify sig is valid for msg under key pair kp for optional chainId.

Spec

See algorithm.md and test-vectors.

License

MIT

FAQs

Package last updated on 03 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc