Blockchain Technology Flashcards

1
Q

bitcoin vs bitcoin cash

A
  • split based on how to deal with slow transactions

Bitcoin

  • started using segregated witness (SegWit2x)
  • reduces amount of verification data for each block
  • Bitcoin also plans to double block size (to 2mb)

Bitcoin Cash

  • felt SegWit2 didn’t go far enough
  • increases block size to 8mb (up from 1mb)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

hash functions

A

Consists of:

  • input: message
    • can be any length
  • output: digest, tag, hash, fingerprint
    • fixed in length

Desired traits

  • should be fast
  • collision resistant
  • hard to infer anything about input
    • was it even or odd
  • well distributed (should look random)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

51% Attack

A
  • hypothetical in which one actor aquires control of over 50% of mining rigs
  • can double spend
  • can prevent others’ transactions
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

digital signature

A
  • scheme for verifying the completeness of a message and the identity of its sender
  • Examples: RSA, DSS

Steps

  1. Alice wants to sign a document
  2. Alice generates 2 keys
    1. Private key
    2. Public key
    • They’re generated at the same time
    • Cannot get private key from the public key
  3. Alice hashes the document with private key to produce signature
  4. Bob wishes to verify the message (does this message really generate this signature)
  5. Bob uses a verification function on the message, signature, and public key determine if message is valid
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

bitcoin block

A
  • a grouping of individual transations

Includes

  • mutliple unrecorded transactions
  • a special transaction representing miners’ reward
  • an encoding of previous transaction block (to ensure continuity)
  • a proof-of-work puzzle
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

bitcoin transaction - steps

A

Steps

  1. Alice wishes to send money to Bob
  2. Alice uses a bitcoin client to record transations in ledger
  3. Alice specifies
    1. Hashes from previous transactions to her account (verifying that she has the money to begin with)
    2. List of recipients for bitcoin (their public keys)
    3. Amount to transfer (usually less than her present balance)
    4. Specify change going back to her
    5. Leftover money is used for transaction fee
  4. Takes transaction details and generates a digital signature
  5. Alice appends transaction with digital signature
  6. Alice broadcasts complete transaction
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

bitcoin mining - steps

A
  • miners confirm the order in which transactions take place in order to prevent double-spending

Steps

  1. Miners gather transactions that haven’t been mined into a block
  2. Also adds an additional transaction representing his reward
    • coinbase/generation transaction
    • how new bitcoins are created
  3. Starts hashing them in pairs to get a single digest value
  4. Hashes this transaction with most recent block in network to produce a number
  5. Convert that number into a challenge (for proof-of-work)
  6. Miner performs proof-of-work
  7. He generates many potential proofs to the challenge until one works
  8. Once found, miner announces proof
  9. This miner’s blockchain becomes the new official chain; other miners build on it
  10. The more leading zeros required, the more difficult it is to generate a proof
  11. Number of zeros is calibrated so that it takes a node, on average, 10 minutes to find a proof
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

longest chain

A
  • chain with PoW puzzles that were the most difficult to solve
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

bitcoin money supply

A
  • money supply limit is 21M bitcoin
  • every time 210K blocks is generated, reward gets cut in half
  • it takes about 4 years to generate 210K block
  • entire supply will be generated by 2140
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

proof of work

A
  • a security measure/intentional hurdle incorporated into most crytocurrency protocols
  • PoW puzzles have a difficulty score that describes how hard puzzle is
  • puzzles are difficult to solve but easy to verify

Steps

  1. Imagine there’s a challenge string
  2. Miner generates a random number, called a “proof” or a “nonce”
  3. He then concatenates the challenge string and the proof
  4. And hashes the result
  5. If the hash has the requisite number ofleading zeros
  6. Then the challenge has been solved
  7. There’s no effective way to guess or infer the solution, so the miner has to do this with brute force
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

proof of stake

A
  • bitcoins are assigned a stake value
  • value grows as long as bitcoin isn’t used
  • when bitcoin is used for transaction, “stake” value is reset
  • people who make fraudulent confirmations will lose money
  • in PoS, blocks are forged, rather than mined
  • the probability that an individual can forge a block is proportional to the stake they have
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

