From fab0654942bd610c99999a6d193e0630d0cd6f98 Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Sun, 25 Apr 2021 23:45:22 +0300 Subject: Moving to nicenet --- content/JWT.md | 18 ++++++++++-------- content/_index.md | 14 ++++++++------ content/block_docs.md | 33 ++++++++++++++++++++++----------- content/misc_docs.md | 4 ---- content/register_docs.md | 21 ++++++++++++--------- content/transaction_docs.md | 35 ++++++++++++----------------------- 6 files changed, 64 insertions(+), 61 deletions(-) (limited to 'content') diff --git a/content/JWT.md b/content/JWT.md index 46da1a2..e77457f 100644 --- a/content/JWT.md +++ b/content/JWT.md @@ -7,15 +7,15 @@ weight = 4 > JSON Web Tokens are representations of claims, or authorization proofs that fit into the `Header` of HTTP requests. # How? - -JWTs are used as the [MAC](https://en.wikipedia.org/wiki/Message_authentication_code) of operations that require authorization: +JWTs are used as the [MAC](https://en.wikipedia.org/wiki/Message_authentication_code) of operations that require authorization. +Gradecoin has 2 such operations: - block proposal - transaction proposal. -They are send alongside the JSON request body in the `Header`; +They are sent alongside the JSON request body in the `Header`; -```html -Authorization: Bearer aaaaaa.bbbbbb.ccccc +``` +Authorization: Bearer ``` Gradecoin uses 3 fields for the JWTs; @@ -29,11 +29,13 @@ Gradecoin uses 3 fields for the JWTs; ``` - `tha` is explained in [blocks](@/block_docs.md) and [transactions](@/transaction_docs.md) documentations. -- `iat` when the JWT was created in [Unix Time](https://en.wikipedia.org/wiki/Unix_time) format -- `exp` when the JWT will expire & be rejected in [Unix Time](https://en.wikipedia.org/wiki/Unix_time) +- `iat` when the JWT was created in [Unix Time](https://en.wikipedia.org/wiki/Unix_time) format. +- `exp` when the JWT will expire & be rejected in [Unix Time](https://en.wikipedia.org/wiki/Unix_time). # Algorithm -We are using [RS256](https://www.rfc-editor.org/rfc/rfc7518.html#section-3.1), `RSASSA-PKCS1-v1_5 using SHA-256`. The JWTs you encode with your private RSA key will be decoded using the public key you have authenticated with. You can see how the process works [here](https://jwt.io/). +We are using [RS256](https://www.rfc-editor.org/rfc/rfc7518.html#section-3.1), `RSASSA-PKCS1-v1_5 using SHA-256`. +The JWTs you encode with your private RSA key will be decoded using the public key you have authenticated with. +You can see how the process works and create ad hoc tokens [here](https://jwt.io/). # References - [RFC, the ultimate reference](https://tools.ietf.org/html/rfc7519) diff --git a/content/_index.md b/content/_index.md index d0be673..3522122 100644 --- a/content/_index.md +++ b/content/_index.md @@ -4,7 +4,6 @@ sort_by = "weight" +++ # Welcome to Gradecoin! - Blockchains are incredibly simple yet can appear very complicated, we will see how they work and practice programming _production_ cryptography code. This server is the sandbox for the PA1, it's currently running the Gradecoin application. Gradecoin is the faux currency we will use to simulate a blockchain network. At the end of the simulation, the amount of Gradecoin you hold will be your PA1 grade. @@ -17,7 +16,7 @@ Blocks need to be _mined_ beforehand using Proof-of-work, or brute force. Gradecoin offers 3 endpoints at [/register](/register), [/block](/block) and [/transaction](/transaction). You can only send GET requests to /block and /transaction without authorization. The server is programmed in [RESTful](https://www.service-architecture.com/articles/web-services/representational_state_transfer_rest.html) architecture, there are no `DELETE`, `PUT` or `UPDATE` operations, though. -Gradecoin uses a Proof-of-work block accepting mechanism. It uses single round [Blake2s](https://www.blake2.net/) hashing which produces 256-bit (64 hexadecimal characters) output. The [target](https://wiki.bitcoinsv.io/index.php/Target) hash is _24 bits_ or _6 hexadecimal characters_ of 0. During testing, I could mine a block on average around 4-6 minutes. +Gradecoin uses a Proof-of-work block accepting mechanism. It uses single round [Blake2s](https://www.blake2.net/) hashing which produces 256-bit (64 hexadecimal characters) output. The [target](https://wiki.bitcoinsv.io/index.php/Target) hash is _24 bits_ or _6 hexadecimal characters_ of 0. > We're expecting you to use existing tools and implementations. Standards are hard. [Don't roll your own crypto](https://www.reddit.com/r/crypto/comments/2coqsy/dont_roll_your_own/). Feel free to ask questions. Collaborate. @@ -25,7 +24,8 @@ You might ask, > But if nobody has any Gradecoin then how do we have transactions? -There is a bank! Their public key is `31415926535897932384626433832795028841971693993751058209749445923` and they have some amount of Gradecoin preloaded. It's also the only account that you can send transactions requests _to_ yourself. +You get rewarded for your hard work during the authentication with some Gradecoin to start with! +Then you can earn block rewards by proposing blocks, create some Gradecoins by generating traffic on the system, or transact with our new highly trained AI bots! # Coinbase The first transactions of a block is called the `coinbase`. They are the **author** of the block proposal and if the block is accepted then they get compensated for their efforts with some Gradecoin. @@ -39,6 +39,7 @@ Gradecoin uses 2048 bit RSA keypairs. - Download `Gradecoin`'s Public Key from [Moodle](https://odtuclass.metu.edu.tr/my/) - Encrypt your [JSON](https://www.json.org/json-en.html) wrapped `Public Key`, `Student ID` and one time `passwd` using Gradecoin's Public Key - Your public key is now in our database and can be used to sign your JWT's during requests +- **Don't forget your Public Key** - For more information, check the [register](@/register_docs.md) page ## /transaction @@ -55,10 +56,10 @@ Gradecoin uses 2048 bit RSA keypairs. - Fetch the last accepted `Block` with a GET request - For more information, check our [block](@/block_docs.md) page - `Authorization`: The request header should have Bearer JWT.Token signed with Student Public Key +> `Authorization`: The request header should have Bearer JWT.Token signed with Student Public Key ## /user -- Meant to be used in the browser, you can see the current list of users and their balance here +- Looking for people to conduct business with? Everyone is listed here! 🤖👋 are bots who are very eager to transact with you. I've trained them personally. # Questions ## This all sound complicated! @@ -87,12 +88,13 @@ At the end of the _simulation_, your Gradecoin balance will be your grade. I wil - perl - rust - python +- dart/typescript - random assortment of bash scripts If your favourite programming language is missing please let me know 🤷? ## Can my friends play? -Sadly, no. Student's who are enrolled to the class will receive one-time-passwords for authentication. +Probably not at this point. I've allowed a couple of people during the testnet phase but don't intend to any more. ## How and or Why? - [Built](https://xkcd.com/2314/), [with](https://lofi.cafe/) [Rust](https://xkcd.com/2418/) diff --git a/content/block_docs.md b/content/block_docs.md index 92880b6..05bf8ee 100644 --- a/content/block_docs.md +++ b/content/block_docs.md @@ -4,11 +4,19 @@ description = "Block Documentation" weight = 10 +++ -A block that was proposed to commit Transactions in `transaction_list` to the -ledger with a nonce that made `hash` valid; 6 zeroes at the left hand side of the -hash (24 bytes). +> Blocks commit proposed transactions into the ledger. +> A transaction that do not appear on a valid block is not accepted by the network. -We are _mining_ using [blake2s](https://www.blake2.net/) algorithm, which produces 256 bit hashes. Hash/second is roughly {{ exp(num="20x10", exponent="3") }} on my machine, a new block can be mined in around 4-6 minutes. +Blocks in Gradecoin are proposed to commit [Transactions](@/transaction_docs.md) that were proposed previously to the system. +`transaction_list` of the Block should be filled with valid transactions to be committed. +Blocks are valid when they are proposed with a `nonce` that produces a `hash` value with 6 zeroes (24 bits) at the left hand side. + +We are _mining_ using [blake2s](https://www.blake2.net/) algorithm, which produces 256 bit hashes. +Hash/second is roughly {{ exp(num="20x10", exponent="3") }} on my machine, a new block can be mined in around 4-6 minutes. + +{% tidbit() %} +We have seen blocks that came in within a minute during the testnet phase! +{% end %} # Requests @@ -16,14 +24,13 @@ We are _mining_ using [blake2s](https://www.blake2.net/) algorithm, which produc A HTTP `GET` request to [/block](/block) endpoint will return the latest mined block. ## POST - -A HTTP `POST` request with Authorization using JWT will allow you to propose your own blocks. +A HTTP `POST` request with Authorization using [JWT](@/JWT.md) will allow you to propose your own blocks. # Fields ``` -transaction_list: [array of Fingerprints] +transaction_list: [array of Transaction IDs] nonce: unsigned 32-bit integer -timestamp: ISO 8601 T