• Stars
    star
    841
  • Rank 54,194 (Top 2 %)
  • Language
    Go
  • Created about 10 years ago
  • Updated about 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A basic blockchain implementation written in Go

Blockchain

Having fun implementing a blockchain using Golang.

Using Minimum Viable Blockchain

Keys

The Blockchain uses ECDSA (224 bits) keys. When a user first joins the blockchain a random key will be generated.

Keys are encoded using base58.

Given x, y as the components of the public key, the key is generated as following:

	base58(BigInt(append(x as bytes, y as bytes)))

Proof of work

In order to sign a transaction and send it to the network, proof of work is required.

Proof of work is also required for block generation.

Protocol

The blockchain runs on port 9191 and uses TCP to handle connections among peers.

Message
  • Message type (1 byte)
     const (
     	MESSAGE_GET_NODES = iota + 20
     	MESSAGE_SEND_NODES
    
     	MESSAGE_GET_TRANSACTION
     	MESSAGE_SEND_TRANSACTION
    
     	MESSAGE_GET_BLOCK
     	MESSAGE_SEND_BLOCK
     )
    
  • Options (4 bytes): Data specific
  • Data (n bytes): Data specific
Transaction
  • Header:

    • From (80 bytes): Origin public key
    • To (80 bytes): Destination public key
    • Timestamp (4 bytes): int32 UNIX timestamp
    • Payload Hash (32 bytes): sha256(payloadData)
    • Payload Length (4 bytes): len(payloadData)
    • Nonce (4 bytes): Proof of work
  • Signature (80 bytes): signed(sha256(header))

  • Payload data (Payload Length bytes): raw data

Block
  • Header:

    • Origin (80 bytes): Origin public key
    • Timestamp (4 bytes): int32 UNIX timestamp
    • Previous block (32 bytes): sha256(previous block header)
    • Merkel Root (32 Bytes): sha256(transaction hashes)
    • Nonce (4 bytes): int32 UNIX timestamp
  • Signature (80 bytes): signed(sha256(header))

  • Block transactions

More Repositories

1

Taylor

A lightweight library for writing HTTP web servers with Swift
Swift
926
star
2

SHSidebarController

Sidebar with folding effect for iOS
Objective-C
173
star
3

todos

Get the TODO's in your code directly into Github Issues
Go
70
star
4

keybase-ethereum-registry

JavaScript
34
star
5

Poker.swift

โ™ ๏ธโ™ฅ๏ธโ™ฃ๏ธโ™ฆ๏ธ Swift library for experimenting with Poker.
Swift
18
star
6

net

Mesh networking prototype/experimentation written in Go.
Go
13
star
7

Memoface

Pebble watch face that allows you to quickly glance a note
CSS
12
star
8

block.chat

Ethereum backed messaging protocol with encryption and blockchain timestamping built-in.
JavaScript
8
star
9

ADNPebbleApp

A small app.net client for the Pebble
Objective-C
8
star
10

Localize

Localising strings in Swift
Swift
7
star
11

TheList-iOS

iOS Client for The List (http://thelist.io)
Objective-C
6
star
12

izqui.me

My nodeJS powered JSON Portfolio/CV
Shell
6
star
13

iPadSfera-iOS-Tutoriales

http://www.ipadsfera.com/category/tutoriales/programacion/
Objective-C
6
star
14

gittask

A Github based task tracker for Github projects
Go
5
star
15

Ohai-Pebble

Pebble app that checks-in Ohai for App.net (http://ohaiapp.net/)
C
5
star
16

MagicRemoteHelper

Mac companion app for MagicRemote
Objective-C
4
star
17

ArduinoiOSIntegration

Controlling a LED intensity from an iOS app
Objective-C
4
star
18

RaspiAutoTorrents

4
star
19

beacon

Go iBeacon library
Go
3
star
20

block.chat-protocol

JavaScript
2
star
21

camera-shooter

Go
2
star
22

pi-os

Assembly
1
star
23

JobPrep-HackerSchool

Job Prep exercises done in Hacker School on Fridays
JavaScript
1
star
24

siriproxy-izqui

Just playing with SiriProxy
Ruby
1
star
25

Wallet

A framework for creating Wallet (formerly Passbook) cards written in Swift
1
star