SHA-256 Algorithm – Encryption – BitcoinWiki

Myriad - A coin for everyone.

Myriad (XMY) is a Multi-PoW consensus protocol secured by 5 mining algorithms. Each one suits different hardware.

So you’ve got your miner working, busy hashing away … but what is it really doing?

Posted for eternity @
Your miner is repeatedly hashing (see below for detail about a hash) a block of data, looking for a resulting output that is lower than a predetermined target. Each time this calculation is performed, one of the fields in the input data is changed, and this results in a different output. The output is not able to be determined until the work is completed – otherwise why would we bother doing the work in the first place?
Each hash takes a block header (see more below, but basically this is a 80-byte block of data). It runs this through the hashing function, and what comes out is a 32-byte output. For each, we usually represent that output in hexadecimal format, so it looks something like:
(that’s 64 hexadecimal characters – each character represents 4-bits. 64 x 4 bits = 256bit = 32 bytes)
The maximum value for our hash is:
And the lowest is:
The goal in Proof-of-Work systems is to look for a hash that is lower than a specific target, i.e. starts with a specific number of leading zeros. This target is what determines the difficulty.
As the output of the hash is indeterminate, we look to statistics and probability to estimate how much work (i.e. attempts at hashing) we need to complete to find a hash that is lower than a specific target. So, we can therefore assume that to find a hash that starts with a leading zero will take, on average, 16 hashes. To find one that will start with two leading zeros (00), we’re looking at 256 hashes. Four leading zeros (0000) will take 65,536 hashes. Eight leading zeros (00000000) takes 4,294,967,296 hashes. So on and so on, until we realize that it will take 2 ^ 256 (a number too big for me to show here) attempts at hitting our minimum hash value.
Remember – this number of hashes is just an estimate. Think of it like rolling a dice. A 16-sided dice. And then rolling it 64 times in a row. And hoping to strike a specific number of leading zeros. Sometimes it will take far less than the estimate, sometimes it will take far more. Over a long enough time period though (with our dice it may take many billions of years), the averages hold true.
Difficulty is a measure used in cryptocurrencies to simply show how much work is needed to find a specific block. A block of difficulty 1 must have a hash smaller than:
A block of difficulty 1/256 (0.00390625) must have a hash lower than:
And a block of difficulty 256 must have a hash lower than:
So the higher the difficulty, the lower the hash must be; therefore more work must be completed to find the block.
Take a recent Vertcoin block – block # 852545, difficulty 41878.60056944499. This required a hash lower than:
The achieve finding this, a single miner would need to have completed, on average 179,867,219,848,013 hashes (calculated by taking the number of hashes needed for a difficulty 1 block - 4,294,967,296 or 2 ^ 32 or 16 ^ 8 – and multiplied by the difficulty). Of course, our single miner may have found this sooner – or later – than predicted.
Cryptocurrencies alter the required difficulty on a regular basis (some like Vertcoin do it after every block, others like Bitcoin or Litecoin do it every 2016 blocks), to ensure the correct number of blocks are found per day. As the hash rate of miners increases, so does the difficulty to ensure this average time between blocks remains the same. Likewise, as hash rate decreases, the difficulty decreases.
With difficulties as high as the above example, solo-mining (mining by yourself, not in a pool) becomes a very difficult task. Assume our miner can produce 100 MH/s. Plugging in this into the numbers above, we can see it’s going to take him (on average) 1,798,673 seconds of hashing to find a hash lower than the target – that’s just short of 21 days. But, if his luck is down, it could easily take twice that long. Or, if he’s lucky, half that time.
So, assuming he hit’s the average, for his 21 days mining he has earned 25 VTC.
Lets take another look at the same miner, but this time he’s going to join a pool, where he is working with a stack of other miners looking for that elusive hash. Assume the pool he has joined does 50 GH/s – in that case he has 0.1 / 50 or 0.2% of the pool’s hash rate. So for any blocks the pool finds he should earn 0.2% of 25 VTC = 0.05 VTC. At 50 GH/s, the pool should expect to spend 3,597 seconds between finding blocks (2 ^ 32 * difficulty / hashrate). So about every hour, our miner can expect to earn 0.05 VTC. This works out to be about 1.2 VTC per day, and when we extrapolate over the estimated 21 days of solo mining above, we’re back to 25 VTC.
The beauty of pooled-mining over solo-mining is that the time between blocks, whilst they can vary, should be closer to the predicted / estimated times over a shorter time period. The same applies when comparing pools – pools with a smaller hash rate will experience a greater variance in time between blocks than a pool with a greater hash rate. But in the end, looking back over a longer period of time, earnings will be the same.
A Hash is a cryptographic function that can take an arbitrary sized block of data and maps it to a fixed sized output. It is a one-way function – only knowing the input data can one calculate the output; the reverse action is impossible. Also, small changes to the input data usually result in significant changes to the output value.
For example, take the following string:
“the quick brown fox jumps over the lazy dog” 
If we perform a SHA256 hash of this, it results in:
If we change a single character in the input string (in this case we will replace the ‘o’ in ‘over’ to a zero), the resulting hash becomes:
A block is made up of a header, and at least one transaction. The first transaction in the block is called the Coinbase transaction – it is the transactions that creates new coins, and it specifies the addresses that those coins go to. The Coinbase transaction is always the first transaction in a block, and there can only be one. All other transactions included in a block are transactions that send coins from one wallet address to another.
The block header is an 80-byte block of data that is made up of the following information in this order:
  • Version – a 32-bit/4-byte integer
  • Previous Block’s SHA256d Hash – 32 bytes
  • Merkle Hash of the Transactions – 32 bytes
  • Timestamp - a 32-bit/4-byte integer the represents the time of the block in seconds past 1st January 1970 00:00 UTC
  • nBits - a 32-bit/4-byte integer that represents the maximum value of the hash of the block
  • Nonce - a 32-bit/4-byte integer
