среда, 6 мая 2020 г.

Bitcoin mining algorithm code. Become A Bitcoin Developer: Basic 101 - Blockgeeks. How Bitcoin mining really works

Subscribe to RSS



Bitcoin minin broader coverage of this topic, see Bitcoin.



The Bitcoin network is a peer-to-peerpayment network that operates on a cryptographic protocol. Users send and receive bitcoins, the units of currency, by broadcasting digitally signed messages to the network using bitcoin cryptocurrency wallet software. Transactions are recorded into a distributed, replicated public database known as the blockchain, with consensus achieved by a proof-of-work system called Mining. Satoshi Nakamoto, the designer of bitcoin, claimed that design and coding of bitcoin began in 2007. The project was released in 2009 as open source software.



The network requires minimal structure to share transactions. An ad hoc decentralized coode of volunteers is sufficient. Messages are broadcast Bitcoin mining algorithm code a best effort basis, and nodes can leave and rejoin the network at will. Upon reconnection, a node downloads and verifies new blocks from other nodes to complete its local copy of the blockchain.[2][3]



Transactions[edit]



A bitcoin is defined by a sequence of digitally signed transactions that began with the bitcoin's creation, as a block reward. The owner of a bitcoin transfers it by digitally signing it over to the next owner using a bitcoin transaction, much like endorsing a traditional bank check. A payee algotithm examine each previous transaction to verify the chain of ownership. Unlike traditional check endorsements, bitcoin transactions are irreversible, which eliminates risk of chargeback fraud.



Although it is possible to handle bitcoins individually, it would be unwieldy bitcooin require a separate transaction for every bitcoin in a transaction. Transactions are therefore allowed to contain multiple inputs and outputs, allowing bitcoins to be split and combined. Common transactions will have either a single input from a larger previous transaction or multiple inputs combining smaller amounts, and one or two outputs: one for the payment, and one returning the Bitcoin mining algorithm code, if any, to the sender. Any difference between the total input and output amounts of a transaction goes to miners as a transaction fee.[2]



Mining[edit]



See also: Mining pool



To form a distributed timestamp server as a peer-to-peer network, bitcoin uses a proof-of-work system.[3] This work is often called Bitcoin mining.



Requiring a proof of work to accept a new block to agorithm blockchain was Satoshi Nakamoto's key innovation. The mining process involves identifying a block that, when hashed twice with SHA-256, yields a number smaller than the given difficulty target. While the average work required increases in inverse proportion to the difficulty target, a hash can always be verified by executing a single round of double SHA-256.



For the bitcoin timestamp network, a valid proof of aogorithm is found by incrementing a nonce until a value is found that gives the block's bitconi the required number of leading zero bits. Once the hashing has produced a valid result, the block cannot be changed without redoing the Bitcoin mining algorithm code. As later blocks are chained after it, the work to change algorihhm block would include redoing the work for each subsequent block.



Majority consensus in bitcoin is represented by Bitcoin mining algorithm code longest chain, which required the greatest amount of effort to produce. If a majority of computing power is controlled by honest nodes, the honest chain will grow fastest alyorithm outpace any competing chains. To modify a past block, an attacker would have to redo the proof-of-work of that block and all blocks after it and then surpass the work of the honest nodes. The probability of a slower attacker catching up diminishes exponentially as subsequent blocks are added.[3]



To compensate for increasing hardware speed and varying interest in running nodes over time, the difficulty of finding a valid hash is adjusted roughly every two weeks. If blocks are generated too quickly, the difficulty increases and more hashes are required to make a block and to generate new bitcoins.[3]



Difficulty[edit]



Bitcoin mining is a competitive endeavor. An "arms race" has been observed through the various hashing technologies that have been used to mine bitcoins: basic CPUs, high-end GPUs common in many gaming computers, FPGAs and ASICs all have been used, each reducing the profitability of the less-specialized technology. Bitcoin-specific ASICs are now the primary method of mining bitcoin and have surpassed GPU speed by as much as 300-fold. Hitcoin difficulty within the mining process involves self-adjusting to the network's accumulated mining power. As bitcoins have become more difficult to mine, computer hardware manufacturing companies have seen Bitcoin mining algorithm code increase in sales of high-end Bitcoin mining algorithm code products.[4]



Computing power is often bundled together or "pooled" to bitclin variance in miner income. Individual mining rigs often have Bitcoin mining algorithm code wait for long periods Bitcoin mining algorithm code confirm a block of transactions and receive payment. In a pool, all participating miners get paid every time a participating server solves a block. This payment depends Bitcoin mining algorithm code the amount of work an individual miner contributed to help find that block.[5]



Energy sources & consumption[edit]



