CypherCryptoLabs / Cypher

This is only a PoC, showing the basic concept of Cypher! Cypher is a new Blockchain, that aims to provide a decentralized live messenger service. To make it attractive to people to run a "Node" to support the Cypher Network, there is a Cryptocurrency that will be based on the Cypher Blockchain called "Cypher".

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Table of contents

Cypher

Cypher is an open-source Project, aiming to create a decentralized Live-Messenger. For this to work, there needs to be a Network of Computers, called "Nodes", that communicate with each other. To make it attractive for people to run a Node, there is a cryptocurrency called "Cypher". In one Cypher there are 1000 "milliCypher" or "mCypher". 1000 Cypher are refered to as one "KCypher" or "KiloCypher". Nodes can earn Cypher by contributing to the Network, and putting some amount of Cypher at risk. This process is called "staking".

The Cypher Project does not stop with providing this decentralized infrastructure and Live-Messenger. There are already more projects in the works, that will be released as a certain progress is reached.

State of the Project

Currently Cypher is still in development. It does not have a public Network, so running a Node is completely useless right now. The website that this document refers to does not exist yet. You can track progress on the "TODO" list. Currently development is only focused on the Blockchain and Crypto-currenty. When this part is stable enough, the Live-Messenger will be implemented.

Contribute

If you want to suggest a feature, or change, please create an Issue, then create a Pull Request, and after a reviwe, you will either receive feedback, or your Pull Request will be merged.

Installation

There are 2 ways of installing the Cypher Node. Either you choose the easy way (Docker) or the painful one (manual installation). For both methods I assume you are using GNU/Linux and have Git as well as Docker installed. If thats not the case, please do it now.

Docker

This is the easy way of installing Cypher Node.

Download the Node

First you need to download the Source Code. You do this by running the following command:

git clone https://github.com/michelbarnich/cypher

Change your directory to the Cypher Docker directory:

cd ./cypher/docker

Modify config.json

You need to adjust the config.json file. It is pretty simple. There are only 4 configurations to modify. This is what the file looks originally:

{
    "host" : "192.168.178.39",
    "port" : 1234,
    "stableNode" : "192.168.178.39",
    "stableNodePort" : 1235,
    "stableNodePubKey" : "-----BEGIN PUBLIC KEY-----\nMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAE6x9RJRVMnhvYlrPtX7Nt5aDNoQp9gkv0\nZC7uDgXYEFDwK8vOYjhLIC+VIoGNYtPhS0XWUK9kiJyzCqLdgmiR0g==\n-----END PUBLIC KEY-----\n"
}

If you are familiar with the IP protocol, you will realize the IP-Addresses are local Addresses, which is a problem if you want to contribute to a global network. The host field needs to have your IP-Address as value. The port field can be anything you want as long as it is inside the TCP port range, and not already used by some other service. The stableNode and stableNodePort fields are the IP-Address and TCP port for a Node you trust. The stableNodePubKey field refers to the trusted Nodes PublicKey. If you dont trust any specific Node, enter the values of the Node run by Cypher, you can find the information on cyphercrypto.io.

Modify Dockerfile

The next step is to modify the port which the Docker container should expose. Edit the Dockerfile file, and search for this string:

EXPOSE 1234

Replace "1234" with the port that you chose when modifying the config.json file ("port" field).

Setting up the Docker container

After changing the config.json file, run the following command to build a Docker Image:

docker build -t cypher .

This might take some time, after a while, you should see a message similar to this one:

!!!COPY THE FOLLOWING KEY TO A SECURE LOCATION!!!
-----BEGIN EC PRIVATE KEY-----
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-----END EC PRIVATE KEY-----

Copy the key to a secure place. All your rewards will be ONLY accessible with this key! The last step is to run the Node. Type the following command:

docker run -d -p<your port>:<your port> cypher

Replace the <your port> with the port you set for the "port" field when you edited the config.json file.

Congratulations, your Node is now online!

Manual Installation

