Git Product home page Git Product logo

crackcoin's Introduction

crackcoin

Crackcoin is a very basic blockchain-free cryptocurrency PoC in Python. It's a project for discovering cryptocurrencies.

Note that this is a PoC that runs only on local networks and does not provide proper security. The code should only be used to get familiar with the building blocks for a cryptocurrency. Also, crackcoin should not be confused with the (dead) currency CrackCoin (CRACK) from 2014.

This project was created as an exercise after reading "Mastering Bitcoin: unlocking digital cryptocurrencies".

Material covered

  • Transaction-based mining as a PoC for a blockchain-free cryptocurrency
  • Threading in Python
  • Working with sockets in Python (UDP)
  • ECC crypto / ECC public key compression/decompression
  • Base58 encoding like bitcoin
  • Having the whole thing work (wallet, crypto, validation, networking, mining, etc)

Blockchain-free cryptocurrencies

Most cryptocurrencies use a blockchain to validate transactions among other things. After years of running these networks it's beginning to look like blockchain-based currencies naturally evolve into a centralised network, because it's in the best interest of the participants to combine computing power to calculate solutions for blocks.

An interesting framework for a blockchain-free protocol is discussed in the paper "Blockchain-Free Cryptocurrencies: A Framework for Truly Decentralised Fast Transactions", which can be found here:

https://eprint.iacr.org/2016/871.pdf

Do note that crackcoin doesn't implement nearly as complex a protocol as described in the paper. But the transaction-based mining method was used as an inspiration for implementing the 'core' for crackcoin.

Usage

Running it normally

  • First run python crackcoin.py
  • Then type h to see options and communicate with other crackcoin-nodes on the network

Generating and working with your own genesis transaction

  • Run python generateGenesis.py until a cool address pops up
  • Edit crackcoinBase.sql: replace the address for the transaction with transactionHash d34db33f in transactions_outputs with your generated address
  • Run crackcoin and wait until a confirmation is generated for d34db33f with a higher difficulty (>6) than the one in crackcoinBase.sql
  • Replace the confirmation for d34db33f
  • Share code on other nodes
  • Manually replace your wallet keys and address with the address and keys generated by generateGenesis.py. This will allow you to 'spend' the genesis cash.

Component basics

  • Wallets

    • A wallet consists of a public/private keypair and an address. The address is derived from the public key.
  • Transactions

    • A transaction contains inputs, outputs and a unique identifier (called 'hash').
    • An output has a unique identifier and is just an amount and a 'to'-address.
    • An input points to a previous output, and uses the coins from that output. It must contain a compressed public key and a signature. This way nodes can identify that the 'to'-address from the previous output, which can be generated with the public key, is owned by the spender.
  • The GUI

    • When you create a transaction, a confirmation is created and both the transaction and the confirmation are shared on the network (UDP broadcast).
    • When using the broadcast option b, your crackcoin node will broadcast a request packet on the network. Any crackcoin node receiving the request will send all transactions and confirmations to you. This is so new nodes can 'sync'.
  • Network server (UDP)

    • When the server receives a new transaction, it checks if the transaction is valid and adds it to the database ('ledger').
    • When a confirmation is received, the transaction's confirmation is updated if the received difficulty is higher than the existing difficulty.
  • Mining and confirmations

    • Confirmations are proof of work hashes for a transaction.
    • The mining component simply creates confirmations for some transaction.
    • Mining is done by hardening the transaction confirmation with the least difficulty.

crackcoin's People

Contributors

spipm avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.