Versions in this module Expand all Collapse all v1 v1.10.4 Jun 13, 2022 Changes in this version + var ErrIncompletePreKeyWhisperMessage = errors.New("incomplete PreKeyWhisperMessage") + var ErrIncompleteWhisperMessage = errors.New("incomplete WhisperMessage") + var ErrInvalidMACForWhisperMessage = errors.New("invalid MAC for WhisperMessage") + var ErrUninitializedSession = errors.New("uninitialized session") + func CalculateAgreement(result, theirPub, ourPriv *[32]byte) + func ComputeTruncatedMAC(msg, key []byte, size int) []byte + func Decrypt(key, ciphertext []byte) ([]byte, error) + func DeriveSecrets(inputKeyMaterial, salt, info []byte, size int) ([]byte, error) + func Encrypt(key, iv, plaintext []byte) ([]byte, error) + func ValidTruncMAC(msg, expectedMAC, key []byte) bool + type DuplicateMessageError struct + func (err DuplicateMessageError) Error() string + type ECKeyPair struct + PrivateKey ECPrivateKey + PublicKey ECPublicKey + func MakeECKeyPair(privateKey, publicKey []byte) *ECKeyPair + func NewECKeyPair() *ECKeyPair + func (kp *ECKeyPair) String() string + type ECPrivateKey struct + func NewECPrivateKey(b []byte) *ECPrivateKey + func (k *ECPrivateKey) Key() *[32]byte + type ECPublicKey struct + func NewECPublicKey(b []byte) *ECPublicKey + func (k *ECPublicKey) Key() *[32]byte + func (k *ECPublicKey) Serialize() []byte + func (pk ECPublicKey) GetKey() [32]byte + type IdentityKey struct + func NewIdentityKey(b []byte) *IdentityKey + type IdentityKeyPair struct + PrivateKey ECPrivateKey + PublicKey IdentityKey + func GenerateIdentityKeyPair() *IdentityKeyPair + func NewIdentityKeyPairFromKeys(priv, pub []byte) *IdentityKeyPair + type IdentityStore interface + GetIdentityKeyPair func() (*IdentityKeyPair, error) + GetLocalRegistrationID func() (uint32, error) + IsTrustedIdentity func(string, *IdentityKey) bool + SaveIdentity func(string, *IdentityKey) error + type InvalidMessageError struct + func (err InvalidMessageError) Error() string + type InvalidSignatureError struct + func (err InvalidSignatureError) Error() string + type MismatchedVersionError struct + func (err MismatchedVersionError) Error() string + type NotTrustedError struct + ID string + func (err NotTrustedError) Error() string + type PreKeyBundle struct + DeviceID uint32 + IdentityKey *IdentityKey + PreKeyID uint32 + PreKeyPublic *ECPublicKey + RegistrationID uint32 + SignedPreKeyID int32 + SignedPreKeyPublic *ECPublicKey + SignedPreKeySignature [64]byte + func NewPreKeyBundle(registrationID, deviceID, preKeyID uint32, preKey *ECPublicKey, ...) (*PreKeyBundle, error) + type PreKeyNotFoundError struct + func (err PreKeyNotFoundError) Error() string + type PreKeyRecord struct + Pkrs *protobuf.PreKeyRecordStructure + func GenerateLastResortPreKey() *PreKeyRecord + func GeneratePreKeys(start, count int) []*PreKeyRecord + func LoadPreKeyRecord(serialized []byte) (*PreKeyRecord, error) + func NewPreKeyRecord(id uint32, kp *ECKeyPair) *PreKeyRecord + func (record *PreKeyRecord) Serialize() ([]byte, error) + type PreKeyStore interface + ContainsPreKey func(uint32) bool + LoadPreKey func(uint32) (*PreKeyRecord, error) + RemovePreKey func(uint32) + StorePreKey func(uint32, *PreKeyRecord) error + type PreKeyWhisperMessage struct + BaseKey *ECPublicKey + IdentityKey *IdentityKey + Message *WhisperMessage + PreKeyID uint32 + RegistrationID uint32 + SignedPreKeyID uint32 + Version byte + func LoadPreKeyWhisperMessage(serialized []byte) (*PreKeyWhisperMessage, error) + type SessionBuilder struct + func NewSessionBuilder(identityStore IdentityStore, preKeyStore PreKeyStore, ...) *SessionBuilder + func (sb *SessionBuilder) BuildReceiverSession(sr *SessionRecord, pkwm *PreKeyWhisperMessage) (uint32, error) + func (sb *SessionBuilder) BuildSenderSession(pkb *PreKeyBundle) error + type SessionCipher struct + Builder *SessionBuilder + DeviceID uint32 + PreKeyStore PreKeyStore + RecipientID string + SessionStore SessionStore + func NewSessionCipher(identityStore IdentityStore, preKeyStore PreKeyStore, ...) *SessionCipher + func (sc *SessionCipher) GetRemoteRegistrationID() (uint32, error) + func (sc *SessionCipher) SessionDecryptPreKeyWhisperMessage(ciphertext *PreKeyWhisperMessage) ([]byte, error) + func (sc *SessionCipher) SessionDecryptWhisperMessage(ciphertext *WhisperMessage) ([]byte, error) + func (sc *SessionCipher) SessionEncryptMessage(plaintext []byte) ([]byte, int32, error) + type SessionRecord struct + Fresh bool + PreviousStates []*sessionState + func LoadSessionRecord(serialized []byte) (*SessionRecord, error) + func NewSessionRecord() *SessionRecord + func (record *SessionRecord) Serialize() ([]byte, error) + type SessionStore interface + ContainsSession func(string, uint32) bool + DeleteAllSessions func(string) + DeleteSession func(string, uint32) + GetSubDeviceSessions func(string) []uint32 + LoadSession func(string, uint32) (*SessionRecord, error) + Lock func() + StoreSession func(string, uint32, *SessionRecord) error + Unlock func() + type SignedPreKeyRecord struct + Spkrs *protobuf.SignedPreKeyRecordStructure + func LoadSignedPreKeyRecord(serialized []byte) (*SignedPreKeyRecord, error) + func NewSignedPreKeyRecord(id uint32, timestamp uint64, kp *ECKeyPair, signature []byte) *SignedPreKeyRecord + func (record *SignedPreKeyRecord) Serialize() ([]byte, error) + type SignedPreKeyStore interface + ContainsSignedPreKey func(uint32) bool + LoadSignedPreKey func(uint32) (*SignedPreKeyRecord, error) + LoadSignedPreKeys func() []SignedPreKeyRecord + RemoveSignedPreKey func(uint32) + StoreSignedPreKey func(uint32, *SignedPreKeyRecord) error + type UnsupportedVersionError struct + func (err UnsupportedVersionError) Error() string + type WhisperMessage struct + Ciphertext []byte + Counter uint32 + PreviousCounter uint32 + RatchetKey *ECPublicKey + Version byte + func LoadWhisperMessage(serialized []byte) (*WhisperMessage, error)