Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ビットコイン トランザクション色々
Search
suish
July 18, 2017
Technology
1
2.3k
ビットコイン トランザクション色々
トランザクション構造と生トランザクション P2PKHのトランザクション署名検証
suish
July 18, 2017
Tweet
Share
Other Decks in Technology
See All in Technology
オブジェクト指向CSSが叶えたかったことと、CSSのいま / The aims of Object-oriented CSS and the current state of CSS usage
shinkufencer
11
3.7k
関数型DDDの理論と実践:「決定を遅らせる」を先につくり、 ビジネスの機動力と価値をあげる
knih
2
500
バッチ処理のSLOをどう設計するか
rynsuke
7
590
XRミーティング 2024-03-20
1ftseabass
PRO
0
100
GitHub最新情報キャッチアップ 2024年3月
dzeyelid
17
3.2k
やっていきテスト
k6s4i53rx
0
160
Azureコストは水道代/The_47th_Tokyo_Jazug
aeonpeople
3
390
Why do you get AWS certificates
hirosys
0
120
任意コード実行の原理
ffri
0
190
オブジェクト指向宗教史
tanakahisateru
14
12k
匠MethodとRDRAとICONIXとDDDで実現する一気通貫オブジェクト指向開発
haru860
4
2.1k
Vos logs méritent mieux que la config par défaut
lyrixx
2
430
Featured
See All Featured
The Language of Interfaces
destraynor
150
23k
What's new in Ruby 2.0
geeforr
335
31k
The Cult of Friendly URLs
andyhume
73
5.6k
Bootstrapping a Software Product
garrettdimon
PRO
302
110k
Rebuilding a faster, lazier Slack
samanthasiow
72
8.2k
A Modern Web Designer's Workflow
chriscoyier
689
190k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
28
5.9k
A better future with KSS
kneath
230
16k
Optimizing for Happiness
mojombo
369
69k
Documentation Writing (for coders)
carmenintech
59
3.8k
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
101
6.6k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
5
1.4k
Transcript
1
0. 1. 2. 3. 4. P2PKH 5. ※ segwit Tx
2
@sarmases 1 Bitcoin/Ethereum/Rootstock Scala 3
4
? (1/2) Bitcoin ( ) 5
? (2/2) 6
7
4bytes 0x01000000(1 ) Input 1-9bytes(VarInt) 0x02(1 ) Input Output 1-9bytes(VarInt)
0x02(1 ) Output 4bytes 0x00000000 ※ 5 (0x1DCD6500) 0 8
TxID 32bytes UTXO Index 4bytes 0x01000000 Unlocking Script 1-9bytes(VarInt) 0x6B
Unlocking Script 4bytes 0xFFFFFFFF ※ Tx Tx 0xFFFFFFFF 9
8bytes 0x01000000 Locking Script 1-9bytes(VarInt) 0x02 Locking Script satoshi 1satoshi
10
VarInt < 0xFD 1bytes (uint8_t) <= 0xFFFF 3bytes 0xFD 2bytes
(uint16_t) <= 0xFFFF FFFF 5bytes 0xFE 4bytes (uint32_t) <= 0xFFFF FFFF FFFF FFFF 9bytes 0xFF 8bytes (uint64_t) 5 => 0x05 255 => 0xFDFF00 11
( ) TxID Little Endian Big Endian 1 0x01 0x01
65536 0x010000 0x000001 0xF778C5D33453 0x5334D3C578F7 0xF778C5D33453 12
13
TxID( ID) Tx hash256(SHA-256 ) 0100000001c9e72944b5fd2b195085f9e8852e96181b4d4ce4a4b8cd993e 6d7925a0ce1c9b000000006946304302202173dc799db6b7b93b1f9b53f7 74c95aedc57dbe6a4d496bfd78d1e4b220c2db021f67e18545d2eccf7f56 2c8ec71f91e718d2292702aeb880a1d95f44fb8a66ab0121029700d3ba67 e374c699c4e5992a2f69f8a8e9321cefadae0c69eb56dba73d30e2ffffff
ff02f3653a01000000001976a9148e92fcfd113418f75356c5ca77b4463d 1bc099d288ace0673500000000001976a9144fcc9445c2edb970cb1ad427 0dc42b392596176188ac00000000 14
(1/2) Unlocking Script Locking Script 01000000 // 00000001 01 //Input
-c9e72944b5fd2b195085f9e8852e96181b4d4ce4a4b8cd993e6d7925a0ce 1c9b //TxID 00000000 // 69 // Unlocking Script 105bytes 46304302202173dc799db6b7b93b1f9b53f774c95aedc57dbe6a4d496bfd 78d1e4b220c2db021f67e18545d2eccf7f562c8ec71f91e718d2292702ae b880a1d95f44fb8a66ab0121029700d3ba67e374c699c4e5992a2f69f8a8 e9321cefadae0c69eb56dba73d30e2 // ffffffff // 15
(2/2) 02 //Output -f3653a0100000000 // 0x013a65f3 20604403satoshi(0.20604403BTC) 19 //Locking Script
25bytes 76a9148e92fcfd113418f75356c5ca77b4463d1bc099d288ac //Locking Script -e067350000000000 // 0x3567e0 3500000satoshi(0.035BTC) 19 //Locking Script 25bytes 76a9144fcc9445c2edb970cb1ad4270dc42b392596176188ac //Locking Script 00000000 // 16
46 //70bytes PUSH 304302202173dc79...fb8a66ab01 // 21 // 33bytes PUSH 029700d3ba0c69eb...dba73d30e2
// - 0x01- 0x4b PUSH OP_PUSHDATA1 0x4c 1byte PUSH OP_PUSHDATA2 0x4d 2bytes PUSH OP_PUSHDATA4 0x4e 4bytes PUSH 17
76 //OP_DUP a9 //OP_HASH160 14 //20bytes PUSH 8e92fcfd113418f75356c5ca77b4463d1bc099d2//20bytes 88 //OP_EQUALVERIFY
ac //OP_CHECKSIG OP_DUP OP_HASH160 HASH160 OP_EQUALVERIFY OP_CHECKSIG ( ) 1 PUSH 0 PUSH 18
( ) (1/6) 1(True) Tx UTXO 76a914/*899ee4cb09de33f6d7a91827ffdf45d28be998d5*/88ac PUSH (P2PKH) {DATA}
{DATA} OP_DUP OP_HASH160 {DATA} OP_EQUALVERIFY OP_CHECKSIG 1 OK 19
( ) (2/6) /* Unlocking Script */ 46 //70bytes PUSH
3043022...a1d95f44fb8a66ab01 // 21 //33bytes PUSH 029700...e0c69eb56dba73d30e2 // /* Locking Script ( TxID Output Index ) */ 76 //OP_DUP a9 //OP_HASH160 14 //20bytes PUSH 899ee4cb...ffdf45d28be998d5 // HASH160 ( ) 88 //OP_EQUALVERIFY ac //OP_CHECKSIG [ ] // PUSH [ , ] // PUSH [ , , ] // [ , , HASH] // HASH160 [ , , HASH, HASH] // HASH PUSH [ , ] // HASH 20
( ) (3/6) Bitcoin HASH256 (Sig Hash ) 1byte Sig
Hash 21
( ) (4/6) Code SIGHASH_ALL 0x01 Unlocking Script SIGHASH_NONE 0x02
SIGHASH_SINGLE 0x03 SIGHASH_ANYONECANPAY 0x80 ( ) 22
( ) (5/6) OP_CHECKSIG 01 SIGHASH_ALL Tx Hash Type 4bytes
//SigHash Tx 01000000 // 00000001 01 //Input -c9e72944b5fd2b19508...925a0ce1c9b //TxID 00000000 // 19 // Unlocking Script 76a914899ee4cb09de33f6d7a91827ffdf45d28be998d588ac //00 OR Input LockingScript ffffffff // 23
( ) (6/6) Tx HASH256 (ECDSA Secp256k1) 1 0 PUSH
[1] [0] 02 -f3653a0100000000 // 0x013a65f3 20604403satoshi(0.206 19 //Locking Script 25bytes 76a9148e92fcfd113418f75356c5ca77b4463d1bc099d288ac //Locking -e067350000000000 // 0x3567e0 3500000satoshi(0.035BTC) 19 //Locking Script 25bytes 76a9144fcc9445c2edb970cb1ad4270dc42b392596176188ac //Locking 00000000 // 01000000 // SigHash Type 01 SIGHASH_ALL 24
25
Tx TxID ( ) Mt.Gox TxID Sig Hash Type Locking
Script ECDSA (ECDSA s + - ) DATAPUSH 26
- PUSHDATA - 0x01-0x4b PUSH OP_PUSHDATA1 0x4c 1byte PUSH OP_PUSHDATA2
0x4d 2bytes PUSH OP_PUSHDATA4 0x4e 4bytes PUSH PUSHDATA Tx 27
Tx 46 (76bytes PUSH) 3043022...66ab01 ( ) 21 (33bytes PUSH)
029700d...3d30e2 ( ) 4c46 (OP_PUSHDATA1 76bytes PUSH) 3043022...66ab01 ( ) 21 (33bytes PUSH) 029700d...3d30e2 ( ) 1byte Tx TxID 7ba53ceea57f5554a266e0ea8b6ac2a772d5bf81c3753e501be9b95f31d654ea ↓ 7374e545e77f380efe21c0d1808c548b42096c5230c204ce1b5df79b8c836b66 28
P2PKH ( ) TxID ( ) segwit SigHash BIP143 29