Installing the Cypher Node this way is not necessarily harder, but a lot more can go wrong.

Download the Node

First you need to download the Source Code. You do this by running the following command:

git clone https://github.com/michelbarnich/cypher

Install NodeJS modules

In the next step, you need to download the Cypher Node dependencies.

cd src # change directory to the source code of Cypher Node
npm install --save # install all dependencies
cd .. # change directory back to the Cypher Node root

Create config.json

You need to adjust the config.json file. It is pretty simple. There are only 4 configurations to modify. This is what the file looks originally:

{
    "host" : "192.168.178.39",
    "port" : 1234,
    "stableNode" : "192.168.178.39",
    "stableNodePort" : 1235,
    "stableNodePubKey" : "-----BEGIN PUBLIC KEY-----\nMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAE6x9RJRVMnhvYlrPtX7Nt5aDNoQp9gkv0\nZC7uDgXYEFDwK8vOYjhLIC+VIoGNYtPhS0XWUK9kiJyzCqLdgmiR0g==\n-----END PUBLIC KEY-----\n"
}

If you are familiar with the IP protocol, you will realize the IP-Addresses are local Addresses, which is a problem if you want to contribute to a global network. The host field needs to have your IP-Address as value. The port field can be anything you want as long as it is inside the TCP port range, and not already used by some other service. The stableNode and stableNodePort fields are the IP-Address and TCP port for a Node you trust. The stableNodePubKey field refers to the trusted Nodes PublicKey. If you dont trust any specific Node, enter the values of the Node run by Cypher, you can find the information on cyphercrypto.io.

Copy the Blockchain

The easiest way to do that is to copy it from the docker directory.

cp docker/blockchain.json blockchain.json

Alternatively, if you find a source somewhere online with a copy of the Blockchain, and you trust that source, you could download it from there.

Run the Node

Finally you can run this command:

node src/main.js

It will create a file called "private.pem", copy it to a secure location, your funds will only be accessible with that file! Congratulations, your Node is now online!

TODO

First Release

  • All TCP traffic signed
  • Proper way of creating a fingerprint of the public key
  • Sync Blockchain with Network on startup
  • verify Blockchain that is received on Network Registration
  • P.o.S. Consensus Algorithm
  • P.o.S. Penalties and Health System
    • Netowrk Diff saved in Blocks
    • Auto generate Nodelist from Blocks
    • Take part of stake away from Nodes that go offline
    • Take part of stake away that falsely voted on a Block
  • Address Balance Cache that is automatically updated when a Block is appended/snycing with Network
  • Only Nodes that have been registered longer than one Voting Slot can be selected as Validator
  • automatically remove offline Nodes from Nodelist
    • Nodes kick other Nodes out of the Network after 1 Voting slot (may be related to Docker setup)
    • Fix Block validation (Block invalid due to different Nodelist during forging and validation)
  • check reachability of Node on registration
  • Timeouts for all TCP traffic
  • Allow multiple transactions per Block per Wallet
  • Multithreading (for each connection a new thread, seperate thread for transactionQueue.worker())
  • Unit Tests

Future Releases and Improvements

  • Migrating Codebase to TypeScript for better readability
  • Standard JavaScript Code Style
  • implementing Messenger Protocol
    • pick communication parter Nodes
    • Implement Proof of Work for Nodes forwarding Messages
    • Integrate PoW for forwarding Messages into PoS Pentalties and health system
  • Alert Network of offline Nodes in Networking.sendPacket() if a Timeout occures
  • Split Networking Class into Networking and Consensus

License

MIT License

Copyright (c) 2022 Michel Barnich

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

This is only a PoC, showing the basic concept of Cypher! Cypher is a new Blockchain, that aims to provide a decentralized live messenger service. To make it attractive to people to run a "Node" to support the Cypher Network, there is a Cryptocurrency that will be based on the Cypher Blockchain called "Cypher".

License:MIT License


Languages

Language:JavaScript 99.6%Language:Dockerfile 0.4%