How to use noble-bls12-381 - 2 common examples

To help you get started, we’ve selected a few noble-bls12-381 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MetaMask / snaps-cli / examples / bls-signer / index.js View on Github external
async function getPubKey () {
  const PRIV_KEY = await wallet.getAppKey()
  return bls.getPublicKey(PRIV_KEY)
}
github MetaMask / snaps-cli / examples / bls-signer / index.js View on Github external
wallet.registerRpcMessageHandler(async (_originString, requestObject) => {
  switch (requestObject.method) {

    case 'getAccount':
      return getPubKey()

    case 'signMessage':
      const pubKey = await getPubKey()
      const data = requestObject.params[0]
      const approved = await promptUser(`Do you want to BLS sign ${data} with ${pubKey}?`)
      if (!approved) {
        throw rpcErrors.eth.unauthorized()
      }
      const PRIVATE_KEY = await wallet.getAppKey()
      const signature = await bls.sign(requestObject.params[0], PRIVATE_KEY, DOMAIN)
      return signature

    default:
      throw rpcErrors.methodNotFound(requestObject)
  }
})

noble-bls12-381

Fastest JS implementation of BLS12-381. Auditable, secure, 0-dependency aggregated signatures & pairings

MIT
Latest version published 3 years ago

Package Health Score

48 / 100
Full package analysis

Popular noble-bls12-381 functions