src/crypto/OlmDevice.js
/**
 * Manages the olm cryptography functions. Each OlmDevice has a single
 * OlmAccount and a number of OlmSessions.
 *
 * Accounts and sessions are kept pickled in a sessionStore.
 *
 * @constructor
 * @alias module:crypto/OlmDevice
 *
 * @param {Object} sessionStore A store to be used for data in end-to-end
 *    crypto
 *
 * @property {string} deviceCurve25519Key   Curve25519 key for the account
 * @property {string} deviceEd25519Key      Ed25519 key for the account
 */
Manages the olm cryptography functions. Each OlmDevice has a single
OlmAccount and a number of OlmSessions.

Accounts and sessions are kept pickled in a sessionStore.



@param {Object} sessionStore A store to be used for data in end-to-end
crypto

@property {string} deviceCurve25519Key   Curve25519 key for the account
@property {string} deviceEd25519Key      Ed25519 key for the account
Manages the olm cryptography functions . Each OlmDevice has a single OlmAccount and a number of OlmSessions . Accounts and sessions are kept pickled in a sessionStore . @param { Object } sessionStore A store to be used for data in end - to - end crypto @property { string } deviceCurve25519Key Curve25519 key for the account @property { string } deviceEd25519Key Ed25519 key for the account
function OlmDevice(sessionStore) {
    this._sessionStore = sessionStore;
    this._pickleKey = "DEFAULT_KEY";
    let e2eKeys;
    const account = new Olm.Account();
    try {
        _initialise_account(this._sessionStore, this._pickleKey, account);
        e2eKeys = JSON.parse(account.identity_keys());
    } finally {
        account.free();
    }
    this.deviceCurve25519Key = e2eKeys.curve25519;
    this.deviceEd25519Key = e2eKeys.ed25519;
    this._outboundGroupSessionStore = {};
     TODO: If we ever remove an event from memory we will also need to remove
     it from this map. Otherwise if we download the event from the server we
     will think that it is a duplicate.
     Keys are strings of form "<senderKey>|<session_id>|<message_index>"
     Values are true.
    this._inboundGroupSessionMessageIndexes = {};
}
function OlmDevice ( sessionStore ) { this . _sessionStore = sessionStore ; this . _pickleKey = "DEFAULT_KEY" ; let e2eKeys ; const account = new Olm . Account ( ) ; try { _initialise_account ( this . _sessionStore , this . _pickleKey , account ) ; e2eKeys = JSON . parse ( account . identity_keys ( ) ) ; } finally { account . free ( ) ; } this . deviceCurve25519Key = e2eKeys . curve25519 ; this . deviceEd25519Key = e2eKeys . ed25519 ; this . _outboundGroupSessionStore = { } ; this . _inboundGroupSessionMessageIndexes = { } ; }
Manages the olm cryptography functions.
Manages the olm cryptography functions .
// we don't bother stashing outboundgroupsessions in the sessionstore - // instead we keep them here. // 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. // // TODO: If we ever remove an event from memory we will also need to remove // it from this map. Otherwise if we download the event from the server we // will think that it is a duplicate. // // Keys are strings of form "<senderKey>|<session_id>|<message_index>" // Values are true.