https://github.com/mvasilkov/pow-wasm
Proof of work similar to Hashcash, based on BLAKE2b, written in JavaScript and WebAssembly
https://github.com/mvasilkov/pow-wasm
blake2b hashcash javascript proof-of-work webassembly
Last synced: 3 months ago
JSON representation
Proof of work similar to Hashcash, based on BLAKE2b, written in JavaScript and WebAssembly
- Host: GitHub
- URL: https://github.com/mvasilkov/pow-wasm
- Owner: mvasilkov
- License: mit
- Created: 2018-11-06T14:42:44.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-25T21:05:11.000Z (over 6 years ago)
- Last Synced: 2025-04-16T00:12:55.270Z (3 months ago)
- Topics: blake2b, hashcash, javascript, proof-of-work, webassembly
- Language: C
- Homepage:
- Size: 30.3 KB
- Stars: 6
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
pow-wasm
===Proof of work similar to Hashcash, based on BLAKE2b, written in JavaScript and WebAssembly
Installation
---```sh
yarn add pow-wasm
```Usage
---```js
const ObjectId = require('bson').ObjectId
const solve = require('pow-wasm/solve').solve
const validate = require('pow-wasm').validateconst salt = '' + ObjectId()
console.log(salt) // 5be97e10b697c24689180e9bsolve(salt, 20, 'oh hai').then(nonce => {
console.log(nonce) // 1013723
const result = validate(nonce, salt, 20, 'oh hai')
console.log(result) // true
})
```**Message format**
| Name | Type | Size | Comment
| --- | --- | --- | ---
| nonce | int64 | 8 | Little-endian int53
| salt | ObjectId | 12 |
| bits | int8 | 1 |
| contents | UTF-8 || Capped at 1 MiBThe field separator is `'\t'`