src/crypto/OlmDevice.js
function OlmDevice(cryptoStore) {
    this._cryptoStore = cryptoStore;
    this._pickleKey = "DEFAULT_KEY";

    // don't know these until we load the account from storage in init()
    this.deviceCurve25519Key = null;
    this.deviceEd25519Key = null;
    this._maxOneTimeKeys = null;

    // we don't bother stashing outboundgroupsessions in the cryptoStore -
    // instead we keep them here.
    this._outboundGroupSessionStore = {};

    // Store a set of decrypted message indexes for each group session.
    // This partially mitigates a replay attack where a MITM resends a group
    // message into the room.
    //
    // When we decrypt a message and the message index matches a previously
    // decrypted message, one possible cause of that is that we are decrypting
    // the same event, and may not indicate an actual replay attack.  For
    // example, this could happen if we receive events, forget about them, and
    // then re-fetch them when we backfill.  So we store the event ID and
    // timestamp corresponding to each message index when we first decrypt it,
    // and compare these against the event ID and timestamp every time we use
    // that same index.  If they match, then we're probably decrypting the same
    // event and we don't consider it a replay attack.
    //
    // Keys are strings of form "<senderKey>|<session_id>|<message_index>"
    // Values are objects of the form "{id: <event id>, timestamp: <ts>}"
    this._inboundGroupSessionMessageIndexes = {};

    // Keep track of sessions that we're starting, so that we don't start
    // multiple sessions for the same device at the same time.
    this._sessionsInProgress = {};
}
function OlmDevice(cryptoStore) {
    this._cryptoStore = cryptoStore;
    this._pickleKey = "DEFAULT_KEY";

    // don't know these until we load the account from storage in init()
    this.deviceCurve25519Key = null;
    this.deviceEd25519Key = null;
    this._maxOneTimeKeys = null;

    // we don't bother stashing outboundgroupsessions in the cryptoStore -
    // instead we keep them here.
    this._outboundGroupSessionStore = {};

    // Store a set of decrypted message indexes for each group session.
    // This partially mitigates a replay attack where a MITM resends a group
    // message into the room.
    //
    // When we decrypt a message and the message index matches a previously
    // decrypted message, one possible cause of that is that we are decrypting
    // the same event, and may not indicate an actual replay attack.  For
    // example, this could happen if we receive events, forget about them, and
    // then re-fetch them when we backfill.  So we store the event ID and
    // timestamp corresponding to each message index when we first decrypt it,
    // and compare these against the event ID and timestamp every time we use
    // that same index.  If they match, then we're probably decrypting the same
    // event and we don't consider it a replay attack.
    //
    // Keys are strings of form "<senderKey>|<session_id>|<message_index>"
    // Values are objects of the form "{id: <event id>, timestamp: <ts>}"
    this._inboundGroupSessionMessageIndexes = {};

    // Keep track of sessions that we're starting, so that we don't start
    // multiple sessions for the same device at the same time.
    this._sessionsInProgress = {};
}
function OlmDevice ( cryptoStore ) { this . _cryptoStore = cryptoStore ; this . _pickleKey = "DEFAULT_KEY" ; // don't know these until we load the account from storage in init() this . deviceCurve25519Key = null ; this . deviceEd25519Key = null ; this . _maxOneTimeKeys = null ; // we don't bother stashing outboundgroupsessions in the cryptoStore - // instead we keep them here. this . _outboundGroupSessionStore = { } ; // Store a set of decrypted message indexes for each group session. // This partially mitigates a replay attack where a MITM resends a group // message into the room. // // When we decrypt a message and the message index matches a previously // decrypted message, one possible cause of that is that we are decrypting // the same event, and may not indicate an actual replay attack.  For // example, this could happen if we receive events, forget about them, and // then re-fetch them when we backfill.  So we store the event ID and // timestamp corresponding to each message index when we first decrypt it, // and compare these against the event ID and timestamp every time we use // that same index.  If they match, then we're probably decrypting the same // event and we don't consider it a replay attack. // // Keys are strings of form "<senderKey>|<session_id>|<message_index>" // Values are objects of the form "{id: <event id>, timestamp: <ts>}" this . _inboundGroupSessionMessageIndexes = { } ; // Keep track of sessions that we're starting, so that we don't start // multiple sessions for the same device at the same time. this . _sessionsInProgress = { } ; }
The type of object we use for importing and exporting megolm session data.

@typedef {Object} module:crypto/OlmDevice.MegolmSessionData
@property {String} sender_key  Sender's Curve25519 device key
@property {String[]} forwarding_curve25519_key_chain Devices which forwarded
this session to us (normally empty).
@property {Object<string, string>} sender_claimed_keys Other keys the sender claims.
@property {String} room_id     Room this session is used in
@property {String} session_id  Unique id for the session
@property {String} session_key Base64'ed key data
 
Manages the olm cryptography functions. Each OlmDevice has a single
OlmAccount and a number of OlmSessions.

Accounts and sessions are kept pickled in the cryptoStore.

@constructor
@alias module:crypto/OlmDevice

@param {Object} cryptoStore A store for crypto data

@property {string} deviceCurve25519Key   Curve25519 key for the account
@property {string} deviceEd25519Key      Ed25519 key for the account
The type of object we use for importing and exporting megolm session data .