Update dependencies/tests

This commit is contained in:
Nicholas Dudfield
2015-06-25 15:33:14 +07:00
parent b9c8fefc87
commit e2e0be689e
4 changed files with 113 additions and 80 deletions

View File

@@ -4,7 +4,6 @@
const util = require('util');
const elliptic = require('elliptic');
const bnjs = require('bn.js');
const hashjs = require('hash.js');
const codec = require('ripple-address-codec');
@@ -13,12 +12,10 @@ const secp256k1 = elliptic.ec('secp256k1');
const Ed25519 = elliptic.eddsa('ed25519');
const {
arrayToHex,
bytesToHex,
hasCachedProperty,
isVirtual,
Sha512,
toGenericArray
} = require('./utils');
/* ---------------------------------- ENUMS --------------------------------- */
@@ -58,7 +55,9 @@ function findk256Key(bytes, discrim) {
function compressedPoint(p) {
const x = p.getX().toArray();
const y = p.getY();
while (x.length < 32) x.unshift(0)
while (x.length < 32) {
x.unshift(0);
}
return [y.isEven() ? 0x02 : 0x03].concat(x);
}
@@ -92,7 +91,7 @@ function derivek256Secret(seed, opts={}) {
}
function createAccountId(pubKeyBytes) {
const hash256 = hashjs.sha256().update(pubKeyBytes).digest()
const hash256 = hashjs.sha256().update(pubKeyBytes).digest();
const hash160 = hashjs.ripemd160().update(hash256).digest();
return hash160;
}
@@ -192,7 +191,7 @@ Ed25519Pair.prototype.verify = function(message, signature) {
function Secp256k1Pair(key) {
KeyPair.apply(this, arguments);
this.type = KeyType.secp256k1;
this.key = key
this.key = key;
}
util.inherits(Secp256k1Pair, KeyPair);
@@ -249,4 +248,4 @@ module.exports = {
Ed25519Pair,
KeyType,
seedFromPhrase
}
};

View File

@@ -1,6 +1,6 @@
/* -------------------------------- REQUIRES -------------------------------- */
'use strict';
const bnjs = require('bn.js');
const BigNum = require('bn.js');
const hashjs = require('hash.js');
function isVirtual() {
@@ -11,7 +11,7 @@ function hasCachedProperty(obj, name, computer) {
const key = name + '__';
obj.prototype[name] = function() {
let cached = this[key];
if(cached === undefined) {
if (cached === undefined) {
cached = this[key] = computer.apply(this, arguments);
}
return cached;
@@ -36,25 +36,25 @@ function bytesToHex(bytes) {
}
class Sha512 {
constructor () {
constructor() {
this.hash = hashjs.sha512();
}
add (bytes) {
add(bytes) {
this.hash.update(bytes);
return this;
}
addU32 (i) {
addU32(i) {
return this.add([(i >>> 24) & 0xFF, (i >>> 16) & 0xFF,
(i >>> 8) & 0xFF, i & 0xFF ]);
(i >>> 8) & 0xFF, i & 0xFF]);
}
finish () {
finish() {
return this.hash.digest();
}
finish256 () {
finish256() {
return this.finish().slice(0, 32);
}
finish256BN () {
return new bnjs(this.finish256());
finish256BN() {
return new BigNum(this.finish256());
}
}
@@ -65,4 +65,4 @@ module.exports = {
isVirtual,
Sha512,
toGenericArray
}
};