provider

package
v0.0.0-...-e364a5d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Suggested min difficulty
	DifficultyMin int = 10
	// Suggested max difficulty
	DifficultyMax int = 1000000
	// Suggested min multiplier
	MultiplierMin int = 10
	// Suggested max multiplier
	MultiplierMax int = 1000000
)

Variables

This section is empty.

Functions

func NewChallenge

func NewChallenge(difficulty int, multiplier int) (Challenge, Verifier)

Generate a new challenge and the matching verifier

difficulty affects how much work both the server and the user have to do multiplier indicates the upper bound of how much more work the user has to do compared to the server

Types

type Challenge

type Challenge struct {
	Id         string `json:"id"`
	Query      []byte `json:"q"`
	Challenge  []byte `json:"c"`
	Difficulty int    `json:"d"`
}

The representation of a challenge to a user's browser

type Solution

type Solution struct {
	Id       string `json:"id"`
	Response []byte `json:"r"`
}

A solution to a Challenge

type Verifier

type Verifier struct {
	Id       string
	Expected []byte
}

A verifier to be stored by the server

func (Verifier) Verify

func (verifier Verifier) Verify(solution Solution) bool

Returns true if the solution is valid

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL