Bitcoin Forum
November 12, 2024, 12:22:09 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Where can I find more information about the concept Cryptography and Bitcoin  (Read 1143 times)
FreshJR (OP)
Member
**
Offline Offline

Activity: 65
Merit: 10



View Profile
March 29, 2012, 06:10:02 AM
Last edit: March 29, 2012, 06:33:01 AM by FreshJR
 #1

Hi, I have been around for a month and understand how bitcoin generally works, but I'm still fuzzy in certain areas.  I want to know whats happening under the hood mathematically.  I searched the Bitcoin wiki and couldn't find what I was looking for.

Basically here is what I understand.

Quote
Wallets

Wallet A consists of a public key (your wallet/routing number) and the private key (your signature)
Wallet B consists of a public key (your wallet/routing number) and the private key (your signature)

These wallets are stored in plain text in the wallet.dat file.  Encrypting the wallets prevents from someone with access to the wallet.dat file from copying your routing number and signature in plaintext.  After encryption, its just a jumble of random numbers that can only be rearraged with the encryption pass phrase.

Your public key is the only thing needed to lookup your balance in the blockchain by the use of the client.  (The client can also sign transactions with your private key)

Transactions

This is the a transaction with A sending money to B

Computer A  
-Gets routing number of B
-Specifies amount sent and date.  Signs this phrase with your signature which produces the transaction phrase.
-This transaction phrase is sent to the bitcoin distrusted network in a block???

Computer B
-reads the transaction message from the distributed network.

The balances of all the wallets are determined according to the distributed network.
The individual blocks in the block chain contain transactions.
To determine the balance of any a wallet is nessasary to start from the genesis block and add up all the transactions pertaining to that wallet through the entire blockchain

Mining
Confirm the transaction.

CONFUSION STARTS HERE  Huh  I need to understand this part a lot more.

I know the block chain is the result of the double SHA256 mathematical formula.  This formula uses the values from the previous blocks as a input someone to make next block. (discarding any possible forks that are made durring very rare and specific circumstances)

Here is the layout

Wallet A
--contains XX BTC as result from transaction #1 (Info stored in block 1)
--contains XX BTC as a result from transaction #6 (Info stored in block 3)

Wallet B
--contains XX BTC as result from transaction #2 (Info stored in block 1)
--contains XX BTC as a result from transaction #14 (Info stored in block 4)


I would like to find out how new transactions are combined into a block.  How false transactions are denied.

Basically on what level in the bitcoin network do miners get their work, where do they send their work.


MOST IMPORTANTLY**

If the public and private key of the same format (encryption) as the block chain.  What prevents using the blockchain as a large crack table (rainbow table).  Can't the public keys be compared with transaction keys and the corresponding hash value be matched up with the private key to essentially use the network against itself to bruteforce individual wallets.
Etlase2
Hero Member
*****
Offline Offline

Activity: 798
Merit: 1000


View Profile
March 29, 2012, 06:28:53 AM
 #2

Miners add up all the transactions and a hash of the previous block into a SHA256 hash. A hash is basically a reduction of all the data into a completely random string of bits. As more transactions come in, the miners re-do the hash.

What the miners are doing is attempting to find is a nonce that gives the hash a certain number of leading zeros that is equal to or greater than the difficulty (this is really hard). If this is found, the nonce is a winner and you get coins. The block can be verified in a single operation by hashing the nonce and the data.

edit: the value of the hash (in leading zeros) needs to be less than the target which is based on the difficulty.

FreshJR (OP)
Member
**
Offline Offline

Activity: 65
Merit: 10



View Profile
March 29, 2012, 06:37:12 AM
 #3

Miners add up all the transactions and a hash of the previous block into a SHA256 hash. A hash is basically a reduction of all the data into a completely random string of bits. As more transactions come in, the miners re-do the hash.

What the miners are doing is attempting to find is a nonce that gives the hash a certain number of leading zeros that is equal to or greater than the difficulty (this is really hard). If this is found, the nonce is a winner and you get coins. The block can be verified in a single operation by hashing the nonce and the data.

Simple enough.  This allows the latest block (and the entire blockchain) to be verified independently by the miners, but allows the rate of verification to be controlled.

I still want to know

-How is this block made
-How are real transactions accepted
-How are fake transactions signed an improper key, rejected
-How are shares related to the final hash
Etlase2
Hero Member
*****
Offline Offline

Activity: 798
Merit: 1000


View Profile
March 29, 2012, 06:41:48 AM
 #4

If the public and private key of the same format (encryption) as the block chain.  What prevents using the blockchain as a large crack table (rainbow table).  Can't the public keys be compared with transaction keys and the corresponding hash value be matched up with the private key to essentially use the network against itself to bruteforce individual wallets.

public and private keypairs use ECDSA, a public/private key algorithm. The block hashes use SHA256. They are two very different types of cryptography. No, the network cannot be used against itself to brute force wallets. Standard "encryption" usually means symmetric encryption (like encrypting files) which is a third and completely different form of cryptography again, one that is not used in bitcoin.

Simple enough.  This allows the entire blockchain can be verified independently with miners verified the blocks.

I still want to know

-How is this block made
-How are real transactions accepted
-How are fake transactions signed an improper key, rejected

The block is just a piece of data. The nonce and hash can be verified independently very easily yet is incredibly hard to produce. Once other miners see a winning block, they will accept it based on that easy verification.
Real transactions are accepted by making sure the digital signature is correct for the transaction based on the public key for the wallet making the transaction. I don't want to rehash intro to cryptography here because there are numerous links you can find on google for yourself.

