Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"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});
var Key = require('bindings')('KeyModule').Key;
module.exports = Key;
"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);
};
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});
var Key = require('bindings')('KeyModule').Key;
module.exports = Key;
var Key = require('bindings')('KeyModule').Key;
module.exports = Key;