ethereum tokens

A
  • boost ether’s value by creating a need for the currency
  • issued via crowdsale called Initial Coin Offering (ICO)
  • ERC20 is a standard interface for tokens
  • Must implement the following:
  1. get the total token supply
  2. get the account balance
  3. transfer the token
  4. approve spending the token
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

hashrate

A
  • measure of mining power
  • number of nonces tried per second normalized by rashrate of the network
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

asic

A
  • application-specific integrated circuit
  • circuit that is designed for a specifc purpose
  • ex: video graphic cards
  • asic resistence
    • memory-hard puzzles
    • memory doesn’t improve as quickly as processing speed
    • puzzles that require memory won’t advantage asic as much
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

externally owned accounts

A
  • EOA
  • accounts that are owned by a private key
  • cannot contain EVM code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

byzantine fault tolerance

A
  • ability of a distributed network to handle the byzantine generals problem
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

two generals probelms

A
  • example of a consensus problem
  • there is no perfect solution

Setup

  1. Two aligned armies (A and B) have to decide whether to attack their opponent (C) tomorrow morning
  2. They will win if they attack together, but lose separately
  3. The armies are separated by the territory of army C
  4. They communicate through courriers, which may or may not make it
  5. They attempt to send messages back and forth in order to reach consensus
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

byzantine generals problem

A
  • example of a consensus problem
  • generalization of the two generals problem

Setup

  • a number of byzantine generals getting ready to attack a fortress
  • must decide if they will attack or retreat
  • but some generals might be traitors
  • the goal is to reach consensus even though one or more generals is a traitor
  • traitors can tell send different messages to different generals
  • how many traitors can the system tolerate?
    • (must be < 1/3)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

double spend

A
  • a deliberate fork
  • first, agent spends bitcoin
  • then agent creates another block at same level to send bitcoin to another person, and starts mining on that chain
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Gas

A
  • costs around 20K gas to set a value
  • storing data is generally more expensive that performing an action
    *
21
Q

EVM

A
  • Runs opcodes
22
Q

Ether

A
  • Currency of ethereum
  • Used to pay for computation
  • Smallest unit (base unit) called wei
23
Q

ABI

A
  • Application Binary Interface
  • Tells web3 how to interact with binary code on blockchain
  • JSON array
  • First element: send
    • Function name
  • Balance
  • data field
    • first 20 bytes are function call
    • rest is a parameter
24
Q

Three Types of Blockchains

A
  • Public blockchains
    • Normal blockchains
  • Consortium blockchains
    • Controlled by a preselected set of nodes (computers)
    • Only those preapproved nodes can sign transaction
    • Considered partially decentralized
  • Private blockchains (aka private networks)
    • Not necessarily considered legitimate blockchains
    • All permissions are kept centralized, by 1 node
    • Banks are experimenting with this
    • Applications: database management, auditing, and things specific to that organization
25
Q

Smart Contracts

A
  • Aid in transferring something of value in transparent and secure way
  • Eliminates middle party

Steps

  1. Buyer pays for product
  2. Receipt is held in virtual smart contract
  3. Seller gives buyer entry key on date specified beforehand
  4. If seller reneges, blockchain will automatically give refund on date key should have arrived
  5. If seller gives key early, blockchain holds it until agreed date
  6. Contract is saved on blockchain, so it cannot be altered once created
  7. If attempt is made to alter it, all parties are notified

Pros

  1. Autonomy: cannot be manipualted by third parties
  2. Trust: impossible to lose
  3. Backups
  4. Safety
  5. Speed
  6. Saves money: no intermediary
  7. Accuracy
26
Q

dApp

A
  • Distributed application
  • Runs on ethereum virtual machine
27
Q

DAO

(Democractic Autonomous Organization)

A
  • virtual organization where members can vote on issues
    *
28
Q

Wallets

A

2 Types of Wallets

  1. Externally Owned Accounts (EOA)
    • Create in your wallets
    • You own private key, public key and password
    • Have an ether balance
    • Can send trasactions
    • Have not code associated with them
  2. Contracts Accounts
    • Deployed in blockchain
    • Contain code
    • Have an ether balance
    • Code is triggered by transactions or messages
    • Can manipulate its own persistent storage