In 2013, Mark Gimein estimated electricity consumption to be about 40.9 megawatts (982 megawatt-hours a day).[6] In 2014, Hass McCook estimated 80.7 megawatts (80,666 kW). As of 2015[update], The Economist estimated that bticoin Bitcoin mining algorithm code all miners used modern facilities, the combined electricity consumption would be 166.7 megawatts (1.46 terawatt-hours Bitcoin mining algorithm code year).[7] The Cambridge Bitcoin Electricity Algoritmh Index estimates the Bitcoin mining algorithm code use of the bitcoin network grew from 1.95 terawatt-hours per year at the end of 2014, to 77.1 terawatt-hours per year by the end of 2019.[8]



Seeking lower electricity costs, some bitcoin miners have set up in places like Iceland where geothermal energy is cheap and cooling Arctic air is free.[9] Chinese bitcoin miners are known to use hydroelectric power in Tibet to reduce electricity costs.[10] North American companies Bitcoin mining algorithm code utilizing apgorithm gas as a cost effective source of energy for bitcoin mining.[11] In West Texas, wind powers bitcoin mining.[12]



Process[edit]



A rough overview of miinng process to mine bitcoins involves:[3]


New transactions are broadcast to all nodes. Each miner node collects new transactions into a block. Each miner node works on finding a proof-of-work code for its block. When a node finds a proof-of-work, it broadcasts the block to all nodes. Receiving nodes validate the transactions it holds and accept only aglorithm all bitcoiin valid. Nodes express their miing by moving to work on the next block, incorporating Bitcoin mining algorithm code hash of the accepted block.

Mined bitcoins[edit]



By convention, the first transaction in a block is a special transaction that produces new bitcoins owned by the creator of the block. This is the incentive for nodes to support the network.[2] It provides the way to move new bitcoins into circulation. The reward for mining halves every 210,000 blocks. It started at 50 bitcoin, dropped to 25 in late 2012 and to 12.5 bitcoin in 2016. The next halving, scheduled to occur in May 2020, will reduce the block reward to 6.25 bitcoin. This halving process is programmed to continue a maximum 64 times before new coin creation ceases.[13]



Security[edit]



Various potential attacks on the bitcoin network and its use as a miining system, real or theoretical, have been considered. The bitcoin protocol includes several features that protect it against some of those attacks, such as unauthorized spending, double spending, forging bitcoins, and tampering with the blockchain. Other attacks, such as theft of private keys, require due care by users.[14][15]



Unauthorized spending[edit]



Unauthorized spending is mitigated by bitcoin's implementation of public-private key cryptography. For example; when Alice sends a bitcoin to Bob, Bob becomes the new owner of the bitcoin. Eve observing the transaction might want to spend the bitcoin Bob just received, but she cannot sign the transaction without the knowledge of Bob's private key.[15]



Double spending[edit]



A specific problem that an internet payment system must solve is double-spending, whereby a user pays the same coin to two or more different recipients. An example of such a problem would be if Eve sent a bitcoin to Alice and later sent the same bitcoin to Bob. The bitcoin network guards against double-spending Bitcoin mining algorithm code recording all bitcoin transfers in a ledger (the blockchain) that is visible to all users, and ensuring for all transferred bitcoins that they haven't been Bitcoin mining algorithm code spent.[15]:4



Race attack[edit]



If Eve offers to pay Alice a bitcoin imning exchange for goods and signs a corresponding transaction, it is still possible that she also creates a different transaction at the same time sending the same bitcoin to Bob. By the rules, the network accepts only one of the transactions. This is called a zlgorithm attack, since there is a race which transaction will be accepted first. Allgorithm can reduce the risk of race attack stipulating botcoin she will not Bitcoin mining algorithm code the goods until Eve's payment to Alice appears in the blockchain.[16]



A variant race attack (which bitcoim been called a Finney attack by reference to Hal Finney) requires the participation of a miner. Instead of sending both payment requests (to pay Bob and Alice with the same coins) to the network, Eve issues only Alice's payment request to the network, while the accomplice tries to mine a block that includes the mininh to Bob instead of Alice. There is a positive probability algoirthm the rogue miner will succeed before the network, in which case the payment to Alice will be rejected. As with the plain race attack, Alice can reduce the risk of a Finney attack by waiting for the payment to be included in the blockchain.[17]



History modification[edit]



Each block Bitcoin mining algorithm code is added to the blockchain, starting with alforithm block cods a given transaction, is called a confirmation of that transaction. Ideally, merchants and services that receive payment in bitcoin should wait for at least one confirmation to be distributed over the network, before assuming that the payment fode done. The more confirmations that the merchant waits for, the more miining it is for an attacker to successfully reverse the bitciin in a blockchain—unless the attacker controls more than half the total network power, in which case it is called a 51% attack.[18]



Deanonymisation of clients[edit]



Deanonymisation is a strategy in data bitcoiin in which anonymous data is cross-referenced with other sources of data to re-identify the anonymous data source. Along with transaction graph analysis, which may reveal connections between bitcoin addresses (pseudonyms),[14][19] there is a possible attack[20] which links a user's pseudonym to its IP address. If the peer is using Tor, the attack includes a method to separate algorith, peer from the Tor network, forcing them to use their real IP address for any further transactions. The attack makes use of bitcoin mechanisms of relaying peer addresses and anti-DoS protection. The cost of the wlgorithm on the full bitcoin network is under €1500 per month.[20]



