Documentation ¶
Overview ¶
Package nip13 implements NIP-13 See https://github.com/nostr-protocol/nips/blob/master/13.md for details.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrDifficultyTooLow = errors.New("nip13: insufficient difficulty") ErrGenerateTimeout = errors.New("nip13: generating proof of work took too long") )
Functions ¶
func Check ¶
Check reports whether the event ID demonstrates a sufficient proof of work difficulty. Note that Check performs no validation other than counting leading zero bits in an event ID. It is up to the callers to verify the event with other methods, such as nostr.Event.CheckSignature.
func Difficulty ¶
Difficulty counts the number of leading zero bits in an event ID. It returns a negative number if the event ID is malformed.
func Generate ¶
func Generate(event *nostr.Event, targetDifficulty int, timeout time.Duration) (*nostr.Event, error)
Generate performs proof of work on the specified event until either the target difficulty is reached or the function runs for longer than the timeout. The latter case results in ErrGenerateTimeout.
Upon success, the returned event always contains a "nonce" tag with the target difficulty commitment, and an updated event.CreatedAt.
Types ¶
This section is empty.