4

I have a problem with using the hashimoto light algorithm in pyethash.

I am using pyethash version 23.1 and comparing the results with ethash.run (ethashjs 0.0.7).

Using the same inputs the result should be the same but I am getting different outputs on OSX 10.10.

pyethash:

import pyethash

blocknr = 229
headerHash = "123deb946d8dd98c79b527d3da0a19210a7193fd6a9c1f496b2c26c9ca4a7933"
nonceStr = "a8c2231491f43da2"

cacheSize = pyethash.get_cache_size(blocknr)
seed = pyethash.get_seedhash(blocknr)

cache = pyethash.mkcache_bytes(
        cacheSize,
        seed).encode('hex')

nonce = long(nonceStr, 16)
fullSize = pyethash.get_full_size(blocknr)

light_result = pyethash.hashimoto_light(fullSize, cache, headerHash.decode("hex"), nonce)
print "result: " + ''.join(x.encode('hex') for x in light_result['result'])

ethashjs:

const Ethash = require('ethashjs');
const levelup = require('levelup');
const memdown = require('memdown');
const BN = require('bn.js');

var block = 229;
var headerHash="123deb946d8dd98c79b527d3da0a19210a7193fd6a9c1f496b2c26c9ca4a7933"
var nonce="a8c2231491f43da2"

var cacheDB = levelup('', {
    db: memdown
});
var ethash = new Ethash(cacheDB);

ethash.loadEpoc(block, function(){

    var result = ethash.run(new Buffer(headerHash, 'hex'), new Buffer(nonce, 'hex'));
    console.log("result " + (new BN(result.hash)).toString(16));

});

The implementation in ethashjs should be correct (It was used to validate a hash for mining a block in my test net). Maybe somebody got a pointer for me!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.