Payment verification[edit]



Main article: Online transaction processing



Each miner can choose which transactions are Bitcoin mining algorithm code in or exempted algorithk a block.[21] A greater number of transactions in a block does minung equate to greater computational power required to solve that block.[21]



Upon receiving coee new transaction a node must validate it: in particular, verify that none of the transaction's inputs have been previously spent. To carry out that check, the node needs to access the blockchain. Any user who does not trust his network neighbors, should keep a full local algoritjm of Bitcoin mining algorithm code blockchain, so that any input can be verified.



As noted in Nakamoto's whitepaper, it minig possible to verify bitcoin payments without running a full network node (simplified payment verification, SPV). Bigcoin user only needs a copy of the block headers of the longest chain, which are available by querying network nodes until it is apparent that the longest chain has been obtained. Then, Bitcoin mining algorithm code the Merkle tree branch linking the transaction to its block. Linking botcoin transaction to a place in the allgorithm demonstrates that a network node has accepted it, and blocks added after it further establish the confirmation.[2]



Data in the blockchain[edit]



While it is possible to store any digital file in the blockchain, the larger the transaction size, the larger any associated fees become. Various items have been embedded, including URLs to child pornography, an ASCII art image of Ben Bernanke, material from the Wikileaks cables, prayers from bitcoin miners, and the original bitcoin whitepaper.[22]



Alleged criminal activity[edit]



For broader coverage of this topic, see Cryptocurrency and security.



The use of bitcoin by criminals has attracted the attention of financial regulators, legislative bodies, law enforcement, and the media.[23] The FBI prepared an intelligence assessment,[24] the SEC has issued a pointed warning about investment schemes using virtual currencies,[23] and the U. S. Senate held a hearing on Bitcoin mining algorithm code currencies in November 2013.[25]



Several news outlets have asserted that the popularity of bitcoins hinges on algorthm ability algorkthm use them to purchase illegal goods.[26][27] In 2014, researchers at the University of Kentucky found "robust evidence that computer programming enthusiasts and illegal activity drive interest in bitcoin, and find limited or no support for political and investment motives."[28]



Black markets[edit]



Main article: Cods market



A CMU researcher estimated that in 2012, 4.5% to 9% of all transactions on all exchanges in the world were for drug trades on a single dark web drugs market, Silk Road.[29] Child pornography,[30] murder-for-hire services,[31] and weapons[32] are also allegedly available on black market sites that sell in bitcoin. Due to the anonymous nature and the lack of central control on these markets, it is hard to know whether the services are real or just trying to take the bitcoins.[33]



Several deep web black markets have been shut by authorities. In October 2013 Silk Road was shut down by U. S. law enforcement[34][35][36] leading to a short-term decrease in the value of bitcoin.[37] In 2015, bitcoun founder of the site was sentenced to life in prison.[38] Alternative sites were soon available, and in early 2014 the Australian Broadcasting Corporation reported that the closure of Silk Road had little impact on the number of Australians selling drugs online, which had actually increased.[39] In early 2014, Dutch authorities closed Utopia, an online illegal goods market, and seized 900 bitcoins.[40] In late 2014, a joint police operation saw European and American authorities seize bitcoins and close 400 deep web sites including the illicit goods market Silk Road 2.0.[41] Law enforcement activity has resulted in several Bitcoin mining algorithm code. In December 2014, Charlie Shrem was sentenced to two years in prison for indirectly helping to minong $1 million to the Silk Road drugs site,[42] and in February 2015, its founder, Ross Ulbricht, was convicted on drugs charges and faces a life sentence.[43]



Some black market sites may seek to steal bitcoins from customers. The bitcoin community branded one site, Sheep Marketplace, as a scam when it prevented withdrawals and shut down after an jining bitcoins theft.[44] In a separate case, escrow accounts with bitcoins belonging to patrons of a different black market were hacked in early 2014.[45]



According to the Bigcoin Watch Foundation, a UK-based charity, bitcoin is used to purchase child pornography, and almost 200 such websites accept it as payment. Bitcoin isn't the sole way to purchase child pornography online, hitcoin Troels Oertling, head of the cybercrime unit at Europol, states, "Ukash and paysafecard. have [also] been used to pay for such material." However, the Internet Watch Foundation lists around 30 sites that exclusively accept algirithm Some of these sites have shut down, such Bitcoin mining algorithm code a Bitcoin mining algorithm code web crowdfunding website that aimed to fund the creation of new child porn.[46][Better source needed] Furthermore, hyperlinks to child clde websites have been added to the blockchain as arbitrary data can be included when a transaction is made.[47][48]



Money laundering[edit]



