Please login or register.

What are the inputs to the hash function?

I wrote an implementation of the cryptonight hash function (a purely academic exercise). Now I want to take it to the next level. I understand that hashing in reality involves a set of inputs, notably the previous block hash, some current transaction data, and a nonce. Is that correct? What is the actual raw input of the monero hash function?

I see the API has a "getblocktemplate" method which returns some of this data. The previous hash is there. Is the blob returned considered the current blob of transactions? If not, where does that come from? And in the end, how do I string this together with the prev hash and nonce to produce a new block?

Replies: 2
moneromooo posted 1 week ago Replies: 1 | Weight: 478 | Link [ - ]

For Cryptonight, the input is the "block hashing blob". This is basically the serialized block, plus the root of the merkle tree of transactions it contains and the number of transactions. I think getblocktemplate gets you pretty much that. This does not include the transactions themselves, just the root of the merkle tree consisting of hte transactions.

Reply to: moneromooo
theshoeshiner edited 1 week ago Weight: 480 | Link [ - ]

Ah okay! So if getblocktemplate returns that part of the input, you also need to attach a nonce, as that is the essence of mining. So where is that attached? Directly on the end?