Back to

Package pow

Latest Go to latest

The highest tagged major version is .

Published: May 4, 2016 | License: BSD-3-Clause | Module:


Package pow is a simple "proof of work" interface.

It's based on a revers SHA512_224 function with a dynamic difficulty. New generated "POW" are saved in memeory tree using "". Challenge request contains an ID, a target, the needed difficulty and an expiration time.

The package save issued challenge requests and delete it when validate. That way the POW can't be use more than ones. Any request to the tree are piped to a channel to permit secured concurent access.

Embedded JSON generation, resolution and check for simple communication.

It is licence under "BSD 3-Clause License"


func Check

func Check(resp *challenger.Response) bool

Check give an easy way to just check if the response. It check the resulting hash is correct and the chalenge is part of the actives challenges list.

func CheckJSON

func CheckJSON(input []byte) bool

CheckJSON do the same as check but take a slice of byte as argument. The slice must represent a challenger.Response as JSON.

func GetChallenge

func GetChallenge(difficulty uint16, expirationTime time.Time) (*request.Challenge, error)

GetChallenge return a challenge object or an error

func GetChallengeAsJSON

func GetChallengeAsJSON(difficulty uint16, expirationTime time.Time) ([]byte, error)

GetChallengeAsJSON is analog to GetChallenge Exept it returns a slice of byte representing the element as JSON

func NewResolveLimits

func NewResolveLimits(dur time.Duration, trys uint64, nbBytes int) *challenger.ResolveLimits

NewResolveLimits build a new resolver limitations

func Resolve

func Resolve(challengeRequest *request.Challenge, limits *challenger.ResolveLimits) (*challenger.Response, error)

Resolve true to resolve the challenge. It returns the solution or an error.

func ResolveAsJSON

func ResolveAsJSON(input []byte, limits *challenger.ResolveLimits) ([]byte, error)

ResolveAsJSON is analog to Resolve Exept it returns a slice of byte representing the element as JSON

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier