Armory: use native multiplication in node and javascript implementation in browser
This commit is contained in:
parent
b5c1a7d387
commit
59ee476b96
|
@ -1,9 +1,8 @@
|
||||||
var Point = require('./browser/Point'),
|
var Point = require('./Point'),
|
||||||
Key = require('./Key'),
|
Key = require('./Key'),
|
||||||
buffertools = require('buffertools'),
|
buffertools = require('buffertools'),
|
||||||
sha256 = require('../util').sha256,
|
sha256 = require('../util').sha256,
|
||||||
twoSha256 = require('../util').twoSha256,
|
twoSha256 = require('../util').twoSha256;
|
||||||
BigInteger = require('../browser/vendor-bundle.js').BigInteger;
|
|
||||||
|
|
||||||
// TODO: use native modules instead of browser libraries
|
// TODO: use native modules instead of browser libraries
|
||||||
|
|
||||||
|
@ -26,10 +25,8 @@ Armory.prototype.generatePubKey = function () {
|
||||||
for (var i = 0; i < 32; i++)
|
for (var i = 0; i < 32; i++)
|
||||||
chainXor[i] ^= chainCode[i];
|
chainXor[i] ^= chainCode[i];
|
||||||
|
|
||||||
var A = new BigInteger(chainXor.toString('hex'), 16);
|
|
||||||
|
|
||||||
var pt = Point.fromUncompressedPubKey(pubKey);
|
var pt = Point.fromUncompressedPubKey(pubKey);
|
||||||
pt = Point.multiply(pt, A);
|
pt = Point.multiply(pt, chainXor);
|
||||||
|
|
||||||
var new_pubkey = pt.toUncompressedPubKey();
|
var new_pubkey = pt.toUncompressedPubKey();
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,9 @@ Point.add = function(p1, p2) {
|
||||||
return point;
|
return point;
|
||||||
};
|
};
|
||||||
|
|
||||||
Point.multiply = function(p1, A) {
|
Point.multiply = function(p1, x) {
|
||||||
|
var x = new BigInteger(x.toString('hex'), 16);
|
||||||
|
|
||||||
var ecparams = getSECCurveByName('secp256k1');
|
var ecparams = getSECCurveByName('secp256k1');
|
||||||
|
|
||||||
var p1xhex = p1.x.toBuffer({size: 32}).toString('hex');
|
var p1xhex = p1.x.toBuffer({size: 32}).toString('hex');
|
||||||
|
@ -59,7 +61,7 @@ Point.multiply = function(p1, A) {
|
||||||
var p1py = new ECFieldElementFp(ecparams.getCurve().getQ(), p1y);
|
var p1py = new ECFieldElementFp(ecparams.getCurve().getQ(), p1y);
|
||||||
var p1p = new ECPointFp(ecparams.getCurve(), p1px, p1py);
|
var p1p = new ECPointFp(ecparams.getCurve(), p1px, p1py);
|
||||||
|
|
||||||
var p = p1p.multiply(A);
|
var p = p1p.multiply(x);
|
||||||
|
|
||||||
var point = new Point();
|
var point = new Point();
|
||||||
var pointxbuf = new Buffer(p.getX().toBigInteger().toByteArrayUnsigned());
|
var pointxbuf = new Buffer(p.getX().toBigInteger().toByteArrayUnsigned());
|
||||||
|
|
Loading…
Reference in New Issue