Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"esnext": false,
"esversion": 5,
"asi": true
}
14 changes: 14 additions & 0 deletions lib/crypto/bundle/bundle.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var Curl = require("../curl/curl");
var Kerl = require("../kerl/kerl");
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() {
var validBundle = false;

while(!validBundle) {

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

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.