blockchain-2023-2024-spring

Addresses

Верифицирането на транзакциите става чрез математика вместо чрез central authorities.

img

Public/Private key addresses (creation)

Bitcoin -> UTXO
Ethereum -> Account balance model

❗ How are addresses added to the protocol – не се добавят, те са числа, протокола не го интересува, стига да са валидни, приемат се
❗ Можем да пратим транзакция на адрес, който не съществува, транзакцията е валидна; при положение, че се появи такъв адрес, ще получи ресурса

Типове акаунти в Ethereum

Externally Owned Account(външни акаунти, човешки акаунти)

Външен за самата мрежа, генериран от частен ключ. В Ethereum към този момент само този тип може да инициират транзакции.
Всяко update-ване на ledger-а се случва от такъв акаунт.

$Address(Key_{pb}) = Bits_{96..255}(Keccak(ECDSA(Key_{pr})))$

  1. Randomly create a $Key_{pr}$ - 32 bytes, hex-encoded 64 characters
  2. Perform ECDSA(elliptic curve digital signature algorithm)(using ECM) on the secp256k1 elliptic curve $Key_{pr}$ times $\to$ results in a $Key_{pb}$ - 64 bytes, hex encoded 128 characters
  3. Hash the $Key_{pb}$ using keccak256 $\to$ results in 64 characters, 32 bytes hash code
  4. Take the last 20 bytes of the hash code $\to$ results in an address(account) - 40 character, 20 bytes
  5. Put Ox prefix in front of the address for readability

Contract Account

(междинни връзки, не могат да бъдат в краищата)

$Address_{contr}(Address_{sender}, Nonce_{sender}) = Bits_{96..255}(keccak256(RLPEncode([Address_{sender}, Nonce_{sender}])))$

  1. Take (externally owned account) $Address_{sender}$ that deploys the contract
  2. Take that Address’s $Nonce_{sender}$
  3. Encode in RLP(recursive length prefix) both fields as an array $[Address_{sender}, Nonce_{sender}]$
  4. Hash the serialized result with keccak256
  5. Take the last 20 bytes of the hash
  6. Put Ox prefix for readability

Понеже това е детерминистичен процес, можем да определим как nonce ще се увеличи, можем да пратим крипто на следващите адреси.


Side note

img


Side note P2PKH format

транзакция, в която има smart contract – internal transaction


Wallets

Hot wallets

Cold wallets

Types of wallets according to structure

Mnemonic

Generating mnemonic

  1. Generate 128/256 bits of(crytographically secured source of) entropy
  2. Hash with SHA256 and take first 4/8 bits(checksum)
  3. Attach the checksum at the end of the entropy(step 1)
  4. Group the resulting data by 11-bit groups
  5. Each word corresponds to a word form a special dictionary
  6. The list of words(order is important) is the mnemonic code
  7. Input the mnemonic and a passphrase(or salt - optional) into a key-stretching function
  8. The key-stretching(PBKDF2) function hashes the input 2048 times using HMAC-SHA512 and generates a 512 seed code.
  9. The seed is hashed again. The resulting 512-bit hash is divided into 2 equal 256 parts
  10. The left 256 group becomes the Private Key(Master Private Key)
  11. Use ECM(elliptic curve multiplication) to generate the Public key from the Private Key, just as usual

Използваме дясната част за генериране на публичен ключ, получаваме йерархия от ключове…

confirmation

Side note BIP - Bitcoin Improvement Proposal

❗❗❗ Тестови ethereums