Documentation ¶
Index ¶
- func CreateTables(db *sql.DB) error
- func DecodeAndDeserializeKeyPair(data []byte, value interface{}) error
- func ExtractUserIDAndDeviceID(registrationID uint32) (uint32, uint32)
- func GenerateRegistrationID(userID, deviceID uint32) uint32
- func GetMACAddress() (string, error)
- func LoadLocalIdentity(db *sql.DB, userID uint32) (identity.KeyPair, uint32, error)
- func MacToUint32(macAddr string) (uint32, error)
- func NewGroupStore() session.GroupStore
- func NewIdentityStore(db *sql.DB) identity.Store
- func NewPreKeyStore(db *sql.DB) prekey.Store
- func NewSessionStore(db *sql.DB) session.Store
- func NewSignedPreKeyStore(db *sql.DB) prekey.SignedStore
- func SerializeKeyPairAndEncode(keyPair interface{}) ([]byte, error)
- func To[T any](t T) *T
- type ChatMessage
- type GroupStore
- type IdentityStore
- func (s *IdentityStore) Clear() error
- func (s *IdentityStore) IsTrustedIdentity(ctx context.Context, addr address.Address, identityKey identity.Key, ...) (bool, error)
- func (s *IdentityStore) KeyPair(_ context.Context) identity.KeyPair
- func (s *IdentityStore) Load(ctx context.Context, addr address.Address) (identity.Key, bool, error)
- func (s *IdentityStore) LocalRegistrationID(_ context.Context) uint32
- func (s *IdentityStore) Store(ctx context.Context, addr address.Address, identityKey identity.Key) (bool, error)
- type LocalIdentity
- type PreKeyStore
- type SQLiteStore
- func (s *SQLiteStore) CreateLocalIdentity(registrationID uint32) (*LocalIdentity, error)
- func (s *SQLiteStore) DeleteMessage(messageID int64) error
- func (s *SQLiteStore) GetAllChatHistory() ([]ChatMessage, error)
- func (s *SQLiteStore) GetChatHistory(senderID, receiverID uint32) ([]ChatMessage, error)
- func (s *SQLiteStore) GetChatHistoryBetweenUsers(senderID, receiverID uint32) ([]ChatMessage, error)
- func (s *SQLiteStore) GroupStore() session.GroupStore
- func (s *SQLiteStore) IdentityStore() identity.Store
- func (s *SQLiteStore) PreKeyStore() prekey.Store
- func (s *SQLiteStore) SaveChatMessage(messageID string, senderID, receiverID uint32, message string, delivered int) error
- func (s *SQLiteStore) SessionStore() session.Store
- func (s *SQLiteStore) SignedPreKeyStore() prekey.SignedStore
- func (s *SQLiteStore) UpdateMessageDeliveryStatus(messageID string, delivered bool) error
- type SerializableKeyPair
- type SessionStore
- type SignedPreKeyStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateTables ¶
CreateTables ensures that the necessary tables for the Signal Protocol stores exist.
func DecodeAndDeserializeKeyPair ¶
DecodeAndDeserializeKeyPair deserializes a JSON-encoded byte slice into the provided struct (mimics gobDecode).
func ExtractUserIDAndDeviceID ¶
ExtractUserIDAndDeviceID extracts the userID and deviceID from a combined registrationID.
func GenerateRegistrationID ¶
func GetMACAddress ¶
func LoadLocalIdentity ¶
LoadLocalIdentity loads the identity key pair and registration ID based on the current device's MAC address.
func MacToUint32 ¶
Convert a MAC address string into a uint32 with a limit to 10 bits
func NewGroupStore ¶
func NewGroupStore() session.GroupStore
NewIdentityStore creates a new SQLite-backed identity store.
func NewIdentityStore ¶
NewIdentityStore creates a new SQLite-backed identity store.
func NewPreKeyStore ¶
NewPreKeyStore creates a new SQLite-backed pre-key store.
func NewSessionStore ¶
NewSessionStore creates a new SQLite-backed session store.
func NewSignedPreKeyStore ¶
func NewSignedPreKeyStore(db *sql.DB) prekey.SignedStore
NewSignedPreKeyStore creates a new SQLite-backed signed pre-key store.
func SerializeKeyPairAndEncode ¶
SerializeKeyPairAndEncode serializes a struct to JSON format (mimics gobEncode).
Types ¶
type ChatMessage ¶
type GroupStore ¶
type GroupStore struct{}
func (*GroupStore) Load ¶
func (g *GroupStore) Load(ctx context.Context, sender address.Address, distributionID distribution.ID) (*session.GroupRecord, bool, error)
func (*GroupStore) Store ¶
func (g *GroupStore) Store(ctx context.Context, sender address.Address, distributionID distribution.ID, record *session.GroupRecord) error
type IdentityStore ¶
type IdentityStore struct {
// contains filtered or unexported fields
}
func (*IdentityStore) Clear ¶
func (s *IdentityStore) Clear() error
Clear removes all items from the store.
func (*IdentityStore) IsTrustedIdentity ¶
func (s *IdentityStore) IsTrustedIdentity(ctx context.Context, addr address.Address, identityKey identity.Key, _ direction.Direction) (bool, error)
IsTrustedIdentity returns "true" if the given identity key for the given address is already trusted. If there is no entry for the given address, the given identity key is trusted.
func (*IdentityStore) KeyPair ¶
func (s *IdentityStore) KeyPair(_ context.Context) identity.KeyPair
KeyPair returns the associated identity key pair from the database.
func (*IdentityStore) LocalRegistrationID ¶
func (s *IdentityStore) LocalRegistrationID(_ context.Context) uint32
LocalRegistrationID returns the associated registration ID from the database.
func (*IdentityStore) Store ¶
func (s *IdentityStore) Store(ctx context.Context, addr address.Address, identityKey identity.Key) (bool, error)
Store stores the identity key associated with the remote address and returns "true" if there is already an entry for the address that is overwritten with a new identity key.
type LocalIdentity ¶
type PreKeyStore ¶
type PreKeyStore struct {
// contains filtered or unexported fields
}
func (*PreKeyStore) Delete ¶
Delete removes a pre-key entry identified by the given ID from the store.
type SQLiteStore ¶
func NewSQLiteStore ¶
func NewSQLiteStore(dbPath string) (*SQLiteStore, error)
func (*SQLiteStore) CreateLocalIdentity ¶
func (s *SQLiteStore) CreateLocalIdentity(registrationID uint32) (*LocalIdentity, error)
func (*SQLiteStore) DeleteMessage ¶
func (s *SQLiteStore) DeleteMessage(messageID int64) error
DeleteMessage deletes a specific message from the `chat_history` table.
func (*SQLiteStore) GetAllChatHistory ¶
func (s *SQLiteStore) GetAllChatHistory() ([]ChatMessage, error)
GetAllChatHistory retrieves all stored chat messages.
func (*SQLiteStore) GetChatHistory ¶
func (s *SQLiteStore) GetChatHistory(senderID, receiverID uint32) ([]ChatMessage, error)
GetChatHistory retrieves all chat messages between a sender and receiver.
func (*SQLiteStore) GetChatHistoryBetweenUsers ¶
func (s *SQLiteStore) GetChatHistoryBetweenUsers(senderID, receiverID uint32) ([]ChatMessage, error)
func (*SQLiteStore) GroupStore ¶
func (s *SQLiteStore) GroupStore() session.GroupStore
func (*SQLiteStore) IdentityStore ¶
func (s *SQLiteStore) IdentityStore() identity.Store
func (*SQLiteStore) PreKeyStore ¶
func (s *SQLiteStore) PreKeyStore() prekey.Store
func (*SQLiteStore) SaveChatMessage ¶
func (s *SQLiteStore) SaveChatMessage(messageID string, senderID, receiverID uint32, message string, delivered int) error
SaveChatMessage inserts a new chat message with the specified messageId into the `chat_history` table.
func (*SQLiteStore) SessionStore ¶
func (s *SQLiteStore) SessionStore() session.Store
func (*SQLiteStore) SignedPreKeyStore ¶
func (s *SQLiteStore) SignedPreKeyStore() prekey.SignedStore
func (*SQLiteStore) UpdateMessageDeliveryStatus ¶
func (s *SQLiteStore) UpdateMessageDeliveryStatus(messageID string, delivered bool) error
UpdateMessageDeliveryStatus updates the `delivered` status of a message in the `chat_history` table.
type SerializableKeyPair ¶
type SessionStore ¶
type SessionStore struct {
// contains filtered or unexported fields
}
type SignedPreKeyStore ¶
type SignedPreKeyStore struct {
// contains filtered or unexported fields
}
func (*SignedPreKeyStore) Load ¶
func (s *SignedPreKeyStore) Load(ctx context.Context, id prekey.ID) (*prekey.SignedPreKey, bool, error)
Load retrieves a signed pre-key record for the given ID.
func (*SignedPreKeyStore) Store ¶
func (s *SignedPreKeyStore) Store(ctx context.Context, id prekey.ID, record *prekey.SignedPreKey) error
Store saves a signed pre-key record for the given ID.