The Version of a block remains relatively static through a coin’s lifetime – most blocks will have the same version. Typically only used to introduce new features or enforce new rules – for instance Segwit adoption is enforced by encoding information into the Version field.
The Previous Blocks’ Hash is simple a doubled SHA256 hash of the last valid blocks header.
The Merkle Hash is a hash generated by chaining all of the transactions together in a hash tree – thus ensuring that once a transaction is included in a block, it cannot be changed. It becomes a permanent record in the blockchain.
Timestamp loosely represents the time the block was generated – it does not have to be exact, anywhere within an hour each way of the real time will be accepted.
nBits – this is the maximum hash that this block must have in order to be considered valid. Bitcoin encodes the maximum hash into a 4-byte value as this is more efficient and provides sufficient accuracy.
Nonce – a simple 4-byte integer value that is incremented by a miner in order to find a resulting hash that is lower than that specified by nBits.
submitted by nzsquirrell to VertcoinMining [link] [comments]

Block hashing calculations

I'm learning about block hashing algorithm. I've found a very good beginner explanation here :
But I struggle to understand why it still takes 10 minutes to find a block ! As I understand it, at the beginning of the race to find a new block, the only unknown is the nonce which is iterated to find a suitable sha256d hash.
So, a miner must iterate 232 possibilities, which with an antminer S9 doing 14*1012 iterations per second is near instant ...
What am I missing here ? If someone can explain that to me, I would be grateful !
submitted by Balistick to BitcoinMining [link] [comments]

How DECOR++ can eradicate selfish mining incentive by design | Sergio Demian Lerner | Aug 16 2015

