@vocdoni/wallets
TypeScript icon, indicating that this package has built-in type declarations

1.16.0 • Public • Published

@vocdoni/wallets

@vocdoni/wallets contains wallets helpers for the dvote-js library

Installation

Use npm to install @vocdoni/wallets.

npm install @vocdoni/wallets

Usage

Metamask

import { SignerUtil } from "@vocdoni/wallets"

const signer = SignerUtil.fromInjectedWeb3()
// wallet.signMessage(...)

// See ethers.js > Signer

Ethereum

import { WalletUtil } from "@vocdoni/wallets"

const wallet = WalletUtil.fromSeededPassphrase("my-passphrase", hexSeed)
// wallet.signMessage(...)

// See ethers.js > Wallet

Baby JubJub

import { WalletBabyJub } from "@vocdoni/wallets"
import { Random } from "@vocdoni/common"

const wallet1 = WalletBabyJub.fromProcessCredentials(loginKey, processId, chosenSecret)

const seed = Random.getHex()
const wallet2 = WalletBabyJub.fromHexSeed(seed)

const privK = "123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0"
const wallet3 = new WalletBabyJub(privK)

// sign
const msg = Buffer.from("my message", "utf8")
const sign = wallet1.sign(msg)

// verify
const valid = WalletBabyJub.verify(msg, sig, wallet1.publicKey)
// => true

Testing

To execute library tests just run

npm run test

Readme

Keywords

none

Package Sidebar

Install

npm i @vocdoni/wallets

Weekly Downloads

0

Version

1.16.0

License

GPL-3.0-or-later

Unpacked Size

50.9 kB

Total Files

27

Last publish

Collaborators

  • jordipainan
  • elboletaire
  • emmdim
  • marcvelmer