How to use the ecurve.getCurveByName function in ecurve

To help you get started, we’ve selected a few ecurve 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 bitcoinjs / bitcoinjs-lib / test / ecpubkey.js View on Github external
it('uses the secp256k1 curve by default', function () {
    var secp256k1 = ecurve.getCurveByName('secp256k1')

    for (var property in secp256k1) {
      // FIXME: circular structures in ecurve
      if (property === 'G') continue
      if (property === 'infinity') continue

      var actual = ECPubKey.curve[property]
      var expected = secp256k1[property]

      assert.deepEqual(actual, expected)
    }
  })
github bitcoinjs / bitcoinjs-lib / test / eckey.js View on Github external
it('uses the secp256k1 curve by default', function () {
    var secp256k1 = ecurve.getCurveByName('secp256k1')

    for (var property in secp256k1) {
      // FIXME: circular structures in ecurve
      if (property === 'G') continue
      if (property === 'infinity') continue

      var actual = ECKey.curve[property]
      var expected = secp256k1[property]

      assert.deepEqual(actual, expected)
    }
  })
github bitcoinjs / bitcoinjs-lib / src / ecpubkey.js View on Github external
var crypto = require('./crypto')
var ecdsa = require('./ecdsa')
var typeForce = require('typeforce')
var networks = require('./networks')

var Address = require('./address')

var ecurve = require('ecurve')
var secp256k1 = ecurve.getCurveByName('secp256k1')

function ECPubKey (Q, compressed) {
  if (compressed === undefined) {
    compressed = true
  }

  typeForce('Point', Q)
  typeForce('Boolean', compressed)

  this.compressed = compressed
  this.Q = Q
}

// Constants
ECPubKey.curve = secp256k1
github bitcoinjs / bitcoinjs-lib / src / eckey.js View on Github external
var assert = require('assert')
var base58check = require('bs58check')
var ecdsa = require('./ecdsa')
var networks = require('./networks')
var randomBytes = require('randombytes')
var typeForce = require('typeforce')

var BigInteger = require('bigi')
var ECPubKey = require('./ecpubkey')

var ecurve = require('ecurve')
var secp256k1 = ecurve.getCurveByName('secp256k1')

function ECKey (d, compressed) {
  assert(d.signum() > 0, 'Private key must be greater than 0')
  assert(d.compareTo(ECKey.curve.n) < 0, 'Private key must be less than the curve order')

  var Q = ECKey.curve.G.multiply(d)

  this.d = d
  this.pub = new ECPubKey(Q, compressed)
}

// Constants
ECKey.curve = secp256k1

// Static constructors
ECKey.fromWIF = function (string) {
github codius-deprecated / codius-engine / test / lib.crypto.js View on Github external
it('(secp256k1) should generate a valid secp256k1 keypair', function(){
      var keypair = crypto.deriveKeypair(node_crypto.randomBytes(32), node_crypto.randomBytes(32));
      var curve = ecurve.getCurveByName('secp256k1');
      expect(curve.validate(ecurve.Point.decodeFrom(curve, new Buffer(keypair.public, 'hex')))).to.be.true;
    });
github ArkEcosystem / core / tests / unit / model / transaction.spec.js View on Github external
const verifyEcdsaNonMalleability = (transaction) => {
  var ecurve = require('ecurve')
  var secp256k1 = ecurve.getCurveByName('secp256k1')
  var n = secp256k1.n
  var hash = arkjs.crypto.getHash(transaction, true, true)

  var signatureBuffer = Buffer.from(transaction.signature, 'hex')
  var senderPublicKeyBuffer = Buffer.from(transaction.senderPublicKey, 'hex')
  var ecpair = arkjs.ECPair.fromPublicKeyBuffer(senderPublicKeyBuffer, transaction.network)
  var ecsignature = arkjs.ECSignature.fromDER(signatureBuffer)
  var ecs2 = arkjs.ECSignature.fromDER(signatureBuffer)
  ecs2.s = n.subtract(ecs2.s)
  var res = ecpair.verify(hash, ecsignature)
  var res2 = ecpair.verify(hash, ecs2)
  return res === true && res2 === false
}
github ArkEcosystem / core / packages / client / __tests__ / models / transaction.spec.js View on Github external
const verifyEcdsaNonMalleability = (transaction) => {
  const ecurve = require('ecurve')
  const secp256k1 = ecurve.getCurveByName('secp256k1')
  const n = secp256k1.n
  const hash = cryptoBuilder.getHash(transaction, true, true)

  const signatureBuffer = Buffer.from(transaction.signature, 'hex')
  const senderPublicKeyBuffer = Buffer.from(transaction.senderPublicKey, 'hex')
  const ecpair = ECPair.fromPublicKeyBuffer(senderPublicKeyBuffer, transaction.network)
  const ecsignature = ECSignature.fromDER(signatureBuffer)
  const ecs2 = ECSignature.fromDER(signatureBuffer)
  ecs2.s = n.subtract(ecs2.s)
  const res = ecpair.verify(hash, ecsignature)
  const res2 = ecpair.verify(hash, ecs2)
  return res === true && res2 === false
}
github kingswisdom / SteemMessenger / view / js / crypto / steem-js / auth / ecc / src / key_public.js View on Github external
var BigInteger = require('bigi');
var ecurve = require('ecurve');
var secp256k1 = ecurve.getCurveByName('secp256k1');
BigInteger = require('bigi');
var base58 = require('bs58');
var hash = require('./hash');
var assert = require('assert');

var G = secp256k1.G
var n = secp256k1.n

class PublicKey {

    /** @param {ecurve.Point} public key */
    constructor(Q) { this.Q = Q; }

    static fromBinary(bin) {
        return PublicKey.fromBuffer(new Buffer(bin, 'binary'));
    }
github bitshares / bitshares-ui / plasma / libraries / @graphene / ecc / src / key_public.js View on Github external
var BigInteger = require('bigi');
var ecurve = require('ecurve');
var secp256k1 = ecurve.getCurveByName('secp256k1');
BigInteger = require('bigi');
var base58 = require('bs58');
var hash = require('./hash');
var config = require('../config');
var assert = require('assert');

var G = secp256k1.G
var n = secp256k1.n

class PublicKey {

    /** @param {ecurve.Point} public key */
    constructor(Q) { this.Q = Q; }
    
    static fromBinary(bin) {
        return PublicKey.fromBuffer(new Buffer(bin, 'binary'));
github steemit / steem-js / src / auth / ecc / src / key_public.js View on Github external
var BigInteger = require('bigi');
var ecurve = require('ecurve');
var secp256k1 = ecurve.getCurveByName('secp256k1');
BigInteger = require('bigi');
var base58 = require('bs58');
var hash = require('./hash');
var config = require('../../../config');
var assert = require('assert');

var G = secp256k1.G
var n = secp256k1.n

class PublicKey {

    /** @param {ecurve.Point} public key */
    constructor(Q) { this.Q = Q; }

    static fromBinary(bin) {
        return PublicKey.fromBuffer(new Buffer(bin, 'binary'));

ecurve

Elliptic curve cryptography

MIT
Latest version published 7 years ago

Package Health Score

56 / 100
Full package analysis

Popular ecurve functions