29
Q

Keypair

A
30
Q

private network

A
31
Q

Solidity

functions

A
  • functions can be make to return variables or not
  • semicolons are required
  • constructor
    • just like Java constructor
    • runs on deployment, and never again
    • costs gas
  • constant functions
    • can return values, but cannot change anything on blockchain
    • can return more than one thing
    • don’t cost gas to run
    • syntax:
    • function getSomeVar() constant returns (uint) {
      return someVar
      }
      *
32
Q

Solidity

Types

A
  • bool
    • auto-initialized to false
  • int (integer)
    • ranges from int8 - int256
  • uint (unsigned integer)
    • ranges from uint8 - uint256
    • auto initialized to zero
    • can only be positive
  • bytes
  • address
    • holds a 20 byte value (size of ethereum address)
    • has properties balance (gets balance at that addres) and transfer (function that sends wei from contract address to involking address)
  • string
  • arrays
    • can be either fixed or dynamic
  • enums
    • used to create user-defined types
  • structs
  • mappings
    • hash tables
33
Q

Solidity

access contact from another contract

A

2 Options

  1. Instantiate a new instance of contract
    • myContract = new ContractA()
  2. Store reference to existing contract
    • myContract = ContractA(addressA)
34
Q

Solidity

msg

A
  • special object
  • properties
    • sender
      • address of individual that sends funds
35
Q

Solidity

Inheritance

A
  • contracts can inherit from each other like classes in other languages
  • use keyword is to inherit
  • ex: contract con1 is con2 { }
36
Q

Solidity

Data Location

A
  • Three places to store data in solidty:
    1. storage (persisting)
    2. memory (non-persisting)
    3. call-data (where external function params are stored)
  • When assigning from a storage to memory variable, always creates an independent copy
  • Assignments to local storage variables are references
  • Forced data location
    • parameters (not return) of external functions: calldata
    • state variables: storage
  • Default data location:
    • parameters (also return) of functions: memory
    • all other local variables: storage
37
Q

Web3

A
  • Interface between ethereum and javascript (and html)
  • Get access contracts as objects
    • Create contractor from contract, and then instantiate
    • Syntax:
    • var MyContract = (web3.eth.contract(abiArray))
    • var contractInstance = MyContract.ad([address])
38
Q

public variable

A
  • can access public variables without using gas
  • an accessor is created for each public variable
  • functions are public by default
39
Q

testrpc

A
  • simulated blockchain that runs on memory on computer
40
Q

interface

A
  • essentially an api
  • a json object that describes all of the functions in contract
    • their params, arguments, what they return, etc.
41
Q

migration

A
  • scripts that allow you to automate tasks related to setting up contracts
    • mass-deployments
      *
42
Q

library

A
  • makes functionality available to multiple contracts at once
43
Q

deployment steps

A

Steps

  1. Write contract
  2. Place contract in contracts folder
  3. Run truffle compile
  4. Add your contract to 2_deploy_contracts.js
  5. Turn on testrpc
  6. Run truffle migrate
  7. truffle migrate
44
Q

transaction/call

A
  • transaction
    • writing to network/changing data
    • ex: sending ether; creating contracts
    • transactions cost ether and take time
    • typically aren’t processed immediately
    • typically return transaction id, rather than return value
    • in function definition: just returns
  • call
    • reading from network
    • free to run
    • processed immediately
    • in function definition: constant returns
    • in function call: myContract.getBalance.call()
45
Q

abstractions

A
  • JavaScript wrappers for solidity contracts
  • Allow you to interact with contract in js
46
Q

module loader/module bundler

A
  • allows you to code modules separately, and combine them in the end
  • generates static assets
  • examples:
    • webpack
    • require.js
    • browserify
47
Q

package manger

A
  • npm
    • mainly for node packages
  • bower
    • mainly for frontend packages
  • yarn
48
Q

task runners

A
  • used to automate tasks, such as converting from SASS to CSS, or minifying
  • examples:
    • gulp
    • grunt
49
Q

bitcoin script

A
  • uses stacks
  • composed of op codes
  • turing incomplete
  • primarily used to validate bitcoin transations