Documentation ¶
Index ¶
- type HashFunction
- type NonceGenerator
- type Pow
- func (p *Pow) GenerateNonce() (nonce []byte, checksum []byte, err error)
- func (p *Pow) VerifyDifficulty(hash []byte) bool
- func (p *Pow) VerifyHash(nonce []byte, data []byte, hash []byte, nonceSig []byte) (bool, error)
- func (p *Pow) VerifyHashAtDifficulty(nonce []byte, data []byte, hash []byte, nonceSig []byte) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NonceGenerator ¶
NonceGenerator function type. takes a length parameter and returns a string.
The length parameter is optional; the returned string need not be as long as the length parameter
type Pow ¶
type Pow struct { Secret []byte NonceLength int Check bool Difficulty int // NonceGenerator method returns a nonce. Takes an integer parameter // which is `Pow.NonceLength`. Defaults to `gonanoid.Nanoid` NonceGenerator NonceGenerator // Hash is a method that hashes a slice of bytes and returns a new slice which is a hash of the slice. // Defaults to `sha256.Sum256` Hash HashFunction }
Pow ...
func (*Pow) GenerateNonce ¶
GenerateNonce generates a new nonce, also generates signature if verify enabled
func (*Pow) VerifyDifficulty ¶
VerifyDifficulty verifies hash fulfils difficulty requirement
func (*Pow) VerifyHash ¶
VerifyHash verifies the hash given the nonce and data
Click to show internal directories.
Click to hide internal directories.