Proof of Work SHA256 | Rust Language

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 มิ.ย. 2024
  • This video shows an example of "proof of work" using SHA256 in Rust and a Python script to check the result. I've used the "ring" crate for the SHA256 hash algorithm.
    🟩 redandgreen.co.uk/proof-of-wo...
    - chapters -
    00:00 Intro - Proof Of Work
    00:34 code
    04:22 lessons learned
    09:05 python check
    Rust Playground
    ---------------------------
    🟩 play.rust-lang.org/?version=s...
    Proof of Work (PoW) is a consensus mechanism widely used in blockchain networks to secure transactions and create new blocks. In a Rust programming language context, implementing PoW involves a cryptographic puzzle-solving process. Miners, or network participants, compete to find a nonce (number used once) that, when combined with the block data, produces a hash with specific leading zeros.
    In the Rust example, you would start by defining the block structure and including a nonce field. Miners iterate through different nonce values, hashing the block data until they find a hash meeting the predetermined criteria. This process is computationally intensive, requiring significant computational power and time.
    Once a miner successfully discovers a valid nonce, they broadcast the solution to the network. Other nodes can easily verify the solution by applying the same hash function. The first miner to solve the puzzle gets the right to append the new block to the blockchain and is rewarded for their effort, typically with cryptocurrency.
    This PoW implementation in Rust demonstrates the decentralized nature of blockchain consensus, where participants engage in competitive computation to secure the network and validate transactions.
    Linux Hosting - VPS server - Webdock
    ----------------------------------------------------------------
    🟩 Webdock Linux Hosting : webdock.io/en?maff=wdaff--170
    #rustlang #learningrust #LearnRust

ความคิดเห็น • 3

  • @flyingbluelion
    @flyingbluelion 2 หลายเดือนก่อน +1

    In a real blockchain proof of work, the data to be hashed is a list of potential bitcoin transactions. Actually there are no transactions, all you can do is give bitcoin away. Thats's it.

    • @learning_rust
      @learning_rust  2 หลายเดือนก่อน +1

      Yes, this was obviously a dumbed down version, it was interesting nonetheless, especially making the difficulty go up by just 1 and how it affects the time to find an acceptable hash. The beauty is that it can be verified so easily?