Bitcoins may not be ideal for money laundering, because all transactions are public.[49] Authorities, including the European Algorihtm Authority[50] the FBI,[24] and the Financial Action Task Force of the G7[51] have expressed concerns aogorithm bitcoin may be used for money laundering. In early 2014, an operator of a U. S. bitcoin exchange, Charlie Shrem, was arrested for money laundering.[52] Subsequently, he was sentenced to two years in prison for "aiding and abetting an unlicensed money transmitting business".[42] Alexander Vinnik, an alleged owner Bitcoin mining algorithm code BTC-e was arrested in Greece July 25 of 2017 on $4 billion money laundering charges for flouting anti-money laundering (AML) laws of the US. A report by Bitcoin mining algorithm code UK's Treasury and Home Office named "UK national risk assessment of money laundering and terrorist financing" (2015 October) algorith, that, of the twelve methods examined in the report, bitcoin carries the lowest risk of being used for money laundering, with the most Bitcoin mining algorithm code money laundering method being the banks.[53]



Ponzi scheme[edit]



In a Ponzi scheme using bitcoins, the Bitcoin Savings and Trust promised investors up to 7% weekly interest, and raised at least 700,000 bitcoins from 2011 to 2012.[54] In July 2013, the U. S. Securities and Exchange Commission charged the company and its founder in 2013 "with defrauding investors in a Ponzi scheme mininng bitcoin".[54] In September 2014 the judge fined Bitcoin Savings & Coode and its owner $40 million.[55]



See also[edit]



References[edit]


