0.0.2 • Published 5 years ago

pow-wasm v0.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

pow-wasm

Proof of work similar to Hashcash, based on BLAKE2b, written in JavaScript and WebAssembly

Installation

yarn add pow-wasm

Usage

const ObjectId = require('bson').ObjectId
const solve = require('pow-wasm/solve').solve
const validate = require('pow-wasm').validate

const salt = '' + ObjectId()
console.log(salt) // 5be97e10b697c24689180e9b

solve(salt, 20, 'oh hai').then(nonce => {
    console.log(nonce) // 1013723
    const result = validate(nonce, salt, 20, 'oh hai')
    console.log(result) // true
})

Message format

NameTypeSizeComment
nonceint648Little-endian int53
saltObjectId12
bitsint81
contentsUTF-8Capped at 1 MiB

The field separator is '\t'

0.0.2

5 years ago

0.0.1

5 years ago

0.0.0

5 years ago