Skip to content

Minimal TCP server in Rust with Proof-of-Work (PoW) protection against DDoS attacks. Client solves challenge to receive a random quote of wisdom.

Notifications You must be signed in to change notification settings

wotori/rust-pow-word-of-wisdom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Word of Wisdom TCP Server (Proof of Work)

Minimal TCP challenge-response server that uses Proof of Work (PoW) to defend against DDoS attacks. After successful PoW validation, the server responds with a quote of wisdom.

How it works

  • The server sends a random challenge (16-byte hex) and a difficulty value.

  • The client brute-forces an 8-byte nonce so that:

    SHA256(SHA256(challenge || nonce))
    

    starts with a number of zero hex nibbles equal to the difficulty.

  • Once verified, the server replies with a quote. Otherwise, an error.

PoW algorithm

The algorithm is double SHA-256 (like Bitcoin), chosen for its simplicity and speed. Difficulty is defined by the number of leading zero hex nibbles.

Running

Locally

make run-server
make run-client

With Docker

make docker-build-server
make docker-build-client

make docker-run-server PORT=5050 DIFFICULTY=6
make docker-run-client PORT=5050

About

Minimal TCP server in Rust with Proof-of-Work (PoW) protection against DDoS attacks. Client solves challenge to receive a random quote of wisdom.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published