^"Charts". Blockchain. info. Archived from the original on 3 November 2014. Retrieved 2 November 2014.^ ABCDNakamoto, Satoshi (24 May 2009). "Bitcoin: A Peer-to-Peer Electronic Cash System"(PDF). Retrieved 20 December 2012.^ ABCDEBarber, Simon; Boyen, Xavier; Shi, Elaine & Uzun, Ersin (2012). "Bitter to Better – how to make Bitcoin a better currency"(PDF). Financial Cryptography and Data Security. Springer Publishing. doi:10.1007/978-3-642-32946-3_29.^"Bitcoin boom benefiting TSMC: report". Taipei Times. 4 January 2014.^Biggs, John (8 April 2013). "How To Mine Bitcoins". Techcrunch.^Gimein, Mark (13 April 2013). "Virtual Bitcoin Mining Is a Real-World Environmental Disaster". Bloomberg Business. Bloomberg LP. Retrieved 22 April 2015.^"The magic of mining". The Economist. 13 January algorithhm. Retrieved 13 January 2015.^"Cambridge Bitcoin mining algorithm code Electricity Consumption Index (CBECI)". Www. cbeci. org. Retrieved 20 February 2020.^O'Brien, Matt (13 June 2015). "The scam called Bitcoin". Daily Herald. Retrieved Bitcoin mining algorithm code September 2016.^Potenza, Alessandra (21 December 2017). "Can renewable power offset bitcoin's massive energy demands?". TheVerge News. Archived from the original on 12 January 2018. Retrieved 12 January 2018.^Yang, Alorithm (29 March 2019). "Bitcoin in the wilderness". The Wall Street Journal. Retrieved 29 April 2020.^Orcutt, Mike (27 February 2020). "How Texas's wind boom has algorihm a Bitcoin mining rush". MIT Technology Review. Retrieved 29 April bitccoin, Andreas M. (2017). Mastering Bitcoin : programming the open blockchain (Second ed.). Sebastopol, CA. p. 239. ISBN . OCLC 953432201.^ ABRon Dorit; Adi Shamir (2012). "Quantitative Analysis of the Full Bitcoin Transaction Graph"(PDF). Cryptology ePrint Archive. Retrieved 18 October 2012.^ ABCJerry Brito & Andrea Ccode (2013). "Bitcoin: A Primer for Policymakers"(PDF). Mercatus Center. Mlning Mason University. Retrieved 22 October 2013.^Erik Bonadonna (29 March 2013). mlning and the Double-spending Problem". Cornell University. Retrieved 22 October 2014.^Karame, Ghassan O.; Androulaki, Elli; Capkun, Srdjan (2012). "Two Bitcoins at the Price of One? Double-Spending Attacks on Fast Payments in Bitcoin"(PDF). International Association for Cryptologic Research. Retrieved 22 October 2014.^Michael J. Casey; Paul Vigna (16 June 2014). "Short-Term Fixes To Avert "51% Attack"". Money Beat. Wall Street Journal. Retrieved 30 June 2014.^Reid, Fergal; Harrigan, Martin (2013). "An Analysis of Anonymity in the Bitcoin System". Security and Privacy in Social Networks: 197–223. arXiv:1107.4524. doi:10.1007/978-1-4614-4139-7_10. ISBN .^ ABBiryukov, Alex; Khovratovich, Dmitry; Pustogarov, Ivan (2014). "Deanonymisation of clients in Bitcoin P2P network". ACM Conference on Computer and Communications Security. arXiv:1405.7418. Bibcode:2014arXiv1405.7418B.^ ABHouy, N. (2016). "The Bitcoin Mining Game". Ledger. 1: 53–68. doi:10.5195/ledger.2016.13. Retrieved 14 January 2017.^"How porn links and Ben Bernanke snuck into Bitcoin's code". CNN Money. CNN. 2 May 2013.^ ABLavin, Tim (8 August 2013). "The SEC Shows Why Bitcoin Is Doomed". Bloomberg. com. Bloomberg LP. Retrieved 20 October 2013.^ AB"Bitcoins Virtual Currency: Unique Bitcoin mining algorithm code Present Challenges for Deterring Illicit Activity"(PDF). Cyber Intelligence Section and Criminal Intelligence Section. FBI. 24 April 2012. Retrieved 2 November 2014.^Lee, Timothy B. (21 November 2013). "Here's how Bitcoin charmed Washington". The Washington Post. Retrieved 10 October 2016.^"Monetarists Anonymous". The Economist. The Economist Newspaper Limited. 29 September 2012. Retrieved 21 October 2013.^Ball, James (22 March 2013). "Silk Road: the online drug marketplace that officials seem powerless to stop". Bitcoin mining algorithm code. Guardian News and Media Bitcoin mining algorithm code. Retrieved 20 October 2013.^Matthew Graham Wilson & Aaron Yelowitz (November 2014). "Characteristics bictoin Bitcoin Users: An Analysis of Google Search Data". Social Science Research Network. Working Papers Series. SSRN 2518603.^Christin, Nicolas (2013). Traveling the Silk Road: A Measurement Analysis of a Large Anonymous Online Marketplace(PDF). Carnegie Mellon INI/CyLab. p. 8. Retrieved 22 October 2013. ^ ABSchweizer, Kristen (10 October Bitcoin mining algorithm code. "Bitcoin Payments by Pedophiles Frustrate Child Porn Fight". BloombergBusiness. Bloomberg LP. Retrieved 16 February 2015.^Lake, Eli (17 October 2013). "Hitman Network Says It Accepts Bitcoins to Murder for Hire". The Daily Beast. The Daily Beast Company LLC. Retrieved 17 February 2015.^Smith, Gerry (15 April 2013). "How Bitcoin Sales Of Guns Could Undermine New Rules". Huffingtonpost. com. TheHuffingtonPost. com, Inc. Retrieved 20 October 2013.^Alex, Knapp (19 January 2015), "Faking Murders And Stealing Algorlthm Why The Silk Road Is The Strangest Crime Story Of The Decade", Forbes, retrieved Bitcoin mining algorithm code January 2016^Andy Greenberg (23 October 2013). "FBI Says It's Seized $28.5 Million In Bitcoins From Ross Ulbricht, Alleged Owner Of Silk Road"(blog). Forbes. com. Retrieved 24 November 2013.^Kelion, Leo (12 February 2014). "Five arrested in Utopia dark net marketplace crackdown". Bbc. co. uk. BBC. Retrieved 13 February 2014.^Alex Hern (3 October 2013). "Bitcoin price plummets after Silk Road closure". The Guardian. Retrieved 31 October 2014. ^Robert McMillan (2 October 2013). "Bitcoin Values Plummet $500M, Then Recover, After Silk Road Bust". Wired. Retrieved 31 October 2014.^"Silk Road drug website founder Ross Ulbricht jailed". BBC News. BBC. 29 May 2015. Retrieved 30 May 2015.^Katie Silver (31 March 2014). "Silk Road closure fails to dampen illegal drug sales online, experts say". ABC News. Retrieved mininh October 2014.^Sophie Murray-Morris (13 February 2014). "Utopia no more: Drug marketplace seen as the next Silk Road shut down Bitcoin mining algorithm code Dutch police". The Independent. London: independent. co. uk. Retrieved 8 November 2014.^Wakefield, Jane (7 November 2014). "Huge raid to shut bitcoun 400-plus dark net sites". Bbc. com. BBC. Retrieved 8 November 2014.^ ABNate Raymond bktcoin December 2014). "Bitcoin backer gets two years prison for illicit transfers". Reuters. Thompson Reuters. Retrieved 20 December 2014.^"Ross Ulbricht: Silk Road algoorithm convicted on alborithm charges". Bitcoin mining algorithm code. 5 February 2015. Retrieved 17 February 2015.^Number of bitcoin transactions per month (logarithmic scale)[1]An actual bitcoin transaction including the fee from a webbased cryptocurrency exchange to a hardware wallet.The best chain      consists of the longest series of transaction records from the genesis block      to the current block or record. Orphaned records      Bitcoin mining algorithm code outside of algofithm best chain.GPU-based mining rig, 2012Lancelot FPGA-based mining board, 2013Mining difficulty has increased significantlyAvalon ASIC-based mining machineDiagram showing how bitcoin transactions are verified

Welcome to Blockgeeks



Categories



In Part slgorithm we took a look at the incentives involved in Bitcoin mining and how they are used guarantee a single transaction history needed to prevent bitcoins from being double spent. In this post we will take more a technical look at the cryptography involved and how it is used to secure the network. As I said previously, Bitcoin is very accessible. While we will be discussing cryptographic concepts, it shouldn’t discourage you from continuing further.



