当前位置: 首页>>代码示例>>Java>>正文


Java Shabal256.reset方法代码示例

本文整理汇总了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]);
	}
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:25,代码来源:MiningPlot.java

示例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()));
  }
 
开发者ID:risex,项目名称:risecoin,代码行数:41,代码来源:MineGenerator.java

示例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]});
}
 
开发者ID:de-luxe,项目名称:burstcoin-jminer,代码行数:10,代码来源:OCLCheckerTask.java

示例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]);
  }
}
 
开发者ID:de-luxe,项目名称:burstcoin-jminer,代码行数:29,代码来源:MiningPlot.java


注:本文中的fr.cryptohash.Shabal256.reset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。