How to use the bindings.Key function in bindings

To help you get started, we’ve selected a few bindings 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 the-bitcoin-token / bitcoin-source / lib / Point.js View on Github external
"use strict";

var bignum = require('bignum');
var CPPKey = require('bindings')('KeyModule').Key;
var assert = require('assert');
var Point = require('./common/Point');

Point.add = function(p1, p2) {
  var u1 = p1.toUncompressedPubKey();
  var u2 = p2.toUncompressedPubKey();
  var pubKey = CPPKey.addUncompressed(u1, u2);
  return Point.fromUncompressedPubKey(pubKey);
};

Point.multiply = function(p1, x) {
  if (Buffer.isBuffer(x) && x.length !== 32)
    throw new Error('if x is a buffer, it must be 32 bytes')
  var u1 = p1.toUncompressedPubKey();
  if (typeof x === 'number' || typeof x === 'string')
    x = (new bignum(x)).toBuffer({size: 32});
github the-bitcoin-token / bitcoin-source / lib / node / Key.js View on Github external
var Key = require('bindings')('KeyModule').Key;

module.exports = Key;
github the-bitcoin-token / bitcoin-source / lib / node / Point.js View on Github external
"use strict";

var imports = require('soop').imports();
var bignum = imports.bignum || require('../Bignum');
var CPPKey = imports.CPPKey || require('bindings')('KeyModule').Key;
var assert = require('assert');

//a point on the secp256k1 curve
//x and y are bignums
var Point = function(x, y) {
  this.x = x;
  this.y = y;
};

Point.add = function(p1, p2) {
  var u1 = p1.toUncompressedPubKey();
  var u2 = p2.toUncompressedPubKey();
  var pubKey = CPPKey.addUncompressed(u1, u2);
  return Point.fromUncompressedPubKey(pubKey);
};
github the-bitcoin-token / bitcoin-source / lib / Key.js View on Github external
var Key = require('bindings')('KeyModule').Key;
var CommonKey = require('./common/Key');
var bignum = require('bignum');
var Point = require('./Point');
var coinUtil = require('../util');

for (var i in CommonKey) {
  if (CommonKey.hasOwnProperty(i))
    Key[i] = CommonKey[i];
}

Key.sign = function(hash, priv, k) {
  if (k)
    throw new Error('Deterministic k not supported in node');

  var key = new Key();
  key.private = priv.toBuffer({size: 32});
github bitpay / bitcore-mnemonic / lib / node / Key.js View on Github external
var Key = require('bindings')('KeyModule').Key;

module.exports = Key;
github bitpay / bitcore / lib / node / Key.js View on Github external
var Key = require('bindings')('KeyModule').Key;

module.exports = Key;