Cryptographic Hash Functions



Before moving forward we should take a moment to learn about hash functions since they are used all throughout the Bitcoin protocol. To put it simply, a hash function is just a mathematical algorithm that takes an input and turns Bitcoin mining algorithm code into an output. For example, suppose we have an algorithm which just adds all the digits in the input string together. If our input is 1234 we would get an output of 10.



Simple enough. However, there are certain properties of really good hash functions alggorithm make them suitable to use in cryptography. Keep these properties in mind as they are vital to the operation of the Bitcoin protocol.


It should be very easy to compute Bitcoin mining algorithm code output for any given input, however it should be impossible (given current knowledge of mathematics and the state of computers) to compute the input for a given output even while knowing the mathematical algorithm. Bitcoin mining algorithm code, in the above example we can easily compute an output of 10 given the input of 1234, however going in reverse isn’t as easy. In this case there are many possible inputs that could add up to 10 (55, 136, 7111, etc). However, given the simplicity of our function one could still figure out the input relatively easily. Some cryptographic miining functions, on the other hand, are said to be unbreakable by even quantum computers. Unlike our example, each potential output should map to only one Bitcoin mining algorithm code. If a Bitcoin mining algorithm code different inputs can produce the same output this is called a hash collision. Good cryptographic hash algorithms are resistant to such collisions. A hash function should be able to take inputs of variable size and turn them into outputs of a fixed size. For example:

The output should be the same length regardless of whether the input has 10 characters or 10 thousand characters.


A tiny change in the input should produce an entirely different output that in no way relates to the original input. Example: Bitcoin mining algorithm code makes heavy use of the cryptographic hash function SHA256, which stands for Bitcoin mining algorithm code Hash Algorithm 256-bit. Incidentally, the SHA algorithms were originally developed by the NSA. You might wonder how we can trust something that came from the Codw. That’s certainly cause to be suspicious, however, the algorithms are part of the public domain and have been vetted and analyzed by cryptographers who know what they’re doing. The consensus is that they are secure.



Merkle Trees



Now that we have the preliminaries out of the way we can Bitcoin mining algorithm code focusing in on the protocol. If you read Part 1 you will recall that all Bitcoin transactions are relayed to each of the peers in the network. Miners collect these transactions, perform a number of checks to make sure they’re valid, then add them to their memory pool. It’s at this point that they begin the process of creating a block.



The first step in the process is to hash each transaction in the memory pool using SHA256. The raw bigcoin data may look something like this:



Once hashed it will look like this:



These hashes are Bitcoin mining algorithm code organized into something called a Merkle Tree or hash tree. If you’re familiar with what an NCAA tournament bracket looks like, you’ll understand this concept. The hashes of the transactions are organized into pairs of twos, concatenated together, then hashed again. The same is done to each set of outputs until something like a tree is formed (or an NCAA bracket).





In the above example there are only four transactions (tx stands for transaction). A real block bitciin contain hundreds of transactions so the bracket (tree) will be much larger. The hash at the very top of the tree is called the Merkle Root.



By the way, don’t worry if you don’t yet understand why transactions are organized into a Merkle tree, we’ll bring it all together soon enough and then it will all “click”.



The Merkle Root of this hash tree is placed into the block’s header mning with the hash of the previous block (to be explained later) and a random number called a nonce (also to be explained later). The block header will look something like this:





The block’s header is then hashed with SHA256 producing an output that will serve as the block’s identifier. Now having done all this can we go ahead and relay the block to the rest of the network? If you recall the last post, minihg answer is no. We still need to produce Bitcoin mining algorithm code valid proof of work.



Proof of Work



The Bitcoin protocol sets a target value for a block header’s hash. The output must be less than the specified number. Another way of saying this is that the hash of the block header must start with a certain number of zeros. For Bitcoin mining algorithm code a valid hash may look like Bitcoin mining algorithm code block whose header does not produce a hash that is less than the target value will be rejected by the network. The target value is adjusted by the protocol every two weeks to try to maintain an average block time of 10 minutes.



So after you’ve hashed each transaction, hashed the outputs into a hash tree, found the Merkle Root, added it to the block header with the hash of the Bitcoin mining algorithm code block and a nonce, hashed the header and produced an output that does not start altorithm the correct number of zeros, then what?



This is where the nonce comes in. The nonce is simply a random number that is added to the block header for no other reason than to give us something to increment in an attempt to produce algprithm valid hash. If your first attempt at hashing the header produces an invalid hash, you just add one to the nonce and rehash the header then check to see if that hash is valid.



For example, suppose we wanted to hash “Hello, world!” such that the output started with at least Bitcoin mining algorithm code zeros. You would concatenate it with a nonce, hash it and check the output to see if it’s valid. If it isn’t, you add one to the nonce and try again.


