wow

module
v0.0.0-...-79df936 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2024 License: Apache-2.0

README

“Word of Wisdom” tcp server

Task

Design and implement “Word of Wisdom” tcp server.

  • TCP server should be protected from DDOS attacks with the Proof of Work (https://en.wikipedia.org/wiki/Proof_of_work), the challenge-response protocol should be used.
  • The choice of the POW algorithm should be explained.
  • After Proof Of Work verification, server should send one of the quotes from “word of wisdom” book or any other collection of the quotes.
  • Docker file should be provided both for the server and for the client that solves the POW challenge

Why was Hashcash chosen

  • Simplicity: The concept behind Hashcash is straightforward and easy to implement. It relies on computing hashes, which can be done even on relatively weak devices. This makes it suitable for various systems without requiring complex computational resources.
  • Provable work: The main idea of Proof of Work is to prove that a certain amount of work has been performed, which takes time and resources but is easily verifiable. In Hashcash, this is achieved by finding a special value (nonce) that, when combined with other data, produces a hash meeting specific criteria (e.g., having a certain number of leading zeros). Verifying such work takes significantly less time than performing it.
  • Adaptability: The algorithm can be adjusted to different levels of difficulty. For example, the required number of leading zeros in the hash can be increased or decreased depending on how challenging the task should be. This allows for flexible tuning of the system's load based on current needs.
  • Resistance to Attacks: Since the algorithm uses cryptographically secure hash functions like SHA-256, forging results is nearly impossible. To create a valid proof, one must genuinely perform the work rather than simply guess the correct answer.

Getting started

# Run server and client by docker-compose
make run

# Run only server by docker-compose
make server

# Run only client by docker-compose
make client

Directories

Path Synopsis
adapter
business
entity
Package entity provides entities for business logic.
Package entity provides entities for business logic.
cmd
client command
Package main Tapir server main package
Package main Tapir server main package
server command
Package main Tapir server main package
Package main Tapir server main package
pkg
logger
Package logger wrapper for zerolog
Package logger wrapper for zerolog

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL