# Trying to understand why hash value is more secure from hash algorithm

I am currently studying in college in the US and was actually curious about bitcoin and cryptocurrencies as a whole. I started looking on free university sites like Stanford university and New York University and even attempted to do questions of their past papers. I answered most of the questions, but I am stuck on one of the questions:

```Suppose your professor wants to award each student in the class a random priority for office hours help by giving them a number H(studentID||Bi) where Bi is the ith block header in the Bitcoin blockchain.Would the scheme be me more secure if you instead used H(studentID||Bi-1|| Bi)?``` (https://cs.nyu.edu/courses/fall17/CSCI-GA.3033-019/assignments/practice_final.pdf)

I get that it maybe more secure if you use the `Bi-1` because you have more inputs to generate an output, but I feel like that is not the reason.

giving them a number H(studentID||Bi) where Bi is the ith block header in the Bitcoin blockchain.Would the scheme be me more secure if you instead used H(studentID||Bi-1|| Bi)?

For this purposes of this question, the bitcoin header Bi = H(Bi-1 || other stuff). Under a black box assumption of H()'s behavior, the two schemes are practically equivalent.

You can't really argue that H(id || Bi-1 || H(bi-1||stuff)) is more secure than H(id || H(Bi-1||stuff)) on the basis of 'more data' because H() might well have an internally bottleneck E.g. it could be implemented H(bytes[0 .. n]) = H(H(...H(H(H(bytes[0])||bytes[1])||bytes[2])...||bytes[n]) (and, in fact, sha256 does work kind of like this, though not one byte at a time).

Without out a more formal definition of "security" I don't think it's possible to just answer the question. But guessing at a meaning "could someone more easily rig their office hours under one instead of the other"-- the answer would be no.

A hash is just a way to summarize things into an unique ID.

The more elements the hashing contains the harder it is to break it, if you reverse a hash it would cause a preimage attack and the algorithm of the hash would be useless because you would’ve broken its main concept which is hashing (not encrypting)

If everyone knows the way the hash is computed then everyone could fake the hash (In bitcoin, everyone knows the way it is computed because that’s how the nodes can verify whether a hash is valid or not and thus know whether the blockchain was modified). Having said that, you might want to consider the secret of the order for the hashing in order to make it “secure”.

A hash safety itself is measured by how hard it is to break it. Sha256 is one of the most powerful hashes because it’s almost impossible to generare a preimage attack, but if you need to make it safer, you could hash the hash, H(H1(H0))

Where H0 is the first hash.

That way it would get harder exponentially to break it, (the more rounds you use to hash information, the harder it gets by an exponent number).

I hope that works for you to understand.