@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