Documentation
¶
Index ¶
- Variables
- func Decrypt(cyphertext []byte, key []byte) ([]byte, error)
- func Encrypt(plaintext []byte, key []byte, reader io.Reader) ([]byte, error)
- func HashPublicKey(pk *ecdsa.PublicKey) []byte
- func IsPubKeyEqual(a, b *ecdsa.PublicKey) bool
- func MessageSpecToWhisper(spec *encryption.ProtocolMessageSpec) (*types.NewMessage, error)
- func Shake256(buf []byte) []byte
- type ChatEntity
- type FeatureFlags
- type MessageProcessor
- func (p *MessageProcessor) AddEphemeralKey(privateKey *ecdsa.PrivateKey) (*transport.Filter, error)
- func (p *MessageProcessor) EncodeMembershipUpdate(group *v1protocol.Group, chatEntity ChatEntity) ([]byte, error)
- func (p *MessageProcessor) HandleMessages(shhMessage *types.Message, applicationLayer bool) ([]*v1protocol.StatusMessage, error)
- func (p *MessageProcessor) JoinPublic(chatID string) error
- func (p *MessageProcessor) SendGroup(ctx context.Context, recipients []*ecdsa.PublicKey, rawMessage RawMessage) ([]byte, error)
- func (p *MessageProcessor) SendPairInstallation(ctx context.Context, recipient *ecdsa.PublicKey, rawMessage RawMessage) ([]byte, error)
- func (p *MessageProcessor) SendPrivate(ctx context.Context, recipient *ecdsa.PublicKey, rawMessage RawMessage) ([]byte, error)
- func (p *MessageProcessor) SendPublic(ctx context.Context, chatName string, rawMessage RawMessage) ([]byte, error)
- func (p *MessageProcessor) SetHandleSharedSecrets(handler func([]*sharedsecret.Secret) error)
- func (p *MessageProcessor) Stop()
- func (p *MessageProcessor) SubscribeToScheduledMessages() <-chan *RawMessage
- func (p *MessageProcessor) SubscribeToSentMessages() <-chan *SentMessage
- type RawMessage
- type SentMessage
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidCiphertextLength = errors.New("invalid cyphertext length")
Functions ¶
func HashPublicKey ¶
func IsPubKeyEqual ¶
IsPubKeyEqual checks that two public keys are equal
func MessageSpecToWhisper ¶
func MessageSpecToWhisper(spec *encryption.ProtocolMessageSpec) (*types.NewMessage, error)
Types ¶
type ChatEntity ¶ added in v0.56.4
type ChatEntity interface { proto.Message GetChatId() string GetMessageType() protobuf.MessageType GetSigPubKey() *ecdsa.PublicKey GetProtobuf() proto.Message SetMessageType(messageType protobuf.MessageType) }
ChatEntity is anything that is sendable in a chat. Currently it encompass a Message and EmojiReaction.
type FeatureFlags ¶
type FeatureFlags struct { // Datasync indicates whether direct messages should be sent exclusively // using datasync, breaking change for non-v1 clients. Public messages // are not impacted Datasync bool // PushNotification indicates whether we should be enabling the push notification feature PushNotifications bool }
type MessageProcessor ¶
type MessageProcessor struct {
// contains filtered or unexported fields
}
func NewMessageProcessor ¶
func NewMessageProcessor( identity *ecdsa.PrivateKey, database *sql.DB, enc *encryption.Protocol, transport transport.Transport, logger *zap.Logger, features FeatureFlags, ) (*MessageProcessor, error)
func (*MessageProcessor) AddEphemeralKey ¶
func (p *MessageProcessor) AddEphemeralKey(privateKey *ecdsa.PrivateKey) (*transport.Filter, error)
AddEphemeralKey adds an ephemeral key that we will be listening to note that we never removed them from now, as waku/whisper does not recalculate topics on removal, so effectively there's no benefit. On restart they will be gone.
func (*MessageProcessor) EncodeMembershipUpdate ¶
func (p *MessageProcessor) EncodeMembershipUpdate( group *v1protocol.Group, chatEntity ChatEntity, ) ([]byte, error)
EncodeMembershipUpdate takes a group and an optional chat message and returns the protobuf representation to be sent on the wire. All the events in a group are encoded and added to the payload
func (*MessageProcessor) HandleMessages ¶
func (p *MessageProcessor) HandleMessages(shhMessage *types.Message, applicationLayer bool) ([]*v1protocol.StatusMessage, error)
HandleMessages expects a whisper message as input, and it will go through a series of transformations until the message is parsed into an application layer message, or in case of Raw methods, the processing stops at the layer before. It returns an error only if the processing of required steps failed.
func (*MessageProcessor) JoinPublic ¶
func (p *MessageProcessor) JoinPublic(chatID string) error
func (*MessageProcessor) SendGroup ¶
func (p *MessageProcessor) SendGroup( ctx context.Context, recipients []*ecdsa.PublicKey, rawMessage RawMessage, ) ([]byte, error)
SendGroup takes encoded data, encrypts it and sends through the wire, always return the messageID
func (*MessageProcessor) SendPairInstallation ¶
func (p *MessageProcessor) SendPairInstallation( ctx context.Context, recipient *ecdsa.PublicKey, rawMessage RawMessage, ) ([]byte, error)
sendPairInstallation sends data to the recipients, using DH
func (*MessageProcessor) SendPrivate ¶
func (p *MessageProcessor) SendPrivate( ctx context.Context, recipient *ecdsa.PublicKey, rawMessage RawMessage, ) ([]byte, error)
SendPrivate takes encoded data, encrypts it and sends through the wire.
func (*MessageProcessor) SendPublic ¶
func (p *MessageProcessor) SendPublic( ctx context.Context, chatName string, rawMessage RawMessage, ) ([]byte, error)
SendPublic takes encoded data, encrypts it and sends through the wire.
func (*MessageProcessor) SetHandleSharedSecrets ¶ added in v0.59.0
func (p *MessageProcessor) SetHandleSharedSecrets(handler func([]*sharedsecret.Secret) error)
func (*MessageProcessor) Stop ¶
func (p *MessageProcessor) Stop()
func (*MessageProcessor) SubscribeToScheduledMessages ¶
func (p *MessageProcessor) SubscribeToScheduledMessages() <-chan *RawMessage
SubscribeToScheduledMessages returns a channel where we publish every time a message is scheduled for sending
func (*MessageProcessor) SubscribeToSentMessages ¶
func (p *MessageProcessor) SubscribeToSentMessages() <-chan *SentMessage
SubscribeToSentMessages returns a channel where we publish every time a message is sent
type RawMessage ¶
type RawMessage struct { ID string LocalChatID string LastSent uint64 SendCount int Sent bool ResendAutomatically bool SkipEncryption bool SendPushNotification bool MessageType protobuf.ApplicationMetadataMessage_Type Payload []byte Sender *ecdsa.PrivateKey Recipients []*ecdsa.PublicKey }
RawMessage represent a sent or received message, kept for being able to re-send/propagate
type SentMessage ¶
type SentMessage struct { PublicKey *ecdsa.PublicKey Spec *encryption.ProtocolMessageSpec MessageIDs [][]byte }
SentMessage reprent a message that has been passed to the transport layer