diff --git a/browser/bundle.js b/browser/bundle.js index 4067855..c27d1ba 100644 --- a/browser/bundle.js +++ b/browser/bundle.js @@ -3005,9 +3005,11 @@ module.exports = RpcClient; module.exports=require('tBM27q'); },{}],"tBM27q":[function(require,module,exports){ (function (Buffer){ +'use strict'; var VersionedData = require('../util/VersionedData'); var EncodedData = require('../util/EncodedData'); var util = require('util'); +var coinUtil = require('../util'); function SIN(type, payload) { if (typeof type != 'number') { @@ -3069,10 +3071,24 @@ SIN.prototype.validate = function() { if (this.data.length != 22) throw new Error('invalid data length'); }); }; + + +// create a SIN from a public key +SIN.fromPubKey = function(pubKey, type) { + if (!type) + type = SIN.SIN_EPHEM; + + if (!Buffer.isBuffer(pubKey) || (pubKey.length !== 33 && pubKey.length != 65)) + throw new Error('Invalid public key'); + + var hash = coinUtil.sha256ripe160(pubKey); + return new SIN(hash, type); +}; + module.exports = SIN; }).call(this,require("buffer").Buffer) -},{"../util/EncodedData":"eLfUFE","../util/VersionedData":"QLzNQg","buffer":91,"util":123}],"EyghZQ":[function(require,module,exports){ +},{"../util":181,"../util/EncodedData":"eLfUFE","../util/VersionedData":"QLzNQg","buffer":91,"util":123}],"EyghZQ":[function(require,module,exports){ var coinUtil = require('../util'); var timeUtil = require('../util/time'); var Key = require('./Key'); diff --git a/lib/SIN.js b/lib/SIN.js index 53889f0..a14cfe5 100644 --- a/lib/SIN.js +++ b/lib/SIN.js @@ -71,8 +71,8 @@ SIN.fromPubKey = function(pubKey, type) { if (!type) type = SIN.SIN_EPHEM; - if (!Buffer.isBuffer(pubKey) || pubKey.length !== 33) - throw new Error('Invalid public key' + pubKey.length); + if (!Buffer.isBuffer(pubKey) || (pubKey.length !== 33 && pubKey.length != 65)) + throw new Error('Invalid public key'); var hash = coinUtil.sha256ripe160(pubKey); return new SIN(hash, type); diff --git a/test/mocha.opts b/test/mocha.opts deleted file mode 100644 index e2bfcc5..0000000 --- a/test/mocha.opts +++ /dev/null @@ -1 +0,0 @@ ---ui qunit