nip26

package
v0.18.4 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoDelegationTag error = fmt.Errorf("No Delegation Tag")

This error is returned by d.Parse(ev) if the event ev does not have a delegation token.

View Source
var VerificationFailed error = fmt.Errorf("VerificationFailed")

This error is returned by Import(t,delegatee_pk) if the token signature verification fails.

Functions

func CheckDelegation

func CheckDelegation(ev *nostr.Event) (ok bool, err error)

CheckDelegation reads the event and reports whether or not it is correctly delegated. If there is a delegation tag, the delegation token signature will be checked according to NIP-26. If there is no delegation tag, ok will be true and err will be nil. For checking many events, it is advisable to use Parse to reduce the number of memory allocations.

func DelegatedSign

func DelegatedSign(ev *nostr.Event, d *DelegationToken, delegatee_sk string) error

DelegatedSign performs a delegated signature on the event ev. The delegation signature is not verified. If desired, the caller can ensure the delegation signature is correct by calling d.Parse(ev) or CheckDelegation(ev) afterwards.

Types

type DelegationToken

type DelegationToken struct {
	// contains filtered or unexported fields
}

func CreateToken

func CreateToken(delegator_sk string, delegatee_pk string, kinds []int, since *time.Time, until *time.Time) (d *DelegationToken, e error)

CreateToken creates a DelegationToken according to NIP-26.

func Import

func Import(t nostr.Tag, delegatee_pk string) (d *DelegationToken, e error)

Import verifies that t is NIP-26 delegation token for the given delegatee. The returned DelegationToken object can be used in DelegatedSign. If the token signature verification fails, the error VerificationFailed will be returned.

func (*DelegationToken) Conditions

func (d *DelegationToken) Conditions() (conditions string)

Conditions() is the delegation conditions string as in NIP-26.

func (*DelegationToken) Parse

func (d *DelegationToken) Parse(ev *nostr.Event) (ok bool, err error)

Parse reads the event ev and stores the delegation token into d. The ok value verifies the event is correctly delegated. If there is no delegation token, then d will not be changed. In this case the error value will be `NoDelegationTag`, and ok will be set to true. Parse does NOT verify the event was correctly signed. Use ev.CheckSignature() for this. More efficient memory allocations versus CheckDelegation(ev) if many events need to be checked.

func (*DelegationToken) Tag

func (d *DelegationToken) Tag() nostr.Tag

Tag() returns the nostr formatted delegation tag for the DelegationToken d.

Jump to

Keyboard shortcuts

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