
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@vegaprotocol/crypto
Advanced tools
@vegaprotocol/crypto
⚠️ Under active development ⚠️
Crypto operations for Vega supporting Node.js and Browsers
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)
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
.
See algorithm.md and test-vectors.
FAQs
Crypto operations for Vega supporting Node.js and Browsers
The npm package @vegaprotocol/crypto receives a total of 1 weekly downloads. As such, @vegaprotocol/crypto popularity was classified as not popular.
We found that @vegaprotocol/crypto demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.