
com.itranswarp.eth.smt.TreeInfo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of eth-smt Show documentation
Show all versions of eth-smt Show documentation
A sparse merkle tree implementation for Ethereum.
package com.itranswarp.eth.smt;
class TreeInfo {
public static int HEIGHT = 160;
private static final byte[][] DEFAULT_HASHES;
static {
DEFAULT_HASHES = new byte[HEIGHT + 1][];
DEFAULT_HASHES[HEIGHT] = SmtUtils.keccak(new byte[0]);
for (int i = HEIGHT - 1; i >= 0; i--) {
DEFAULT_HASHES[i] = SmtUtils.keccak(DEFAULT_HASHES[i + 1], DEFAULT_HASHES[i + 1]);
}
}
public static byte[] getDefaultHash(int height) {
assert height >= 0 && height <= HEIGHT : "invalid height: " + height;
return DEFAULT_HASHES[height];
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy