Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashy5000 committed Apr 1, 2024
2 parents 97bba32 + 6ad3748 commit b3180d7
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 5 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ The roadmap for this repository looks something like this:
The root directory of this project is occupied by the Golang source code that nodes run in order to interact with each other and the decentralized blockchain. In the ```peer_server``` directory, there is Rust code that can be run by servers to maintain a list of peers in the network. Nodes can connect to these servers or maintain their own lists. Using this code is optional, and its only purpose is to make it faster to discover peers. Thirdly, the ```gui_wallet``` directory contains Rust code for a GUI wallet to make transactions easier to make. Note that you will still have to generate a key using the ```keygen``` command in the interactive console (see *To run as a client* below).

## About decentralized peer lists
There are two ways to run a node: using a peer server or a local peer list. With a peer server, there is far less configuration. To make yourself known to the network, use the `addpeer [YOUR IP]` command in the BlockCMD console (see *To run as a client:* below to open the console). With a local peer list, you fully decentralize your connections with other computers to completely remove trust from the system. However, dealing with the configuration for this option can take a bit longer. I personally recommend using a local peer list. The security and reliability that decentralized peer tracking provides simply can't be reproduced with a centralized peer server, but if it seems daunting to manually configure IP addresses, the peer server's an okay way to start. The two options both use the same network and the same blockchain, so your balance will be preserved if you switch over.
~~There are two ways to run a node: using a peer server or a local peer list. With a peer server, there is far less configuration. To make yourself known to the network, use the `addpeer [YOUR IP]` command in the BlockCMD console (see *To run as a client:* below to open the console). With a local peer list, you fully decentralize your connections with other computers to completely remove trust from the system. However, dealing with the configuration for this option can take a bit longer. I personally recommend using a local peer list. The security and reliability that decentralized peer tracking provides simply can't be reproduced with a centralized peer server, but if it seems daunting to manually configure IP addresses, the peer server's an okay way to start. The two options both use the same network and the same blockchain, so your balance will be preserved if you switch over.~~ Non-decentralized peer lists are deprecated. Please use a local peer list instead.

## Setup & Usage

For a simpler guide, see the [welcome](docs/welcome.md) page.

*Note: A node must have a publicly accessible IP address in order to join the network. You may have to set up port forwarding on your router.*

Create and clone the repository:
Expand Down
2 changes: 1 addition & 1 deletion blockchain.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"sender":{"P":null,"Q":null,"G":null,"Y":null},"recipient":{"P":null,"Q":null,"G":null,"Y":null},"miner":{"P":null,"Q":null,"G":null,"Y":null},"amount":0,"nonce":0,"R":0,"S":0,"miningTime":0,"difficulty":0,"previousBlockHash":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"timestamp":"0001-01-01T00:00:00Z"},{"sender":{"P":109323646573944889017971237778979166402951725319866372099867982932268881762684139782899268033891823409243311489268588260056684363244728025842481944674695388396691286222725852102221017739551478086381994507889733922711574564153732248684860038129398518695786805476154353065843578991278852472230970998664035001731,"Q":921422443924672895878224248303232639235422794719,"G":64959536327200260046979789588575676756756503754983503606783280973770165695981612756742027273458939956322333435733300087757009868486842332523727514121178851322832964076299888901772063159288598340072206469466898501288945024583024250201415528129071120965682994878678832555302104941534265440367510272776298887332,"Y":51996143750538274136478406075177963521686622109835488246960703257111262626004591372611340083515304440734194408968806358833815439538317123457791789387734545041878387973535122170421410379125837323285892931516696214770626046526978455381349501023425999012502666016495567773381174249500463277838446882128660738179},"recipient":{"P":109323646573944889017971237778979166402951725319866372099867982932268881762684139782899268033891823409243311489268588260056684363244728025842481944674695388396691286222725852102221017739551478086381994507889733922711574564153732248684860038129398518695786805476154353065843578991278852472230970998664035001731,"Q":921422443924672895878224248303232639235422794719,"G":64959536327200260046979789588575676756756503754983503606783280973770165695981612756742027273458939956322333435733300087757009868486842332523727514121178851322832964076299888901772063159288598340072206469466898501288945024583024250201415528129071120965682994878678832555302104941534265440367510272776298887332,"Y":123},"miner":{"P":109323646573944889017971237778979166402951725319866372099867982932268881762684139782899268033891823409243311489268588260056684363244728025842481944674695388396691286222725852102221017739551478086381994507889733922711574564153732248684860038129398518695786805476154353065843578991278852472230970998664035001731,"Q":921422443924672895878224248303232639235422794719,"G":64959536327200260046979789588575676756756503754983503606783280973770165695981612756742027273458939956322333435733300087757009868486842332523727514121178851322832964076299888901772063159288598340072206469466898501288945024583024250201415528129071120965682994878678832555302104941534265440367510272776298887332,"Y":51996143750538274136478406075177963521686622109835488246960703257111262626004591372611340083515304440734194408968806358833815439538317123457791789387734545041878387973535122170421410379125837323285892931516696214770626046526978455381349501023425999012502666016495567773381174249500463277838446882128660738179},"amount":0,"nonce":57784,"R":120673424799108260233418723037671238952905847948,"S":414620227771783302622005043717071932179462850880,"miningTime":18111636943,"difficulty":100000,"previousBlockHash":[34,74,4,191,81,58,244,37,24,85,239,153,81,190,217,206,161,23,155,60,225,95,77,215,229,64,156,175,53,67,133,27],"timestamp":"2024-03-17T16:28:46.648769749-07:00"},{"sender":{"P":109323646573944889017971237778979166402951725319866372099867982932268881762684139782899268033891823409243311489268588260056684363244728025842481944674695388396691286222725852102221017739551478086381994507889733922711574564153732248684860038129398518695786805476154353065843578991278852472230970998664035001731,"Q":921422443924672895878224248303232639235422794719,"G":64959536327200260046979789588575676756756503754983503606783280973770165695981612756742027273458939956322333435733300087757009868486842332523727514121178851322832964076299888901772063159288598340072206469466898501288945024583024250201415528129071120965682994878678832555302104941534265440367510272776298887332,"Y":51996143750538274136478406075177963521686622109835488246960703257111262626004591372611340083515304440734194408968806358833815439538317123457791789387734545041878387973535122170421410379125837323285892931516696214770626046526978455381349501023425999012502666016495567773381174249500463277838446882128660738179},"recipient":{"P":109323646573944889017971237778979166402951725319866372099867982932268881762684139782899268033891823409243311489268588260056684363244728025842481944674695388396691286222725852102221017739551478086381994507889733922711574564153732248684860038129398518695786805476154353065843578991278852472230970998664035001731,"Q":921422443924672895878224248303232639235422794719,"G":64959536327200260046979789588575676756756503754983503606783280973770165695981612756742027273458939956322333435733300087757009868486842332523727514121178851322832964076299888901772063159288598340072206469466898501288945024583024250201415528129071120965682994878678832555302104941534265440367510272776298887332,"Y":111896023106432554777809308052085863034982465927166615553218927304801713083181810551956462303169716813833436449219419993350043269466866139597543167870732984366746098836377306502199983155278737536883971636034997486082415756904066748028920533259155461870402333867374806819743871633519713520336324574686122971428},"miner":{"P":109323646573944889017971237778979166402951725319866372099867982932268881762684139782899268033891823409243311489268588260056684363244728025842481944674695388396691286222725852102221017739551478086381994507889733922711574564153732248684860038129398518695786805476154353065843578991278852472230970998664035001731,"Q":921422443924672895878224248303232639235422794719,"G":64959536327200260046979789588575676756756503754983503606783280973770165695981612756742027273458939956322333435733300087757009868486842332523727514121178851322832964076299888901772063159288598340072206469466898501288945024583024250201415528129071120965682994878678832555302104941534265440367510272776298887332,"Y":51996143750538274136478406075177963521686622109835488246960703257111262626004591372611340083515304440734194408968806358833815439538317123457791789387734545041878387973535122170421410379125837323285892931516696214770626046526978455381349501023425999012502666016495567773381174249500463277838446882128660738179},"amount":1,"nonce":290797,"R":543224510889230789310846360669632071437128505256,"S":309045618337553885435084149056761959954947541482,"miningTime":137044572099,"difficulty":300000,"previousBlockHash":[0,0,95,216,202,79,21,9,134,255,110,91,89,155,26,138,155,217,140,9,64,132,232,251,21,171,123,95,177,116,209,191],"timestamp":"2024-03-17T16:29:30.955304197-07:00"}]
[{"transactions":null,"miner":{"P":null,"Q":null,"G":null,"Y":null},"nonce":0,"miningTime":0,"difficulty":0,"previousBlockHash":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"timestamp":"0001-01-01T00:00:00Z","timeVerifierSignature":[],"timeVerifiers":[]},{"transactions":["111896023106432554777809308052085863034982465927166615553218927304801713083181810551956462303169716813833436449219419993350043269466866139597543167870732984366746098836377306502199983155278737536883971636034997486082415756904066748028920533259155461870402333867374806819743871633519713520336324574686122971428\u0026124334585104178018537342354507973396229081486761522638665531587228378821572146308508040265181448362979380041028812468562654458638087008520917706538759743858057739798219334114639642712323100006159568840572201452789112766967306545744051923877499403078217652976253866837175759751485975307908215307693172716083951\u00261325683629013751074584942400294182844511772252959\u002626141189716406718735166685954688468302446411755761057594764426589010889617733449918677660549354929129990052410279264115900911908928290282365235099116814778923262737065487773320997659370640354573996110246242658866145422245611500205259643638514924156846224797192485592075928422150636297085091237112406248487655:123\u0026124334585104178018537342354507973396229081486761522638665531587228378821572146308508040265181448362979380041028812468562654458638087008520917706538759743858057739798219334114639642712323100006159568840572201452789112766967306545744051923877499403078217652976253866837175759751485975307908215307693172716083951\u00261325683629013751074584942400294182844511772252959\u002626141189716406718735166685954688468302446411755761057594764426589010889617733449918677660549354929129990052410279264115900911908928290282365235099116814778923262737065487773320997659370640354573996110246242658866145422245611500205259643638514924156846224797192485592075928422150636297085091237112406248487655:0.000000:807138244954021860019856206459516873471083823370$96699467706924367512198201685411468626387678089"],"miner":{"P":109323646573944889017971237778979166402951725319866372099867982932268881762684139782899268033891823409243311489268588260056684363244728025842481944674695388396691286222725852102221017739551478086381994507889733922711574564153732248684860038129398518695786805476154353065843578991278852472230970998664035001731,"Q":921422443924672895878224248303232639235422794719,"G":64959536327200260046979789588575676756756503754983503606783280973770165695981612756742027273458939956322333435733300087757009868486842332523727514121178851322832964076299888901772063159288598340072206469466898501288945024583024250201415528129071120965682994878678832555302104941534265440367510272776298887332,"Y":51996143750538274136478406075177963521686622109835488246960703257111262626004591372611340083515304440734194408968806358833815439538317123457791789387734545041878387973535122170421410379125837323285892931516696214770626046526978455381349501023425999012502666016495567773381174249500463277838446882128660738179},"nonce":60107,"miningTime":28712208477,"difficulty":100000,"previousBlockHash":[174,41,65,60,172,189,120,211,96,134,202,94,148,249,228,83,222,56,153,81,214,199,199,160,67,154,249,75,172,198,143,58],"timestamp":"2024-04-01T08:04:28.921705727-07:00","timeVerifierSignature":[],"timeVerifiers":[]}]
2 changes: 1 addition & 1 deletion constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var initialBlockDifficulty = uint64(100000)
var minimumBlockDifficulty = uint64(100000)
var maximumUint64 = ^uint64(0)
var blocksBeforeSpendable = 3
var maxBlockSize = 10000
var maxBlockSize = 10000000

// Mining power is measured in difficulty points per minute (DPM).
const dpm = 1
Expand Down
5 changes: 4 additions & 1 deletion docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
The architecture of the blockchain revolves around altered version of the traditional PoW (Proof of Work) consensus algorithm. One major change is made to the existing method to increase the efficiency and lower the power usage of the network. Instead of a block's difficulty being calculated based on the speed of the network, it is calculated based on the speed **of the miner that is mining it**. In this way, a miner with more hashing power will gain only a small benefit over a miner with less hashing power. If a block is found more quickly, the next one will be more difficult to mine, and the speed will balance out (for the most part). However, the target time, on average 1 minute, does vary based on your mining rate- a higher mining rate means a lower target time. The lowest target time is 30 seconds and the highest 1 minute 30 seconds, so there's no substantial benefit from mining faster, but there's still a little. It's important to encourage miners to contribute more computing power to the network, even if you don't provide a large benefit. This method will strengthen the network while also increasing decentralization and efficiency. The difficulty calculations are made each block for every miner on the network, so attempting to "trick" the difficulty calculations is not possible. However, without further modification, this approach is impossible to enforce. As miners may create an arbitrary amount of public/private key pairs, they may bypass the difficulty adjustment feature and create a new key pair for every block they mine. To prevent unlimited key pairs from being generated, this blockchain sets a maximum miner limit that increases with the number of blocks in the blockchain. This ensures that unlimited miners cannot be created.

### Time Verification
To ensure miners are honest about the time it took them to mine a block, each block must be signed by at least 1/5 of the miners in the network. These are called the 'time verifiers'. Their digital signature is requested, and they will sign the block if and only if the current time is less than 10 seconds after the time the miner claimed to have finished mining. If the miner says it took longer than it actually did to mine a block, the time verifiers will see that the finishing time is in the future and refuse to sign the block. If the miner attempts to wait before sending it to a time verifier, they will most likely lose the block before it is sent. This system creates a history of blocks with verified timestamps, ensuring the honesty of miners and their mining times, and preventing miners from manipulating block difficulty.
To ensure miners are honest about the time it took them to mine a block, each block must be signed by at least 1/5 of the miners in the network. These are called the 'time verifiers'. Their digital signature is requested, and they will sign the block if and only if the current time is less than 10 seconds after the time the miner claimed to have finished mining. If the miner says it took longer than it actually did to mine a block, the time verifiers will see that the finishing time is in the future and refuse to sign the block. If the miner attempts to wait before sending it to a time verifier, they will most likely lose the block before it is sent. This system creates a history of blocks with verified timestamps, ensuring the honesty of miners and their mining times, and preventing miners from manipulating block difficulty.

### Maximum block size
To enable high speeds and throughput of the network, the maximum size of each block is at a maximum 10 MB. Combining this with the 30 sec-1 min 30 sec block time, the network has a theoretical throughput 100x that of Bitcoin. The high maximum block size and the short block times are the two primary reasons behind the scalability of the network and blockchain.
43 changes: 43 additions & 0 deletions docs/setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Setup
You have three options to participate in the network:
1. Client: Send and receive currency
2. Node: Propagate transactions and support the network
3. Miner: Use your computing power to maintain the network's security and gain
rewards

### Client Setup
This setup assumes a Linux/Unix-like command line.

First, clone the repository.

```bash
git clone https://github.com/Ashy5000/cryptocurrency
```

Find the correct executable.

| | x86_64 | arm64 | arm | 386 |
-------------------------------------------------------------------------------------------------------------------------------------------
| Linux | builds/node/node_linux-amd64 | builds/node/node_linux-arm64 | builds/node/node_linux-arm | builds/node/node_linux-386 |
| MacOS | builds/node/node_darwin-amd64 | builds/node/node_darwin-arm64 | Combination not possible | Combination not possible |
| Windows | builds/node/node_windows-amd64 | builds/node/node_windows-arm64 | builds/node/node_windows-arm | builds/node/node_windows-386 |

Run the correct executable.

```bash
./builds/node/{executable}
```

```
You will now be in the BlockCMD console. It should look something like this:
Copyright (C) 2024 Asher Wrobel
This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions.
To see the license, type `license`.
BlockCMD console (encrypted: true):
```

Type `keygen` and then enter. This will generate a new DSA keypair. If you wish, type `encrypt` and then enter. This will encrypt your keypair with a 16-character-long passcode. When you need to check your balance or send currency, type `decrypt` to make it usable. When you are done, use `encrypt` once more.

To use a graphical application to manage funds, first install the Rust programming language if you haven't already. Then, move into the `gui_wallet` directory and use the `cargo run` command to build and run the application.

If you prefer a text-based interface, use the `help` command in the BlockCMD console for more information.
3 changes: 2 additions & 1 deletion docs/welcome.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Welcome
Welcome to the docs! This directory is for documentation about this cryptocurrency blockchain project. Here are some places to get started:

- [Architecture](architecture.md)
- [Architecture](architecture.md)
- [Setup](setup.md)

0 comments on commit b3180d7

Please sign in to comment.