惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
小众软件
小众软件
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - Franky
Jina AI
Jina AI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Y
Y Combinator Blog
V
Visual Studio Blog
C
Check Point Blog
阮一峰的网络日志
阮一峰的网络日志
U
Unit 42
量子位
人人都是产品经理
人人都是产品经理
博客园 - 聂微东
M
MIT News - Artificial intelligence
爱范儿
爱范儿
B
Blog RSS Feed
MyScale Blog
MyScale Blog
H
Help Net Security
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
美团技术团队
L
LangChain Blog
D
Docker

ashishb.net

A day in Luxembourg - the richest country in the world I was asked to install malware during a fake interview Book summary: Breakneck - China's quest to engineer the future by Dan Wang Book summary: How to Teach Your Baby to Read Book Summary: The Discontented Little Baby Book by Pamela Douglas Introducing Amazing Sandbox - run third-party tools and AI agents securely on your machine Why software outsourcing gets a bad reputation? Book summary: The Natural Baby Sleep Solution by Polly Moore A day in Antwerp, Belgium Journey of online influencers Two days in Brussels, Belgium Shortcuts - when we love them and when we don't A visit to Rakhigarhi Three days in overhyped Paris Empty Japan, crowded Tokyo The real lock-in in GitHub is not the code, but the stars 11-day Norwegian Breakaway East Caribbean cruise Sanskrit and Sri Lankan Air Force Use REST with Open API The Achilles heel of American capitalism Costa Rica in 4 days At a juice stall in Sri Lanka A short stay at Warsaw, Poland Best practices for using Python & uv inside Docker Two days in Vilnius, Lithuania How IntelliJ IDEs waste disk space Pregnancy Why there aren't many digital nomads from India Two days in Riga, Latvia To keep your machine secure, run third-party tools inside Docker
Stanford CS251: Lecture 4
Ashish Bhatia · 2019-04-01 · via ashishb.net

Lecture 4: Blockchains

80 bytes block consists of 32 bytes previous block hash, 32 bytes transactions Merkle tree hash, timestamp, bits, nonce, etc. Each block is <= 1MB to minimize the propagation times. Therefore, large transactions require more service fee to compensate miners to include the transaction in the block.

Miner’s transaction checks

  1. ScriptSig (from spending transaction) || ScriptPubKey (from funding transaction) executes and this should produce non-empty stack. Empty stack or zero is false.
  2. Transaction inputs are in the UTXO set.
  3. Sum of all outputs <= Sum of all inputs

As of Oct 2016, 43M UTXO, 475K unique addresses, and 15.9M BTC in circulation.

Transaction signature is over the whole transaction (except the signature itself) => miners cannot modify any portion of the transaction. P2PKH (Pay to public key hash) does not reveal the public key (but only its hash), this provides added security in terms of someone brute-forcing the public key. The signature scheme ECDSA does not have strong unforgeability which means that miner can change ECDSA pair (r, s) to (r, s’). This changes the transaction hash. Therefore, transaction hashes cannot be relied upon. Not knowing this fact lead to Mt. Gox collapse. Segregated Witness, eventually, fixed this by moving signatures out of the transaction hash.

There are two types of transactions

  1. Pay to Public Key hash (P2PKH)
  2. Pay to script hash (P2SH) Funding transaction scriptPk: HASH160 H() EQUAL # Only hash of the script is exposed at the funding time Spending transaction scriptSig: <sig1> <sig2> ....<sigN> <redeemScript> Miner verifies that
    1. ScriptSig | ScriptPk -> true => script is correct
    2. ScriptSig -> true => script is satisfied This is different from what miner does for P2SH

Another example of P2SH is multi-sig: m out of n signatures required. Redeem script: <2> <pk1> <pk2> <pk3> <3> CHECKMULTISIG Bitcoin implement is buggy so it eats the first element of the ScriptSig, therefore, add a dummy first element <0> ScriptSig: <0> <sig1> <sig3> <redeemScript> Applications of multi-sig =>

  1. Co-signatory - 2 out of 2 signatures required
  2. Escrow - buyer will fund a 2-out-3 signatures transaction which two of the buyer, seller, and judge’s signatures.
  3. Micropayments - which accumulate and send together to save on the transaction fee.

Bitcoin Address

Base 58 - a-z, A-Z, 0-9 excluding {0,o, i, l} => 34 char addresses

Addresses for P2PKH starts with 1. Addresses for P2SH starts with 3.