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.


import pyethash

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

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

cache = pyethash.mkcache_bytes(

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'])


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!

1 Answer 1


I might have come across something that should be of help. ~6 years later though :/

This segment, more specifically this line suggest some endianness conversion is going on with the nonce.

if ETHASH_LIB == 'ethash':
    mkcache = ethash.mkcache
    EPOCH_LENGTH = ethash_utils.EPOCH_LENGTH
    hashimoto_light = ethash.hashimoto_light
elif ETHASH_LIB == 'pyethash':
    mkcache = pyethash.mkcache_bytes
    hashimoto_light = lambda s, c, h, n: \
        pyethash.hashimoto_light(s, c, h, utils.big_endian_to_int(n))

So perhaps you had to convert the nonce to int from big endian format?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.