Skip to content

Commit

Permalink
Bugfix and make jshint happy
Browse files Browse the repository at this point in the history
  • Loading branch information
th0br0 committed Oct 24, 2017
1 parent 5311af9 commit 3e3adf6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .jshintrc
@@ -0,0 +1,5 @@
{
"esnext": false,
"esversion": 5,
"asi": true
}
14 changes: 14 additions & 0 deletions lib/crypto/bundle/bundle.js
@@ -1,6 +1,7 @@
var Curl = require("../curl/curl"); var Curl = require("../curl/curl");
var Kerl = require("../kerl/kerl"); var Kerl = require("../kerl/kerl");
var Converter = require("../converter/converter"); var Converter = require("../converter/converter");
var tritAdd = require("../helpers/adder");


/** /**
* *
Expand Down Expand Up @@ -74,6 +75,9 @@ Bundle.prototype.addTrytes = function(signatureFragments) {
* *
**/ **/
Bundle.prototype.finalize = function() { Bundle.prototype.finalize = function() {
var validBundle = false;

while(!validBundle) {


var kerl = new Kerl(); var kerl = new Kerl();
kerl.initialize(); kerl.initialize();
Expand Down Expand Up @@ -112,6 +116,16 @@ Bundle.prototype.finalize = function() {


this.bundle[i].bundle = hash; this.bundle[i].bundle = hash;
} }

var normalizedHash = this.normalizedBundle(hash);
if(normalizedHash.indexOf(13 /* = M */) != -1) {
// Insecure bundle. Increment Tag and recompute bundle hash.
var increasedTag = tritAdd(Converter.trits(this.bundle[0].obsoleteTag), [1]);
this.bundle[0].obsoleteTag = Converter.trytes(increasedTag);
} else {
validBundle = true;
}
}
} }


/** /**
Expand Down

0 comments on commit 3e3adf6

Please sign in to comment.