keyer

package
v0.42.3 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: MIT Imports: 12 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, pool *nostr.SimplePool, input string, opts *SignerOptions) (nostr.Keyer, error)

Types

type BunkerSigner

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

BunkerSigner is a signer that asks a bunker using NIP-46 every time it needs to do an operation.

func NewBunkerSignerFromBunkerClient

func NewBunkerSignerFromBunkerClient(bc *nip46.BunkerClient) BunkerSigner

func (BunkerSigner) Decrypt

func (bs BunkerSigner) Decrypt(ctx context.Context, base64ciphertext string, sender string) (plaintext string, err error)

func (BunkerSigner) Encrypt

func (bs BunkerSigner) Encrypt(ctx context.Context, plaintext string, recipient string) (string, error)

func (BunkerSigner) GetPublicKey

func (bs BunkerSigner) GetPublicKey(ctx context.Context) (string, error)

func (BunkerSigner) SignEvent

func (bs BunkerSigner) SignEvent(ctx context.Context, evt *nostr.Event) error

type Cipher deprecated

type Cipher interface {
	Encrypt(ctx context.Context, plaintext string, recipientPublicKey string) (base64ciphertext string, err error)
	Decrypt(ctx context.Context, base64ciphertext string, senderPublicKey string) (plaintext string, err error)
}

Deprecated: use nostr.Cipher instead

type EncryptedKeySigner

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

EncryptedKeySigner is a signer that must always ask the user for a password before every operation.

func (EncryptedKeySigner) Decrypt

func (es EncryptedKeySigner) Decrypt(ctx context.Context, base64ciphertext string, sender string) (plaintext string, err error)

func (EncryptedKeySigner) Encrypt

func (es EncryptedKeySigner) Encrypt(ctx context.Context, plaintext string, recipient string) (c64 string, err error)

func (*EncryptedKeySigner) GetPublicKey

func (es *EncryptedKeySigner) GetPublicKey(ctx context.Context) (string, error)

func (*EncryptedKeySigner) SignEvent

func (es *EncryptedKeySigner) SignEvent(ctx context.Context, evt *nostr.Event) error

type KeySigner

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

Keysigner is a signer that holds the private key in memory and can do all the operations instantly and easily.

func NewPlainKeySigner added in v0.36.3

func NewPlainKeySigner(sec string) (KeySigner, error)

func (KeySigner) Decrypt

func (ks KeySigner) Decrypt(ctx context.Context, base64ciphertext string, sender string) (string, error)

func (KeySigner) Encrypt

func (ks KeySigner) Encrypt(ctx context.Context, plaintext string, recipient string) (string, error)

func (KeySigner) GetPublicKey

func (ks KeySigner) GetPublicKey(ctx context.Context) (string, error)

func (KeySigner) SignEvent

func (ks KeySigner) SignEvent(ctx context.Context, evt *nostr.Event) error

type Keyer deprecated

type Keyer interface {
	Signer
	Cipher
}

Deprecated: use nostr.Keyer instead

type ManualSigner

type ManualSigner struct {
	ManualGetPublicKey func(context.Context) (string, error)
	ManualSignEvent    func(context.Context, *nostr.Event) error
	ManualEncrypt      func(ctx context.Context, plaintext string, recipientPublicKey string) (base64ciphertext string, err error)
	ManualDecrypt      func(ctx context.Context, base64ciphertext string, senderPublicKey string) (plaintext string, err error)
}

ManualSigner is a signer that doesn't really do anything, it just calls the functions given to it. It can be used when an app for some reason wants to ask the user to manually provide a signed event by copy-and-paste, for example.

func (ManualSigner) Decrypt

func (ms ManualSigner) Decrypt(ctx context.Context, base64ciphertext string, sender string) (plaintext string, err error)

func (ManualSigner) Encrypt

func (ms ManualSigner) Encrypt(ctx context.Context, plaintext string, recipient string) (c64 string, err error)

func (ManualSigner) GetPublicKey

func (ms ManualSigner) GetPublicKey(ctx context.Context) (string, error)

func (ManualSigner) SignEvent

func (ms ManualSigner) SignEvent(ctx context.Context, evt *nostr.Event) error

type Signer deprecated

type Signer interface {
	GetPublicKey(context.Context) (string, error)
	SignEvent(context.Context, *nostr.Event) error
}

Deprecated: use nostr.Signer instead

type SignerOptions

type SignerOptions struct {
	BunkerClientSecretKey string
	BunkerSignTimeout     time.Duration
	BunkerAuthHandler     func(string)

	// if a PasswordHandler is provided the key will be stored encrypted and this function will be called
	// every time an operation needs access to the key so the user can be prompted.
	PasswordHandler func(context.Context) string

	// if instead a Password is provided along with a ncryptsec, then the key will be decrypted and stored in plaintext.
	Password string
}

Jump to

Keyboard shortcuts

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