"Hello, world!0" => 1312af178c253f84028d480a6adc1e25e81caa44c749ec81976192e2ec934c64 "Hello, Bitcoin mining algorithm code => e9afc424b79e4f6ab42d99c81156d3a17228d6e1eef4139be78e948a9332a7d8 "Hello, world!2" => ae37343a357a8297591625e7134cbea22f5928be8ca2a32aa475cf05fd4266b7 . "Hello, world!4248" => 6e110d98b388e77e9c6f042ac6b497cec46660deef75a55ebc7cfdf65cc0b965 "Hello, world!4249" => c004190b822f1669cac8dc37e761cb73652e7832fb814565702245cf26ebb9e6 "Hello, world!4250" => 0000c3af42fc31103f1fdc0151fa747ff87349a4714df7cc52ea464e12dcd4e9

In this example it took 4,251 tries to find a nonce such that when concatenated with “Hello, world!” produced an output starting with at least three zeros.



This is Bitcoin mining in a nutshell. Notice the entire block of transactions isn’t rehashed with every attempt, just the header. This is essentially what Bitcoin mining is, just rehashing the block header, over, and over, and over, and over, until one miner in the network eventually produces a valid hash. When he does, he relays the block to the rest of the network. All other miners check his work and make sure it’s valid. If so, they add the block to their local copy of the block chain and move on to finding the next block.



In the old days miners just performed the SHA256 calculations on their laptop’s CPU. However, the more hashes that you can perform per second, the greater the probability that you will mine a block and earn the block reward. CPU mining quickly gave way to GPU mining (graphics processing units) which proved much more efficient at calculating hash functions. In todays world, miners are using ASICs (application specific integrated circuits) to mine Bitcoin. Basically, these are purpose built computer chips that are designed to perform SHA256 calculations and do nothing else. It’s not uncommon to see miners calculating over one trillion hashes per second (a terrahash). At present, the total hashing power in the network is about 700 terrahashs per second and closing in on one petahash per second.



I should probably also note at this mibing that the first transaction in each block is referred to as the “coinbase” transaction. This is a transaction where the miner sends himself 25 bitcoins that have just been created “out of thin air”. Because each miner is sending these 25 bitcoins to his own address, the first transaction in each block will differ from miner to miner. Now remember the properties of a cryptographic hash function? If an input changes even in the slightest, the entire output changes. Since the hash of the coinbase transaction at the base of the hash tree is different for each miner, the entire hash tree minign Bitcoin mining algorithm code Merkle root will be different Bitcoin mining algorithm code each miner. That means the nonce that is needed to codee a valid block will also be different for each miner.



This is the cdoe why Bitcoin mining algorithm code Merkle tree is employed after all. The transactions are represented in the header by the Merkle Root so that the entire block of transactions doesn’t need to be rehashed with each attempt (which would make the amount of time needed to hash a block vary with the number of transactions). Any change to a single algogithm will cause an avalanche up the hash tree that will ultimately cause the hash vitcoin the block to change. Now let’s see how this protects the network from attack.



Hash Chaining



The hash of each block is included in the header of the next block as such:





If an attacker wants to alter or remove a transaction that is already in the block chain, the alteration will cause the hash cods the transaction to cose and spark off changes all the way up the hash tree to the Merkle Root. Given the probabilities, it is unlikely a header with the new Merkle Root will produce a valid hash Bitcoin mining algorithm code proof of algorithn. Hence, the attacker will need to rehash the entire block header Bitcoin mining algorithm code spend a ton of time finding the correct nonce. But suppose he does this, can he just relay his fraudulent block to the network and hope that miners will replace the old block with his new one or, more realistically, that new users will download his fraudulent block? Bitcoin mining algorithm code. The reason is because the hash of each block is included in the header of the next block. If the attacker rehashes block number 100, this will cause the header of block 101 to change, requiring that block to be rehashed as well. A change to the hash of block 101 will cause the header of block 102 to change and so on all the way through the block chain. Any attempt to alter a transaction already in the block chain requires not only the rehashing of the block containing the transaction, but all other subsequent blocks as well. Depending on how deep in the chain the transaction is, it could take a bitocin attacker weeks, months, or years, to rehash the rest of the Bitcoin mining algorithm code chain. And as I mentioned in Part 1, as long as the attacker does not control a majority of the processing power in the network, the rest of the network will be adding new blocks on to the main chain faster than the attacker can add blocks to his fraudulent chain, guaranteeing that the legitimate chain remains the longest and the attacker’s chain is ignored.



Six Confirmations



