How to use the supercop.js.sign function in supercop

To help you get started, we’ve selected a few supercop 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 nomic-io / js-tendermint / test / verify.js View on Github external
let precommits = []
  let time = new Date(header.time).getTime()
  for (let i = 0; i < validators.length; i++) {
    let validator = validators[i]
    let precommit = {
      validator_address: validator.address,
      validator_index: String(i),
      height: header.height,
      round: '0',
      timestamp: new Date(time + Math.random() * 1000).toISOString(),
      type: 2,
      block_id: blockId
    }
    let signBytes = Buffer.from(getVoteSignBytes(header.chain_id, precommit))
    let pub = Buffer.from(validator.pub_key.value, 'base64')
    let signature = ed25519.sign(signBytes, pub, validator.priv_key)
    precommit.signature = {
      type: 'tendermint/SignatureEd25519',
      value: signature.toString('base64')
    }
    precommits.push(precommit)
  }
  return {
    block_id: blockId,
    precommits
  }
}
github hyperledger / iroha-javascript / src / irohajs.ts View on Github external
sign (msg: string): string {
    const message = new Buffer(sha3_256(msg));
    return supercop.sign(message, this.publicKey, this.privateKey).toString("base64");
  }
}
github OwenRay / Remote-MediaServer / backend / modules / sharing / EDHT.js View on Github external
        sign: buf => ed.sign(buf, this.keypair.publicKey, this.keypair.secretKey),
      };
github vacuumlabs / adalite / withNode / utils.js View on Github external
exports.sign = function(message, extendedPrivateKey) {
  const privKey = extendedPrivateKey.getSecretKey() //extendedPrivateKey.substr(0, 128);
  const pubKey = extendedPrivateKey.getPublicKey() //substr(128, 64);

  const messageToSign = new Buffer(message, 'hex')

  return ed25519
    .sign(messageToSign, new Buffer(pubKey, 'hex'), new Buffer(privKey, 'hex'))
    .toString('hex')
}
github hyperledger / iroha-javascript / src / irohajs.ts View on Github external
export function sign (opt: { publicKey: string, privateKey: string, message: string }): string {
  const publicKey = new Buffer(opt.publicKey, "base64");
  const privateKey = new Buffer(opt.privateKey, "base64");
  const sha3Message = new Buffer(sha3_256(opt.message));

  const sig = supercop.sign(
    sha3Message,
    publicKey,
    privateKey
  ).toString("base64");

  return sig;
}
github nomic-io / shea / bin / cmd.js View on Github external
function getSignature(req) {
    return ed
      .sign(
        Buffer.isBuffer(req.body) ? req.body : Buffer.from(stringify(req.body)),
        req.keypair.publicKey,
        req.keypair.secretKey
      )
      .toString('base64')
  }
  expressApp.post('/sign', ensureKey, (req, res) => {
github vacuumlabs / adalite / utils.js View on Github external
exports.sign = function(message, extendedPrivateKey) {
  const privKey = extendedPrivateKey.getSecretKey() //extendedPrivateKey.substr(0, 128);
  const pubKey = extendedPrivateKey.getPublicKey() //substr(128, 64);

  const messageToSign = new Buffer(message, 'hex')

  return ed25519
    .sign(messageToSign, new Buffer(pubKey, 'hex'), new Buffer(privKey, 'hex'))
    .toString('hex')
}

supercop

cross-compiled javascript implementation of ed25519 based on supercop-ref10

MIT
Latest version published 11 months ago

Package Health Score

56 / 100
Full package analysis