Skip to content

ac259/satoshi-hodler-nakamoto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

satoshi-hodler-nakamoto

My attempt of building the bitcoin from scratch. I wrote this to better understand the "Bitcoin" and Nakamoto Consensus. This implementation is based on the initial whitepaper Bitcoin: A Peer-to-Peer Electronic Cash System by Satoshi Nakamoto [link]

Components

  • Coin

    • Chain of digital signatures - elliptical curve digital signature algorithm [link]. Transfer of a coin - digitally sign [previous transaction + public key of next owner]. Code for a simple ecdsa:(from stackoverflow)
      Usage:
    	# SECP256k1 is the Bitcoin elliptic curve
    	sk = ecdsa.SigningKey.generate(curve=ecdsa.SECP256k1) 
    	vk = sk.get_verifying_key()
    	sig = sk.sign(b"message")
    	vk.verify(sig, b"message") # True
    

    To verify an existing signature with a public key:

        message = b"message"
        public_key = '98cedbb266d9fc38e41a169362708e0509e06b3040a5dfff6e08196f8d9e49cebfb4f4cb12aa7ac34b19f3b29a17f4e5464873f151fd699c2524e0b7843eb383'
        sig = '740894121e1c7f33b174153a7349f6899d0a1d2730e9cc59f674921d8aef73532f63edb9c5dba4877074a937448a37c5c485e0d53419297967e95e9b1bef630d'
        vk = ecdsa.VerifyingKey.from_string(bytes.fromhex(public_key), curve=ecdsa.SECP256k1)
        vk.verify(bytes.fromhex(sig), message) # True
    
  • Time Stamp Server
    taking a hash of a block of items to be timestamped and broadcast the hash to the network.

  • Proof of Work
    Hash Puzzle that is computationally expensive.

  • Block

  • Nodes and Miners

  • Merkle Trees - Hash Trees for transaction

  • UTXO Unspent Transaction Output
    This term was not used in the white paper however, this is the same as section 9: Combining and Splitting Value in the paper.

  • Mining
    Circulation of coins

  • Nakamoto Consensus

  • Limits

    • Maximum number of coins
    • Limiting the number of blocks produced
    • Mining incentives
  • Network

About

My attempt of building the bitcoin from scratch.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages