Skip to content

ariden83/blockchain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

blockchain

ariden83 Build Status

New blockchain. See website of project blockchain-altcoin.com

Resources

Blockchain

Keys Encrypting

  1. What is permanent
  • user : priv key
  • blockchain : pub key and pub blockchain key
  1. actions
  • user generate priv blockchain key with priv key
  • priv key generate pub blockchain key and a script
  • blockchain validator verify script is valid with pub blockhain key (possibilitĂ© de vĂ©rifier que script decode avec blockchain key = public key)
  1. PB:
  • (no check if pub blockchain key = public key) > can be solved
  • (not if it is the priv key of the user who makes the transaction for the validators)

Installation

Command

  • make local - launch the app
  • make local-light - launch the app without files generators (logs, blockchain, ...)

Build

  • make proto - generate proto files
  • make local-vendor - generate vendor files

Metrics

Metrics can be get on http://127.0.0.1:8082/metrics depending on configuration

Healthz

Status of server can be get by url

http://127.0.0.1:8082/liveness

and

http://127.0.0.1:8082/readiness

Features

  • Retrieves all seeds and the full blockchain when connecting with the first server
  • Generate a new seed
  • Access to your wallet
  • Mine a new bloc
  • Send tokens to another
  • Access to your balance
  • The blocks created are necessarily validated by more than 50% of the connected servers
  • The service requires at least two servers to operate
  • List currently active servers
  • Addition of transaction fees in favor of the minor
  • Evolution of the difficulty

Future

  • Fully Tested
  • Add bench
  • GRPC endpoint
  • Update seed database
  • Create seed database with seed database on network
  • Add oauth
  • Encrypt data with cypher key
  • Load seed database in many times
  • Load blockchain database in many times
  • Add a metadata field in each seed (for additional info)
  • Connect to the metamask API
  • ...

Godocs

You can browse the documentation of all local packages and projects with the Godocs package:

go install golang.org/x/tools/godoc
godoc -http=:6060

This will install the executable and start a server listening on http://localhost:6060

Test

1) Open services

You have to open two terminal minimun.

In the first terminal :

make local

return

go run main.go -p2p_target /ip4/127.0.0.1/tcp/8098/p2p/QmWV1qKRBSy8vggYgMSWDGukmwcus8wbuSoru31oNaEWdd

Then launch one or more light service *

cd example/light
go run main.go -p2p_target /ip4/127.0.0.1/tcp/8098/p2p/QmWV1qKRBSy8vggYgMSWDGukmwcus8wbuSoru31oNaEWdd
  • light service dont create files, it's just for tests

2) GENERATE A SEED (WALLET)

make local

And call IT

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' 'http://127.0.0.1:8098/wallet' -d ''

Return

{
  "Address": "1P1aBegXRiTinJhhEYHHiMALfG26Wu9sG3",
  "Timestamp": "2021-10-11 16:52:12.416519751 +0200 CEST m=+27.320229089",
  "PubKey": "xpub661MyMwAqRbcFTZYiEcSv4Qj2Qr2NzQ7rjYc3iv9c6VSTxoYsqA9AA6nNbp8e9nVR9hRARXz5CApP6j5BxUnohyj89oSg3zZdDuKmGhdSFF",
  "PrivKey": "xprv9s21ZrQH143K2yV5cD5SYvTzUP1XyXgGVWd1FLWY3kxTbAUQLHqtcMnJXJgfkH1Q3UqXqZ6FmDRTwLHdvDTJC6wNm7Vh9FokRma8WrDGQAe",
  "Mnemonic": "couple robot escape silent main once smoke check good basket mimic similar"
}

3) GENERATE YOUR FIRST BLOCK

And call IT in the first terminal

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' 'http://127.0.0.1:8098/write' -d '{"address": "1P1aBegXRiTinJhhEYHHiMALfG26Wu9sG3", "key": "xpub661MyMwAqRbcFTZYiEcSv4Qj2Qr2NzQ7rjYc3iv9c6VSTxoYsqA9AA6nNbp8e9nVR9hRARXz5CApP6j5BxUnohyj89oSg3zZdDuKmGhdSFF"}'

Return

{
  "Index": 26,
  "Timestamp": "2021-10-11 17:04:46.977307004 +0200 CEST m=+45.479261977",
  "Transactions": [
    {
      "ID": null,
      "Inputs": [
        {
          "ID": "",
          "Out": -1,
          "Sig": "xpub661MyMwAqRbcFTZYiEcSv4Qj2Qr2NzQ7rjYc3iv9c6VSTxoYsqA9AA6nNbp8e9nVR9hRARXz5CApP6j5BxUnohyj89oSg3zZdDuKmGhdSFF"
        }
      ],
      "Outputs": [
        {
          "Value": 1,
          "PubKey": "xpub661MyMwAqRbcFTZYiEcSv4Qj2Qr2NzQ7rjYc3iv9c6VSTxoYsqA9AA6nNbp8e9nVR9hRARXz5CApP6j5BxUnohyj89oSg3zZdDuKmGhdSFF"
        }
      ]
    }
  ],
  "Hash": "MGRiODRmMWFlNjhmZjQ5ZDA5ZmI4M2JhODE0MDg2YTdjN2QxOWYyZGFjODEzMzdhZmVlMTU3YjU4MjZhYzkwZQ==",
  "PrevHash": "MDcyYWMxYTlkNmI5YjQ1ZWFiMWYyMTI3Y2U1YzVlMGVlZjBiYjE3NTI3NTFkNzQyMWM2Y2U1ZmUxN2MwOTUyNA==",
  "Difficulty": 1,
  "Nonce": "8"
}

4) YOUR BALANCE

Call your balance :

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' 'http://127.0.0.1:8098/balance' -d '{"key": "xpub661MyMwAqRbcFTZYiEcSv4Qj2Qr2NzQ7rjYc3iv9c6VSTxoYsqA9AA6nNbp8e9nVR9hRARXz5CApP6j5BxUnohyj89oSg3zZdDuKmGhdSFF"}'

return

Balance of xpub661MyMwAqRbcFTZYiEcSv4Qj2Qr2NzQ7rjYc3iv9c6VSTxoYsqA9AA6nNbp8e9nVR9hRARXz5CApP6j5BxUnohyj89oSg3zZdDuKmGhdSFF: 1

5) GENERATE A SECOND WALLET

{
  "Address": "1NKEsiake5Yu8yx2H2uHm2oJZe2xYnQ8ZS",
  "Timestamp": "2021-10-11 17:04:24.263414034 +0200 CEST m=+3.378949045",
  "PubKey": "xpub661MyMwAqRbcG4VYfVo7ptRncn7wsGMjNubLNrm5Stu5ERP4RtJqo7sQgSQAESwyJKi442EJ6sNWRz5wWZ2ecFE8p1JEJs6qGkzPKncdkhb",
  "PrivKey": "xprv9s21ZrQH143K3aR5ZUG7TkV44kHTTodt1gfjaUMTtZN6Md3utLzbFKYvqCuqyXAnVcirzpNuzcBkcvpTfJNRjakAwsmEA26wNWmDmLJKXYD",
  "Mnemonic": "couple office mix shadow glide crater sister check gown sister mirror indoor"
}

6) SEND ONE TOKEN TO THE 2nd WALLET

a) We send the sum from account A to account B.

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' 'http://127.0.0.1:8098/send' -d '{"from": "xpub661MyMwAqRbcFTZYiEcSv4Qj2Qr2NzQ7rjYc3iv9c6VSTxoYsqA9AA6nNbp8e9nVR9hRARXz5CApP6j5BxUnohyj89oSg3zZdDuKmGhdSFF", "to": "xpub661MyMwAqRbcG4VYfVo7ptRncn7wsGMjNubLNrm5Stu5ERP4RtJqo7sQgSQAESwyJKi442EJ6sNWRz5wWZ2ecFE8p1JEJs6qGkzPKncdkhb", "amount": 3}'

b) We recover the balance of the sending account.

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' 'http://127.0.0.1:8098/balance' -d '{"key": "xpub661MyMwAqRbcFTZYiEcSv4Qj2Qr2NzQ7rjYc3iv9c6VSTxoYsqA9AA6nNbp8e9nVR9hRARXz5CApP6j5BxUnohyj89oSg3zZdDuKmGhdSFF"}'

return

Balance of xpub661MyMwAqRbcFTZYiEcSv4Qj2Qr2NzQ7rjYc3iv9c6VSTxoYsqA9AA6nNbp8e9nVR9hRARXz5CApP6j5BxUnohyj89oSg3zZdDuKmGhdSFF: 97

c) We recover the balance of the receiving account

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' 'http://127.0.0.1:8098/balance' -d '{"key": "xpub661MyMwAqRbcG4VYfVo7ptRncn7wsGMjNubLNrm5Stu5ERP4RtJqo7sQgSQAESwyJKi442EJ6sNWRz5wWZ2ecFE8p1JEJs6qGkzPKncdkhb"}'

return

Balance of xpub661MyMwAqRbcG4VYfVo7ptRncn7wsGMjNubLNrm5Stu5ERP4RtJqo7sQgSQAESwyJKi442EJ6sNWRz5wWZ2ecFE8p1JEJs6qGkzPKncdkhb: 3

7) Communicate new update of blockChain / wallet with every blockChain service

After order

make local
> 2021-10-15T16:40:38.669+0200	INFO	Now run "go run main.go -l 8198 -d /ip4/127.0.0.1/tcp/8097/p2p/QmdJboshgG8BuRexqmq9opEsr49Zw961UqSMQrrfXxyzxQ" on a different terminal

you must retrieve the TCP address transmitted in the logs and execute it in a new terminal.

cd ./cmd/p2p
go run main.go -l 8198 -d /ip4/127.0.0.1/tcp/8097/p2p/QmdJboshgG8BuRexqmq9opEsr49Zw961UqSMQrrfXxyzxQ

After each creation / update of the blockChain or seeds, the second service launched will update.

minage

messaging

GPG tutorial

Creating and exporting a key

// Creation of a public key
gpg --gen-key

// Exporting the public key
gpg --export --armor adrienparrochia@gmail.com > pubkey.asc

scp -r -p pubkey.asc ariden@51.15.171.142:/home/ariden/

// Exporting the public key
gpg --import pubkey.asc

IPFS tutorial

Ressources

Installation d'IPFS

ipfs-update versions
ipfs-update install latest
ipfs init
sysctl -w net.core.rmem_max=2500000
ipfs daemon

IPFS Daemon

To do this, we create a unit file at /etc/systemd/system/ipfs.service with the contents:

[Unit]
Description=IPFS Daemon

[Service]
ExecStart=/usr/local/bin/ipfs daemon
User=ipfs
Restart=always
LimitNOFILE=10240

[Install]
WantedBy=multi-user.target

IPFS site perso

Site de test

TCP

Ressources

Test

In the first terminal :

make local-networking

In a second terminal :

nc localhost 9000
5
7
...