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


Java Shabal256类代码示例

本文整理汇总了Java中fr.cryptohash.Shabal256的典型用法代码示例。如果您正苦于以下问题:Java Shabal256类的具体用法?Java Shabal256怎么用?Java Shabal256使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Shabal256类属于fr.cryptohash包,在下文中一共展示了Shabal256类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processRequest

import fr.cryptohash.Shabal256; //导入依赖的package包/类
@Override
JSONStreamAware processRequest(HttpServletRequest req) {
	JSONObject response = new JSONObject();
	
	response.put("height", Long.toString(Nxt.getBlockchain().getHeight() + 1));
	
	Block lastBlock = Nxt.getBlockchain().getLastBlock();
	byte[] lastGenSig = lastBlock.getGenerationSignature();
	Long lastGenerator = lastBlock.getGeneratorId();
	
	ByteBuffer buf = ByteBuffer.allocate(32 + 8);
	buf.put(lastGenSig);
	buf.putLong(lastGenerator);
	
	Shabal256 md = new Shabal256();
	md.update(buf.array());
	byte[] newGenSig = md.digest();
	
	response.put("generationSignature", Convert.toHexString(newGenSig));
	response.put("baseTarget", Long.toString(lastBlock.getBaseTarget()));
	
	return response;
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:24,代码来源:GetMiningInfo.java

示例2: 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

示例3: processRequest

import fr.cryptohash.Shabal256; //导入依赖的package包/类
@Override
JSONStreamAware processRequest(HttpServletRequest req) {
	JSONObject response = new JSONObject();
	
	response.put("height", Long.toString(Rise.getBlockchain().getLastHDDBlock().getHeight() + 1));
	
	Block lastBlock = Rise.getBlockchain().getLastHDDBlock();
	byte[] lastGenSig = lastBlock.getGenerationSignature();
	Long lastGenerator = lastBlock.getGeneratorId();
	
	ByteBuffer buf = ByteBuffer.allocate(32 + 8);
	buf.put(lastGenSig);
	buf.putLong(lastGenerator);
	
	Shabal256 md = new Shabal256();
	md.update(buf.array());
	byte[] newGenSig = md.digest();
	
	response.put("generationSignature", Convert.toHexString(newGenSig));
	response.put("baseTarget", Long.toString(lastBlock.getBaseTarget()));
	
	return response;
}
 
开发者ID:risex,项目名称:risecoin,代码行数:24,代码来源:GetMiningInfo.java

示例4: calcScoopNumber

import fr.cryptohash.Shabal256; //导入依赖的package包/类
private static int calcScoopNumber(long blockNumber, byte[] generationSignature)
{
  if(blockNumber > 0 && generationSignature != null)
  {
    ByteBuffer buf = ByteBuffer.allocate(32 + 8);
    buf.put(generationSignature);
    buf.putLong(blockNumber);

    // generate new scoop number
    Shabal256 md = new Shabal256();
    md.update(buf.array());

    BigInteger hashnum = new BigInteger(1, md.digest());
    return hashnum.mod(BigInteger.valueOf(MiningPlot.SCOOPS_PER_PLOT)).intValue();
  }
  return 0;
}
 
开发者ID:de-luxe,项目名称:burstcoin-jminer,代码行数:18,代码来源:Round.java

示例5: calculateGenerationSignature

import fr.cryptohash.Shabal256; //导入依赖的package包/类
@Override
public byte[] calculateGenerationSignature(byte[] lastGenSig, long lastGenId) {
    ByteBuffer gensigbuf = ByteBuffer.allocate(32 + 8);
    gensigbuf.put(lastGenSig);
    gensigbuf.putLong(lastGenId);

    Shabal256 md = new Shabal256();
    md.update(gensigbuf.array());
    return md.digest();
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:11,代码来源:GeneratorImpl.java

示例6: calculateScoop

import fr.cryptohash.Shabal256; //导入依赖的package包/类
@Override
public int calculateScoop(byte[] genSig, long height) {
    ByteBuffer posbuf = ByteBuffer.allocate(32 + 8);
    posbuf.put(genSig);
    posbuf.putLong(height);

    Shabal256 md = new Shabal256();
    md.update(posbuf.array());
    BigInteger hashnum = new BigInteger(1, md.digest());
    return hashnum.mod(BigInteger.valueOf(MiningPlot.SCOOPS_PER_PLOT)).intValue();
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:12,代码来源:GeneratorImpl.java

示例7: calculateHit

import fr.cryptohash.Shabal256; //导入依赖的package包/类
@Override
public BigInteger calculateHit(long accountId, long nonce, byte[] genSig, int scoop) {
    MiningPlot plot = new MiningPlot(accountId, nonce);

    Shabal256 md = new Shabal256();
    md.update(genSig);
    plot.hashScoop(md, scoop);
    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:muhatzg,项目名称:burstcoin,代码行数:11,代码来源:GeneratorImpl.java

示例8: getScoopNum

import fr.cryptohash.Shabal256; //导入依赖的package包/类
@Override
  public int getScoopNum() {
  	ByteBuffer posbuf = ByteBuffer.allocate(32 + 8);
posbuf.put(generationSignature);
posbuf.putLong(getHeight());
Shabal256 md = new Shabal256();
md.update(posbuf.array());
BigInteger hashnum = new BigInteger(1, md.digest());
int scoopNum = hashnum.mod(BigInteger.valueOf(MiningPlot.SCOOPS_PER_PLOT)).intValue();
return scoopNum;
  }
 
开发者ID:risex,项目名称:risecoin,代码行数:12,代码来源:BlockImpl.java

示例9: 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

示例10: 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

示例11: 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

示例12: hashScoop

import fr.cryptohash.Shabal256; //导入依赖的package包/类
public void hashScoop(Shabal256 md, int pos) {
	md.update(data, pos * SCOOP_SIZE, SCOOP_SIZE);
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:4,代码来源:MiningPlot.java

示例13: hashScoop

import fr.cryptohash.Shabal256; //导入依赖的package包/类
public void hashScoop(Shabal256 md, int pos)
{
  md.update(data, pos * SCOOP_SIZE, SCOOP_SIZE);
}
 
开发者ID:de-luxe,项目名称:burstcoin-jminer,代码行数:5,代码来源:MiningPlot.java


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