mls

package module
v0.0.0-...-afe930b Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2025 License: Unlicense Imports: 6 Imported by: 0

README

nostr-mls

WIP

Current Status

Groups
  • Create a group
  • Export a secret key
  • Send a message
  • Receive a message
Key Packages
  • Update a credential with a signature key pair
  • Create a key package payload
  • Delete a key package from store
    • not planned: We only store signature keys
  • Parse a key package payload
Welcomes
  • Parse a welcome message
  • Preview a welcome message
  • Join a group from a welcome message

Documentation

Index

Constants

View Source
const (
	KindMLSKeyPackage          = 443
	KindMLSWelcome             = 444
	KindMLSGroupMessage        = 445
	KindMLSKeyPackageRelayList = 10051
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CredentialWithKey

type CredentialWithKey struct {
	Credential         *mls.Credential
	SignaturePublicKey []byte
}

type Group

type Group struct {
	WelcomeMessage []byte
	NostrGroupData *extension.NostrGroupData
	// contains filtered or unexported fields
}

type GroupUpdateInfo

type GroupUpdateInfo struct {
	WelcomeMessage     []byte
	PrevExporterSecret string // hex
	ExporterSecret     string // hex
	Epoch              uint64
}

type KeyPackage

type KeyPackage mls.KeyPackage

type MemoryStore

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

MemoryStore is used for tests

func (*MemoryStore) Clear

func (s *MemoryStore) Clear() error

func (*MemoryStore) Get

func (s *MemoryStore) Get(key []byte) ([]byte, error)

func (*MemoryStore) Remove

func (s *MemoryStore) Remove(key []byte) error

func (*MemoryStore) Upsert

func (s *MemoryStore) Upsert(key, value []byte) error

type NostrMLS

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

func NewNostrMLS

func NewNostrMLS(store Store) *NostrMLS

func (*NostrMLS) ClearStore

func (n *NostrMLS) ClearStore() error

func (*NostrMLS) CreateKeyPackageHex

func (n *NostrMLS) CreateKeyPackageHex(pubkey string) (string, error)

func (*NostrMLS) CreateMessage

func (n *NostrMLS) CreateMessage(groupID []byte, message string) (string, error)

func (*NostrMLS) ExporterSecretWithEpoch

func (n *NostrMLS) ExporterSecretWithEpoch(groupID []byte) (string, uint64, error)

func (*NostrMLS) NewGroup

func (n *NostrMLS) NewGroup(name, description, creator string, memberKeyPackages []KeyPackage, admins, relays []string) (*Group, error)

creator: pubkey admins: list of pubkeys

func (*NostrMLS) ParseKeyPackage

func (n *NostrMLS) ParseKeyPackage(keyPackageHex string) (*KeyPackage, error)

func (*NostrMLS) ParseSerializedEventFromGroupMessage

func (n *NostrMLS) ParseSerializedEventFromGroupMessage(groupID []byte, message string) ([]byte, error)

func (*NostrMLS) PreviewWelcome

func (n *NostrMLS) PreviewWelcome(welcomeMessage []byte) (*WelcomePreview, error)

type Store

type Store interface {
	// Upsert updates or inserts an entry
	Upsert(key, value []byte) error
	// Get gets an entry
	Get(key []byte) ([]byte, error)
	// Remove removes an entry
	Remove(key []byte) error
	// Clear clears entire store
	Clear() error
}

Store is used for NostrMLS

func NewMemoryStore

func NewMemoryStore() Store

type Welcome

type Welcome mls.Welcome

type WelcomePreview

type WelcomePreview struct {
	Welcome        *Welcome
	NostrGroupData *extension.NostrGroupData
}

func (*WelcomePreview) Join

func (p *WelcomePreview) Join() (*Group, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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