The core protocol of WoopChain
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
woop/pow
Minh Doan 0e34dcf448 fix a lot of basic mistakes. See https://docs.google.com/document/d/1eIuVFnRra8Ggnj5zSTcGLn9iXGwHEdOHGC6-gHvvuGc 6 years ago
..
LICENSE WIP commit 6 years ago
README.md WIP commit 6 years ago
api.go fix a lot of basic mistakes. See https://docs.google.com/document/d/1eIuVFnRra8Ggnj5zSTcGLn9iXGwHEdOHGC6-gHvvuGc 6 years ago
api_test.go WIP commit 6 years ago
example_test.go WIP commit 6 years ago
sha2bday.go WIP commit 6 years ago

README.md

go-pow

go-pow is a simple Go package to add (asymmetric) Proof of Work to your service.

To create a Proof-of-Work request (with difficulty 5), use pow.NewRequest:

req := pow.NewRequest(5, someRandomNonce)

This returns a string like sha2bday-5-c29tZSByYW5kb20gbm9uY2U, which can be passed on to the client. The client fulfils the proof of work by running pow.Fulfil:

proof, _ := pow.Fulfil(req, []byte("some bound data"))

The client returns the proof (in this case AAAAAAAAAAMAAAAAAAAADgAAAAAAAAAb) to the server, which can check it is indeed a valid proof of work, by running:

ok, _ := pow.Check(req, proof, []byte("some bound data"))

Notes

  1. There should be at least sufficient randomness in either the nonce passed to NewRequest or the data passed to Fulfil and Check. Thus it is fine to use the same bound data for every client, if every client get a different nonce in its proof-of-work request. It is also fine to use the same nonce in the proof-of-work request, if every client is (by the encapsulating protocol) forced to use different bound data.

  2. The work to fulfil a request scales exponentially in the difficulty parameter. The work to check it proof is correct remains constant:

    Check on Difficulty=5  	  500000	      2544 ns/op
    Check on Difficulty=10 	  500000	      2561 ns/op
    Check on Difficulty=15 	  500000	      2549 ns/op
    Check on Difficulty=20 	  500000	      2525 ns/op
    Fulfil on Difficulty=5  	  100000	     15725 ns/op
    Fulfil on Difficulty=10 	   30000	     46808 ns/op
    Fulfil on Difficulty=15 	    2000	    955606 ns/op
    Fulfil on Difficulty=20 	     200	   6887722 ns/op
    

To do

  • Support for equihash would be nice.
  • Port to Python, Java, Javascript, ...
  • Parallelize.