The only exception to the above rule is if the attacker simply gets lucky. As we noted, it takes the Bitcoin mining algorithm code network an average of 10 minutes to find a Bitcoin mining algorithm code block. It should take Bitcoin mining algorithm code single attacker with, say, 10% of the processing Bitcoin mining algorithm code in the network 100 minutes to find a valid block (200 minutes at 5% etc), but those are just averages. It’s theoretically possible that an attacker could get lucky and mine a block in 1 minute when it’s supposed to take him an average of 100 minutes. If that block contained a double spend, it’s possible the attacker’s fraudulent transaction would get included Bitcoin mining algorithm code the block chain and his legitimate transaction rejected (the rest of the network minimg think the legitimate transaction is the double spend). The deeper a transaction is in the block chain, however, the more times in row the attacker would need to get lucky and mine a block before the rest of the network to extend his chain longer than the main chain. From a probability standpoint, the chances of such an attack succeeding decrease exponentially with each subsequent block. It’s kind of like winning the lottery a number of times in a row. In the original white paper Satoshi Nakamoto calculated the probabilities that an attacker could get lucky and pull off a double spend. In the following table q is the percentage of the network controlled by the attacker, P is the probability an attacker could get lucky and override z number of blocks.



Given the above probabilities we can see that an attacker with 10% of the network’s processing power would have a.024% chance of getting lucky Bitcoin mining algorithm code overriding six blocks. Ibtcoin is usually why it is recommended Bitcoin mining algorithm code if you are selling something expensive, you should wait until your transaction is six blocks deep (six confirmations in Bitcoin lingo) before actually handing Bitcoin mining algorithm code the merchandise.



Ok that’s it for now. This post got long in a hurry. I was going talk a little bit about mining pools, but maybe I’ll save that for a Part 3. Hope you enjoyed these posts and I hope algorithn learned something.



Like this:



LikeLoading.




Related




Tags: Bitcoin, Cryptography



Is The Bitcoin Code a Scam? Beware, Read our Review First



Litecoin Scrypt Algorithm Explained



Last Updated: 18th December 2018



Scrypt is a hash function that was miming used by the cove, Litecoin, as an alternative to the more well-known SHA-256 hash function. Scrypt and SHA-256 are used as mining algorithms within the Litecoin and Bitcoin protocols respectively. Both operate within the proof-of-work consensus mechanism where a miner is required to find a nonce value (a variable selected by the miner), such that, when a candidate block header is hashed, the resulting output is equal to or lower than the given Bitcoin mining algorithm code. Algorihtm target is a measure of how difficult it is for a miner to produce a valid block; the lower the target value, the more difficult it will be for a miner to generate a valid block. Conversely, the higher the target value, the easier it is for a miner to generate a valid block. The block generation time of Litecoin is 2.5 minutes, therefore, the target will automatically adjust in difficulty so that a successful block is produced by a miner every 2.5 minutes.



For example, if the nonce were to be variable “12345”, this would be placed in the block header to be hashed, such that:



Where x = hash output value,



X = Algoritm header)



If the resulting hash output value, in this case ‘x’, proves to be above the target, the miner must try again. The miner then changes the nonce to another variable, e. g. “90872”, Bitcoin mining algorithm code places this inside the block header. If the resulting hash output value proves to be below the target, the miner’s block is then relayed to Litecoin nodes on the network in order to be Bitcoin mining algorithm code & SHA-256

Both the Scrypt and SHA-256 hash functions are Bitcoin mining algorithm code intensive as they both require raw computational power in order to Bitcoin mining algorithm code a large number of possible solutions for their respective functions. For example, according to Bitcoin mining algorithm code, as of writing, the current hash rate on the Litecoin network is 146 TH/s. What this means is, there are 146 trillion hash computations being performed every second by miners on the Litecoin protocol. However, what differentiates the Scrypt function, from the SHA-256 function, is that it is also Memory intensive. Scrypt is memory intensive because as well as requiring miners to generate numbers rapidly, these generated numbers are stored in the Random Access Memory (RAM) of the processor, which then needs to be accessed before submitting a result.



In terms of overall hashing power, Scrypt based protocols have a lower hash rate than SHA-256 based protocols. Currently, according to Blockchain. info, the Bitcoin protocol has a hash rate of roughly 45,000,000,000 TH/s – significantly more than that of the Litecoin.



Why use Scrypt?



The Scrypt hash function was initially implemented by the Litecoin development team to avoid what are known, Application-Specific Integrated Mniing (ASICs), from being able mine on the Litecoin network. When mining for cryptocurrencies, users typically have an option between: a CPU, Bltcoin or ASIC miner.



ASICs are computationally superior to CPUs and GPUs, i. e. they are able to generate more hashes per second. Therefore, miners who use any other device other than an ASIC to mine for a cryptocurrency, are put at a disadvantage. However, the Scrypt mining algorithm was introduced to prevent ASIC mining from taking place because the algorithm is memory intensive; ASIC miners were initially not well-suited to mine on Scrypt-based protocols, and thus, miners who used CPUs and GPUs could remain competitive.



However, as time as gone on, the initial “ASIC-resistance” of the Scrypt mining algorithm has disappeared. Scrypt-capable ASICs have been developed that allow for efficient mining of any cryptocurrency that use the Scrypt algorithm. Consequently, CPUs and GPUs are no longer valid mining tools on the Litecoin network due Bitcoin mining algorithm code their inferior computational power, when compared to ASICs.



Bisola Asolo

Комментариев нет:

Отправить комментарий