Code Monkey home page Code Monkey logo

pow-php-javascript-demo's Introduction

pow-php-javascript-demo

This repository is proof of concept that implement proof of work system in PHP and javascript.

Screenshots

Server web deny content for customer request without submit proof of work solution

Server web deny content for customer request without submit proof of work solution

Customer solve proof of work at 207 hash/sec

Customer solve proof of work at 207 hash/sec

Customer submit proof of work solution and server web accept

Customer submit proof of work solution and server web accept

Server web show content for customer with submit proof of work solution

Server web show content for customer with submit proof of work solution

Getting Started

Drop the files contained in this repository in server (example /var/www) and configure your server web with new virtual host with document root is the htdocs directory of this repository. It notice that want settings.php be locate outside document root.

Hash function

Pass the values (in order) to SHA256 twice, like bitcoin

  1. hostname - the hostname of your server $_SERVER['HTTP_HOST']
  2. timestamp - a current iso-8601 timestamp in UTC
  3. rand - the random string put by the server and stored to $_SESSION['pow']['rand']
  4. counter - a nonce that is incremented until the hash satisfies the difficulty

Prevent cheater customer

Cheater customer prevent by

  1. Store difficulty in server variable of session PHP
  2. Check customer specific random number in server variable of session PHP
  3. Check solution use timestamp less than 1 old hour

Limitation

Javascript very slow. Cheater customer write C program and solve and submit solution server web many many fast than use javascript in this repository.

Wasm better. See https://github.com/shenzhu2/pow-php-wasm-demo

Donate

If demo help you please make donation at monero address

4ATt62EMG6KGW6EnehvnJJABd75RavSxZY367JCb3QWzKZJzbjHexkuYQA3TwJznz1F8NgqzrgPKQ6vnxuYEpSYVMfuLEo9

Thank you!

Authors

License

This project is license with AGPL License. See LICENSE

pow-php-javascript-demo's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.