Introduction to Blockchains
All Aboard the Hype Chain
All Aboard the Hype Chain
$ whoami
Lucy Wyman | @lucyCwyman
Software Engineer - Bolt
2.4.4 :001 > require 'digest'
=> true
2.4.4 :002 > Digest::SHA256.hexdigest("Hello SCaLE!")
=> "0bb4b1b2992676414a822941f3160c7669404acb8bb8da18278e4f6aabf83b92"
2.4.4 :003 > Digest::SHA256.hexdigest("Longer input, same length output")
=> "380e12f12589eda081e21c794e6379053c75a54c3394ddad0d84026c1a6947ab"
- Each block stores owner's public-key (think RSA)
From https://github.com/lucywyman/blockchain-example
class Block
def initialize(index, previous_hash, timestamp, data)
@index = index
@previous_hash = previous_hash
@timestamp = timestamp
@data = data
@hash = self.hash_block
end
end
class Blockchain < Array
attr_reader :chain
def initialize
@chain = [self.first_block]
end
def first_block
return Block.new(0, "0", Time.now, "Hello blockchain!")
end
def add_block(name)
index = @chain[-1].index + 1
previous_hash = @chain[-1].hash
timestamp = Time.now
data = "#{name} voted for Hermione Granger"
block = Block.new(index, previous_hash, timestamp, data)
@chain.push(block)
end
"An issue in this ongoing debate is whether a private system with verifiers tasked and authorized (permissioned) by a central authority should be considered a blockchain.[51][52][53][54][55]" Wikipedia
"Blockchain was built to solve a social problem, not a technical problem"