/** * This method returns the index of the next Treehash instance that should * receive an update * * @param layer the layer of the GMSS tree * @return index of the treehash instance that should get the update */ private int getMinTreehashIndex(int layer) { int minTreehash = -1; for (int h = 0; h < heightOfTrees[layer] - K[layer]; h++) { if (currentTreehash[layer][h].wasInitialized() && !currentTreehash[layer][h].wasFinished()) { if (minTreehash == -1) { minTreehash = h; } else if (currentTreehash[layer][h].getLowestNodeHeight() < currentTreehash[layer][minTreehash] .getLowestNodeHeight()) { minTreehash = h; } } } return minTreehash; }
/** * returns a String representation of the treehash instance */ public String toString() { String out = "Treehash : "; for (int i = 0; i < 6 + tailLength; i++) { out = out + this.getStatInt()[i] + " "; } for (int i = 0; i < 3 + tailLength; i++) { if (this.getStatByte()[i] != null) { out = out + new String(Hex.encode((this.getStatByte()[i]))) + " "; } else { out = out + "null "; } } out = out + " " + this.messDigestTree.getDigestSize(); return out; }
/** * This method sets the first node stored in the treehash instance itself * * @param hash */ public void setFirstNode(byte[] hash) { if (!this.isInitialized) { this.initialize(); } this.firstNode = hash; this.firstNodeHeight = this.maxHeight; this.isFinished = true; }
currentTreehash[layer][i].updateNextSeed(gmssRandom); if (currentTreehash[layer][i].wasFinished()) .getFirstNode(), 0, currentAuthPaths[layer][i], 0, mdLength); currentTreehash[layer][i].destroy(); currentTreehash[layer][i].initialize(); System.arraycopy( this.currentTreehash[layer][minTreehash] .getSeedActive(), 0, seed, 0, mdLength); byte[] seed2 = gmssRandom.nextSeed(seed); WinternitzOTSignature ots = new WinternitzOTSignature( seed2, this.digestProvider.get(), this.otsIndex[layer]); byte[] leaf = ots.getPublicKey(); currentTreehash[layer][minTreehash].update( this.gmssRandom, leaf);
.update(this.gmssRandom, leaf); .wasFinished()) .getSeedActive(); this.upperTreehashLeaf[layer - 1] = new GMSSLeaf( this.digestProvider.get(), this.otsIndex[layer - 1], t, seed);
/** * initializes the seeds for the treehashs of the tree precomputed by this * class * * @param seed the initial seed for treehash: seedNext * @param index the height of the treehash */ public void initializeTreehashSeed(byte[] seed, int index) { treehash[index].initializeSeed(seed); }
for (int i = 0; i < this.heightOfTree - this.K; i++) this.treehash[i] = new Treehash(sharedStack, i, this.digestProvider.get());
treehash[0].setFirstNode(leaf); treehash[helpHeight].setFirstNode(help);
currentTreehash[layer][i].updateNextSeed(gmssRandom); if (currentTreehash[layer][i].wasFinished()) .getFirstNode(), 0, currentAuthPaths[layer][i], 0, mdLength); currentTreehash[layer][i].destroy(); currentTreehash[layer][i].initialize(); System.arraycopy( this.currentTreehash[layer][minTreehash] .getSeedActive(), 0, seed, 0, mdLength); byte[] seed2 = gmssRandom.nextSeed(seed); WinternitzOTSignature ots = new WinternitzOTSignature( seed2, this.digestProvider.get(), this.otsIndex[layer]); byte[] leaf = ots.getPublicKey(); currentTreehash[layer][minTreehash].update( this.gmssRandom, leaf);
.update(this.gmssRandom, leaf); .wasFinished()) .getSeedActive(); this.upperTreehashLeaf[layer - 1] = new GMSSLeaf( this.digestProvider.get(), this.otsIndex[layer - 1], t, seed);
/** * initializes the seeds for the treehashs of the tree precomputed by this * class * * @param seed the initial seed for treehash: seedNext * @param index the height of the treehash */ public void initializeTreehashSeed(byte[] seed, int index) { treehash[index].initializeSeed(seed); }
for (int i = 0; i < this.heightOfTree - this.K; i++) this.treehash[i] = new Treehash(sharedStack, i, this.digestProvider.get());
treehash[0].setFirstNode(leaf); treehash[helpHeight].setFirstNode(help);
/** * This method returns the index of the next Treehash instance that should * receive an update * * @param layer the layer of the GMSS tree * @return index of the treehash instance that should get the update */ private int getMinTreehashIndex(int layer) { int minTreehash = -1; for (int h = 0; h < heightOfTrees[layer] - K[layer]; h++) { if (currentTreehash[layer][h].wasInitialized() && !currentTreehash[layer][h].wasFinished()) { if (minTreehash == -1) { minTreehash = h; } else if (currentTreehash[layer][h].getLowestNodeHeight() < currentTreehash[layer][minTreehash] .getLowestNodeHeight()) { minTreehash = h; } } } return minTreehash; }
/** * returns a String representation of the treehash instance */ public String toString() { String out = "Treehash : "; for (int i = 0; i < 6 + tailLength; i++) { out = out + this.getStatInt()[i] + " "; } for (int i = 0; i < 3 + tailLength; i++) { if (this.getStatByte()[i] != null) { out = out + new String(Hex.encode((this.getStatByte()[i]))) + " "; } else { out = out + "null "; } } out = out + " " + this.messDigestTree.getDigestSize(); return out; }
/** * This method sets the first node stored in the treehash instance itself * * @param hash */ public void setFirstNode(byte[] hash) { if (!this.isInitialized) { this.initialize(); } this.firstNode = hash; this.firstNodeHeight = this.maxHeight; this.isFinished = true; }
int tailLength = currentTreehash[i][j].getStatInt()[1]; .getStatByte()[0])); seqOfByte.add(new DEROctetString(currentTreehash[i][j] .getStatByte()[1])); seqOfByte.add(new DEROctetString(currentTreehash[i][j] .getStatByte()[2])); for (int k = 0; k < tailLength; k++) .getStatByte()[3 + k])); currentTreehash[i][j].getStatInt()[0])); seqOfInt.add(new ASN1Integer(tailLength)); seqOfInt.add(new ASN1Integer( currentTreehash[i][j].getStatInt()[2])); seqOfInt.add(new ASN1Integer( currentTreehash[i][j].getStatInt()[3])); seqOfInt.add(new ASN1Integer( currentTreehash[i][j].getStatInt()[4])); seqOfInt.add(new ASN1Integer( currentTreehash[i][j].getStatInt()[5])); for (int k = 0; k < tailLength; k++) .getStatInt()[6 + k])); int tailLength = nextTreehash[i][j].getStatInt()[1]; .getStatByte()[0])); seqOfByte.add(new DEROctetString(nextTreehash[i][j]
int tailLength = currentTreehash[i][j].getStatInt()[1]; .getStatByte()[0])); seqOfByte.add(new DEROctetString(currentTreehash[i][j] .getStatByte()[1])); seqOfByte.add(new DEROctetString(currentTreehash[i][j] .getStatByte()[2])); for (int k = 0; k < tailLength; k++) .getStatByte()[3 + k])); currentTreehash[i][j].getStatInt()[0])); seqOfInt.add(new ASN1Integer(tailLength)); seqOfInt.add(new ASN1Integer( currentTreehash[i][j].getStatInt()[2])); seqOfInt.add(new ASN1Integer( currentTreehash[i][j].getStatInt()[3])); seqOfInt.add(new ASN1Integer( currentTreehash[i][j].getStatInt()[4])); seqOfInt.add(new ASN1Integer( currentTreehash[i][j].getStatInt()[5])); for (int k = 0; k < tailLength; k++) .getStatInt()[6 + k])); int tailLength = nextTreehash[i][j].getStatInt()[1]; .getStatByte()[0])); seqOfByte.add(new DEROctetString(nextTreehash[i][j]