本文整理汇总了Java中fr.cryptohash.Shabal256.reset方法的典型用法代码示例。如果您正苦于以下问题:Java Shabal256.reset方法的具体用法?Java Shabal256.reset怎么用?Java Shabal256.reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fr.cryptohash.Shabal256
的用法示例。
在下文中一共展示了Shabal256.reset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MiningPlot
import fr.cryptohash.Shabal256; //导入方法依赖的package包/类
public MiningPlot(long addr, long nonce) {
ByteBuffer base_buffer = ByteBuffer.allocate(16);
base_buffer.putLong(addr);
base_buffer.putLong(nonce);
byte[] base = base_buffer.array();
Shabal256 md = new Shabal256();
byte[] gendata = new byte[PLOT_SIZE + base.length];
System.arraycopy(base, 0, gendata, PLOT_SIZE, base.length);
for(int i = PLOT_SIZE; i > 0; i -= HASH_SIZE) {
md.reset();
int len = PLOT_SIZE + base.length - i;
if(len > HASH_CAP) {
len = HASH_CAP;
}
md.update(gendata, i, len);
md.digest(gendata, i - HASH_SIZE, HASH_SIZE);
}
md.reset();
md.update(gendata);
byte[] finalhash = md.digest();
for(int i = 0; i < PLOT_SIZE; i++) {
data[i] = (byte) (gendata[i] ^ finalhash[i % HASH_SIZE]);
}
}
示例2: MineGenerator
import fr.cryptohash.Shabal256; //导入方法依赖的package包/类
private MineGenerator(String secretPhrase, Long nonce, byte[] publicKey, Long account) {
this.secretPhrase = secretPhrase;
this.publicKey = publicKey;
// need to store publicKey in addition to accountId, because the account may not have had its publicKey set yet
this.accountId = account;
this.nonce = nonce;
this.block = Rise.getBlockchain().getLastHDDBlock().getHeight() + 1;
// get new generation signature
Block lastBlock = Rise.getBlockchain().getLastHDDBlock();
byte[] lastGenSig = lastBlock.getGenerationSignature();
Long lastGenerator = lastBlock.getGeneratorId();
ByteBuffer gensigbuf = ByteBuffer.allocate(32 + 8);
gensigbuf.put(lastGenSig);
gensigbuf.putLong(lastGenerator);
Shabal256 md = new Shabal256();
md.update(gensigbuf.array());
byte[] newGenSig = md.digest();
// calculate deadline
MiningPlot plot = new MiningPlot(accountId, nonce);
ByteBuffer posbuf = ByteBuffer.allocate(32 + 8);
posbuf.put(newGenSig);
posbuf.putLong(lastBlock.getHeight() + 1);
md.reset();
md.update(posbuf.array());
BigInteger hashnum = new BigInteger(1, md.digest());
int scoopNum = hashnum.mod(BigInteger.valueOf(MiningPlot.SCOOPS_PER_PLOT)).intValue();
md.reset();
md.update(newGenSig);
plot.hashScoop(md, scoopNum);
byte[] hash = md.digest();
BigInteger hit = new BigInteger(1, new byte[] {hash[7], hash[6], hash[5], hash[4], hash[3], hash[2], hash[1], hash[0]});
deadline = hit.divide(BigInteger.valueOf(lastBlock.getBaseTarget()));
}
示例3: calculateResult
import fr.cryptohash.Shabal256; //导入方法依赖的package包/类
private BigInteger calculateResult(byte[] scoops, byte[] generationSignature, int nonce)
{
Shabal256 md = new Shabal256();
md.reset();
md.update(generationSignature);
md.update(scoops, nonce * MiningPlot.SCOOP_SIZE, MiningPlot.SCOOP_SIZE);
byte[] hash = md.digest();
return new BigInteger(1, new byte[]{hash[7], hash[6], hash[5], hash[4], hash[3], hash[2], hash[1], hash[0]});
}
示例4: MiningPlot
import fr.cryptohash.Shabal256; //导入方法依赖的package包/类
public MiningPlot(long addr, long nonce)
{
ByteBuffer base_buffer = ByteBuffer.allocate(16);
base_buffer.putLong(addr);
base_buffer.putLong(nonce);
byte[] base = base_buffer.array();
Shabal256 md = new Shabal256();
byte[] gendata = new byte[PLOT_SIZE + base.length];
System.arraycopy(base, 0, gendata, PLOT_SIZE, base.length);
for(int i = PLOT_SIZE; i > 0; i -= HASH_SIZE)
{
md.reset();
int len = PLOT_SIZE + base.length - i;
if(len > HASH_CAP)
{
len = HASH_CAP;
}
md.update(gendata, i, len);
md.digest(gendata, i - HASH_SIZE, HASH_SIZE);
}
md.reset();
md.update(gendata);
byte[] finalhash = md.digest();
for(int i = 0; i < PLOT_SIZE; i++)
{
data[i] = (byte) (gendata[i] ^ finalhash[i % HASH_SIZE]);
}
}