Sergio Demian Lerner on Aug 16 2015:
In these shocking forking times, nothing more relaxing that to immerse
yourself in a pure technical reading about cryptocurrency design, letting
aside Bitcoin politics for a moment. This message is about cryptocurrencies
design in general, so you're free to skip my message if you think it will
never apply to Bitcoin.
[ full article copied from my blog:
A year ago I proposed the DECOR protocol
<>, a new rule for
cryptocurrencies to reduce significantly the amount of orphan blocks and
then allow block rate to be as high as one block every 5 seconds, and at
the same time it promised to address the problem of selfish mining
<>. After one
year, I’ve received very little feedback about it. Yet the selfish mining
<> problem has
been argued over and over against certain changes in Bitcoin, as if selfish
mining were something inevitable to all POW-based cryptocurrencies. But it
is not.
In a nutshell, DECOR is a protocol that permits miners to share the block
reward if both mine competing blocks. This is done by publishing block
header siblings (sometime called uncles) into child blocks, and modifying
the cryptocurrency protocol to pay some amount to the miners of uncles. If
all miners are honest, this strategy increases slightly the probability of
1-block reversals, but reduces considerably the probability of longer
reversals, as all miners choose the same parent. A few months after my
post, Ethereum <>adopted a similar strategy of
paying a certain amount of ether to uncles, but the amount paid was created
out of thin ear, and at that time there could be any amount of uncles, so
basically it distorted the money supply function into a uncapped
inflationary one, if all miners decided to collude. After I reported this
issue, they restricted the number of uncles that can be included, but still
it leaves an incentive for all miners to collude to increase miner revenue.
DECOR does reward sharing, so the supply function cap is maintained. But it
does not solve the Selfish mining problem: miners withholding a block get
paid a full reward but the remaining miners are working (without knowing
it) for a half of the block reward. So my original strategy does not work
for rational (but not necessarily honest) miners. A few posts later I
presented DECOR+ <> to try
to address the problem of unbalanced rewards: what happens if there are two
competing blocks, but one has a 12.5 BTC reward, but the other has a 20 BTC
reward due to additional fees? But again, if miners are dishonest, the
proposed scheme does not solve the underlying problem, as miners can
artificially increase their fees to win the conflict resolving rule, at
least in all cryptocurrencies that do not burn transaction fees. How can we
fix it?
We’ll fix DECOR by doing three changes. The first is by paying full rewards
to all competing blocks, either the parent or the uncles. To prevent
increasing the money supply, first we set a maximum number of uncles U than
can be included over a period of N blocks. For example we can set U=100 and
N=1000 (a maximum orphan rate of 10%). Then we create rule to decrease the
money supply per time interval in case it previously was increased. So to
prevent miners colluding to increase the money supply in U/N, we either
decrease the subsidies of the following N blocks by the excess amount in
the previous period or we make N coincident with block difficulty re-target
interval and we consider uncles in the rate computation, so mining
afterward simply gets more difficult. If all miners collude to try to
increase their revenue by U/N, they will see their revenue decrease by the
same amount in the following re-target interval.
Miners could start switching between two cryptocurrencies to mine only
during the low difficulty interval and avoid the high difficulty interval.
But here are no competing valuable non-merged mined cryptocurrency using
SHA256D, so this is no problem for Bitcoin. Also the cryptocurrency left
without mining power would become insecure and its price will fall to near
zero. So increasing the immaturity lock time for coinbases to at least N
blocks destroys any miner earnings if all decide to switch all at once.
The second change is to choose the parent block in case of conflict based
on a deterministic random selection in case of deciding between several
chains with the same accumulated difficulty but different tip: we order the
competing tip blocks by their hash digest values, we hash the hashes and we
use the resulting hash digest as seed to a PRNG to choose an index in the
sorted list of the block to choose as parent.
The third change is to process the transactions of all competing blocks
(the actual block and its siblings) in case of a conflict. The transactions
on the parent block will be processed first as normal. The others will be
processed in the order they are referenced in following child blocks.
Conflicting transactions (double-spends) present in uncle blocks with
respect to the main block are skipped, while obviously internal conflicts
in the uncle blocks make them invalid, as usual. Now, as long as the
subsidy dominates the fees, miners have no incentive to withhold blocks.
Let’s analyze what can happen in the long term, when fees dominate the
block reward. In the future there may be two kinds of transactions: public
transactions and private transactions. Public transactions are the current
standard transactions: they pay a fee in the standard way and are broadcast
over the public network. Private transactions may appear if miners decide
to negotiate inclusion in blocks directly with web wallets or gateways:
private transactions will pay fees as an output to the miner’s public key.
Blocks with high rewards competing with blocks with low rewards due to
public transactions will be rare, since for the benefit of the miner most
transactions included in blocks should be present in all other miners
memory pools to accelerate propagation, so all miners are exposed to the
same reward pool. If it happens (by the mistake of a user) that a public
transaction pays an extremely high fee, the withholding incentive may
reappear. But in a far future, when subsidy disappears and miners receive
the payment mainly because of fees, they may adopt the more competitive
commercial strategy of rely mainly in private transactions (or maybe using Mike
Hearn’s assurance contracts
<>). As fees from
private transactions are not shared between competing blocks, they won’t
affect selfish mining. I conclude that DECOR++ is currently incentive
compatible and it is highly probable that remains incentive compatible in
the future.
To summarize, DECOR++ main protocol properties are:
Best regards, Sergio.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>
submitted by bitcoin-devlist-bot to bitcoin_devlist [link] [comments]

Segwit addresses with python - into Instructions for Solving the SHA-265 Cryptographic Hash ... Free Bitcoin Mining Website 2020  Mine 0.08BTC Daily ... Dissecting a P2PKH Bitcoin Transaction down to the last Byte But how does bitcoin actually work? - YouTube

From Bitcoin Wiki. Jump to: navigation, search. SHA-256 is a member of the SHA-2 cryptographic hash functions designed by the NSA. SHA stands for Secure Hash Algorithm. Cryptographic hash functions are mathematical operations run on digital data; by comparing the computed "hash" (the output from execution of the algorithm) to a known and expected hash value, a person can determine the data's ... Transaktion ist ein Datenabschnitt, der durch eine Unterschrift bestätigt wird. Es wird an das Bitcoin - Netzwerk gesendet und bildet Blöcke.Es enthält normalerweise Verweise auf vorhergehende Transaktionen und ordnet eine bestimmte Anzahl von Bitcoins mit einem oder mehreren öffentlichen Schlüsseln zu (Bitcoin-Adressen).Es ist nicht verschlüsselt, da im Bitcoin-System nichts zu ... SHA-256 is a member of the SHA-2 cryptographic hash functions designed by the NSA. SHA stands for Secure Hash Algorithm. Cryptographic hash functions are mathematical operations run on digital data; by comparing the computed "hash" (the output from execution of the algorithm) to a known and expected hash value, a person can determine the data's integrity. SHA-256d ist die Hash-Funktion, die den Kern von Bitcoin bildet. Inhaltsverzeichnis. 1 Über; 2 Beispiel; 3 Siehe auch; 4 Ressourcen; Über . SHA-256d wurde wie folgt in einem der Ferguson / Schneier-Bücher vorgeschlagen: SHA-256d (x) = SHA-256 (SHA-256 (x)) Die Motivation für diese Konstruktion besteht darin, Längenausdehnungsangriffe zu vermeiden. Beispiel . Ein Beispiel ist dieses ... The following is a list of cryptocurrencies (both current and dead) that use the SHA-256 hashing algorithm. 21Coin <!-- https://coinmarketcap

[index] [42047] [18986] [27548] [18093] [41777] [9802] [35826] [11082] [10089] [36657]

Segwit addresses with python - into

Have you purchased a USB Bitcoin miner and need to learn how to set it up? Now, the first item that you want to pick up is called a Raspberry Pi. Now, this is Now, the first item that you want to ... Best Free Bitcoin mining earn up to 0.025 BTC every day Automated miner site link How to create Coinbase acound ? We aim to understand how bitcoin nodes validate a bitcoin transaction by concatenation of output and input scripts . Therefor we analyze the format of Bitcoin transaction. This is needed to ... Start trading Bitcoin and cryptocurrency here: Bitcoin mining is the process of updating the ledger of Bitcoin transactions known as th... Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.