Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Decrypting Crypto-Currency with F#

Decrypting Crypto-Currency with F#

Robert Pickering

June 27, 2014
Tweet

More Decks by Robert Pickering

Other Decks in Programming

Transcript

  1. type IPeerToPeerConnectionManager = abstract Connect: unit -> unit abstract Broadcast:

    Message -> unit abstract SendTo: IPAddress -> Message -> unit [<CLIEvent>] abstract MessageReceived: IEvent<MessageReceivedEventArgs>
  2. Such database Block Block Block Block Genasis Block Trans Trans

    Trans Trans Address Address Address Address Trans Address Reward Reward Reward Reward Payment
  3. type Block = { OffSet: int64 Length: int Version: int

    Hash: array<byte> // hash of previous block MerKleRoot: array<byte> Timestamp: DateTime Target: int Nonce: int NumberOfTransactions: uint64 Transactions: array<Transaction> }
  4. type Transaction = { TransactionVersion: int NumberOfInputs: uint64 Inputs: array<Input>

    NumberOfOutputs: uint64 Outputs: array<Output> LockTime: int TransactionHash: array<byte> }
  5. type Input = { InputHash: array<byte> InputTransactionIndex: int ResponseScriptLength: uint64

    ResponseScript: array<byte> ParsedResponseScript: option<array<Op>> SequenceNumber: int } type Output = { Value: int64 OutputScriptLength: uint64 OutputScript: array<byte> ParsedOutputScript: option<array<Op>> CanonicalOutputScript: option<CanonicalOutputScript> }
  6. [|Op_Dup; Op_HASH160; Op_PushData (Vector(20uy), [|174uy; 162uy; 183uy; 35uy; 215uy; 73uy;

    186uy; 28uy; 7uy; 81uy; 57uy; 60uy; 120uy; 183uy; 65uy; 181uy; 159uy; 157uy; 79uy; 247uy|]); Op_EqualVerify; Op_CheckSig|]; very output
  7. [|Op_PushData (Vector(72uy), [|48uy; 69uy; 2uy; 32uy; 124uy; 166uy; 68uy; 95uy;

    86uy; 220uy; 43uy; 209uy; 203uy; 254uy; 114uy; 34uy; 110uy; 142uy; 200uy; 164uy; 243uy; 111uy; 76uy; 77uy; 162uy; 249uy; 121uy; 216uy; 149uy; 52uy; 233uy; 34uy; 147uy; 147uy; 246uy; 180uy; 2uy; 33uy; 0uy; 217uy; 84uy; 56uy; 142uy; 241uy; 234uy; 57uy; 137uy; 54uy; 24uy; 166uy; 78uy; 141uy; 235uy; 22uy; 249uy; 196uy; 220uy; 0uy; 98uy; 0uy; 222uy; 121uy; 12uy; 110uy; 20uy; 2uy; 168uy; 21uy; 235uy; 92uy; 134uy; 1uy|]); Op_PushData (Vector(33uy), [|2uy; 231uy; 24uy; 167uy; 187uy; 86uy; 155uy; 0uy; 14uy; 185uy; 222uy; 52uy; 154uy; 160uy; 83uy; 42uy; 172uy; 224uy; 229uy; 26uy; 22uy; 244uy; 169uy; 246uy; 108uy; 79uy; 236uy; 176uy; 42uy; 85uy; 46uy; 103uy; 47uy|])|]; very input
  8. Explore the block chain: http://blockchain.info/ Good explanation of the block

    chain: http://james.lab6.com/2012/01/12/bitcoin-285-bytes-that-changed-the-world/ The protocol specification: https://en.bitcoin.it/wiki/Protocol_specification My explanation of bitcoin: http://robertpi.github.io/blog/2014/01/01/bitcoins-a-detailed-yet-easy-to- understand-explaination/ much info