Revalin
Hero Member
*****
Offline Offline

Activity: 728
Merit: 500


165YUuQUWhBz3d27iXKxRiazQnjEtJNG9g


View Profile
March 29, 2012, 06:45:46 AM
 #5

I want to know whats happening under the hood mathematically.

You may want to read the white paper: http://bitcoin.org/bitcoin.pdf  .  It may answer some questions, but the source code may be the only answer to others.


Quote
Encrypting the wallets prevents from someone with access to the wallet.dat file from copying your routing number and signature in plaintext.  After encryption, its just a jumble of random numbers that can only be rearraged with the encryption pass phrase.

Only the private key / signature is encrypted.  Public keys / addresses / routing numbers have minor privacy implications but it's not worth encrypting them for most people since you'd then have to decrypt to check your balance.


Quote
This transaction phrase is sent to the bitcoin distrusted network in a block???

It is sent as a "transaction".  The network then floods it to everyone.  Computer B sees it if it happens to be connected.  The miners also see it, and add it to the list of transactions they are processing.  When they succeed (every 10 minutes on average), they then send the signed "block" to the network, which floods it.

In other words, the transaction exists independently at first, and then is included into a block.  Before inclusion, the transaction is "unconfirmed".  After inclusion the transaction has "n confirmations", where n is the number of blocks since it was included.


Quote
I would like to find out how the transactions are combined into a block, and how this block is verified.

The transactions are simply listed in a prospective block.  A SHA256 checksum is made of the transactions.  That checksum, plus the signature of the previous block, the current time, etc, are called the "block headers".  The block must be "signed" by taking the headers and adding an arbitrary "nonce".  That combination is then hashed again and if it includes enough leading zeroes (the quantity determined by the "difficulty") it is considered a valid block.  If not, the miner changes the nonce and tries again until they find one that works.  When a match is found the complete block (headers plus transaction list) is flooded to the network and future miners include its signature in the next blocks they are creating.

      War is God's way of teaching Americans geography.  --Ambrose Bierce
Bitcoin is the Devil's way of teaching geeks economics.  --Revalin 165YUuQUWhBz3d27iXKxRiazQnjEtJNG9g
Revalin
Hero Member
*****
Offline Offline

Activity: 728
Merit: 500


165YUuQUWhBz3d27iXKxRiazQnjEtJNG9g


View Profile
March 29, 2012, 06:48:23 AM
 #6

-How are fake transactions signed an improper key, rejected
-How are shares related to the final hash

Fake transactions signed by the wrong key won't have the proper signature.  Everyone (relay nodes, miners) just drops them.

Shares are partial results - some leading zeroes on the signature, but not enough.  They show you're performing work.

      War is God's way of teaching Americans geography.  --Ambrose Bierce
Bitcoin is the Devil's way of teaching geeks economics.  --Revalin 165YUuQUWhBz3d27iXKxRiazQnjEtJNG9g
FreshJR (OP)
Member
**
Offline Offline

Activity: 65
Merit: 10



View Profile
March 29, 2012, 07:14:00 AM
Last edit: March 29, 2012, 07:28:17 AM by FreshJR
 #7

WOW, that was quick.  Its 2AM over here for me but I now have a firm grip of what the hell is actually going on.  Thanks guys.


The transactions are simply listed in a prospective block.  A SHA256 checksum is made of the transactions.  That checksum, plus the signature of the previous block, the current time, etc, are called the "block headers".  The block must be "signed" by taking the headers and adding an arbitrary "nonce".  That combination is then hashed again and if it includes enough leading zeroes (the quantity determined by the "difficulty") it is considered a valid block.  If not, the miner changes the nonce and tries again until they find one that works.  When a match is found the complete block (headers plus transaction list) is flooded to the network and future miners include its signature in the next blocks they are creating.

So this is the time intensive task since it is very hard to meet the current difficultly. Yet the actual solve time is completely random based on probability.  Since the SHA256 check sum is continually updated with every iteration this method ensures correct results and a block cutoff.  I'm assuming the nonce values randomly generated since incrementing their value makes no sense from a mathematical standpoint.

One last question (SORRY!!)  How is the nonce value chosen?  I know computers cannot generate a random value yet (but I think I read intel is working on feature with haswell). Computers simply choose a random value based on starting value in a predefined table, and number of times the fuction was run.  An effective pseudorandom method is to use the current time as the starting point in the table.  Depending on the rate of new transactions being adding to the block, would major inefficiencies occur due to double calculation of the same nonce values.  This depends on the current on how far apart in iterations run the miners and the difference in calculation rates.

EDIT:  Never mind, by modifying the desired start point to incorporate the current iteration number has the potential the prevent this problem.

That C++ class freshman year of college (only computer sci class I took), really paid off.  

Thanks for all the help in this thread.  I have no more questions and I am now very proficient in bitcoin architecture.  
Revalin
Hero Member
*****
Offline Offline

Activity: 728
Merit: 500


165YUuQUWhBz3d27iXKxRiazQnjEtJNG9g


View Profile
March 29, 2012, 07:44:12 AM
 #8

Linearly increasing the nonce works fine.  Each increment will generate a completely new SHA256 signature and is just as likely to get the string of zeroes that you need.

I'm not sure what you mean by iterations.  You can explain it if you'd like me to double check what you know.  Smiley

      War is God's way of teaching Americans geography.  --Ambrose Bierce
Bitcoin is the Devil's way of teaching geeks economics.  --Revalin 165YUuQUWhBz3d27iXKxRiazQnjEtJNG9g
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!