diff --git a/src/client.js b/src/client.js index 4240d6593..54d4f038a 100644 --- a/src/client.js +++ b/src/client.js @@ -178,8 +178,8 @@ function keyFromRecoverySession(session, decryptionKey) { * * @param {object} opts.cryptoCallbacks Optional. Callbacks for crypto and cross-signing. * - * @param {function} [opts.cryptoCallbacks.getPrivateKey] - * Optional (required for cross-signing). Function to call when a private key is needed. + * @param {function} [opts.cryptoCallbacks.getCrossSigningKey] + * Optional (required for cross-signing). Function to call when a cross-signing private key is needed. * Args: * {string} type The type of key needed. Will be one of "master", * "self_signing", or "user_signing" @@ -190,7 +190,7 @@ function keyFromRecoverySession(session, decryptionKey) { * Should return a promise that resolves with the private key as a * UInt8Array or rejects with an error. * - * @param {function} [opts.cryptoCallbacks.savePrivateKeys] + * @param {function} [opts.cryptoCallbacks.saveCrossSigningKeys] * Optional (required for cross-signing). Called when new private keys * for cross-signing need to be saved. * Args: diff --git a/src/crypto/CrossSigning.js b/src/crypto/CrossSigning.js index 4000104c1..880931d00 100644 --- a/src/crypto/CrossSigning.js +++ b/src/crypto/CrossSigning.js @@ -35,7 +35,7 @@ export class CrossSigningInfo extends EventEmitter { * * @param {string} userId the user that the information is about * @param {object} callbacks Callbacks used to interact with the app - * Requires getPrivateKey and savePrivateKeys + * Requires getCrossSigningKey and saveCrossSigningKeys */ constructor(userId, callbacks) { super(); @@ -56,19 +56,19 @@ export class CrossSigningInfo extends EventEmitter { * @param {Uint8Array} expectedPubkey The matching public key or undefined to use * the stored public key for the given key type. */ - async getPrivateKey(type, expectedPubkey) { - if (!this._callbacks.getPrivateKey) { - throw new Error("No getPrivateKey callback supplied"); + async getCrossSigningKey(type, expectedPubkey) { + if (!this._callbacks.getCrossSigningKey) { + throw new Error("No getCrossSigningKey callback supplied"); } if (expectedPubkey === undefined) { expectedPubkey = getPublicKey(this.keys[type])[1]; } - const privkey = await this._callbacks.getPrivateKey(type, expectedPubkey); + const privkey = await this._callbacks.getCrossSigningKey(type, expectedPubkey); if (!privkey) { throw new Error( - "getPrivateKey callback for " + type + " returned falsey", + "getCrossSigningKey callback for " + type + " returned falsey", ); } const signing = new global.Olm.PkSigning(); @@ -76,7 +76,7 @@ export class CrossSigningInfo extends EventEmitter { if (gotPubkey !== expectedPubkey) { signing.free(); throw new Error( - "Key type " + type + " from getPrivateKey callback did not match", + "Key type " + type + " from getCrossSigningKey callback did not match", ); } else { return [gotPubkey, signing]; @@ -113,8 +113,8 @@ export class CrossSigningInfo extends EventEmitter { } async resetKeys(level) { - if (!this._callbacks.savePrivateKeys) { - throw new Error("No savePrivateKeys callback supplied"); + if (!this._callbacks.saveCrossSigningKeys) { + throw new Error("No saveCrossSigningKeys callback supplied"); } if (level === undefined || level & 4 || !this.keys.master) { @@ -141,7 +141,7 @@ export class CrossSigningInfo extends EventEmitter { }, }; } else { - [masterPub, masterSigning] = await this.getPrivateKey("master"); + [masterPub, masterSigning] = await this.getCrossSigningyKey("master"); } if (level & CrossSigningLevel.SELF_SIGNING) { @@ -181,7 +181,7 @@ export class CrossSigningInfo extends EventEmitter { } Object.assign(this.keys, keys); - this._callbacks.savePrivateKeys(privateKeys); + this._callbacks.saveCrossSigningKeys(privateKeys); } finally { if (masterSigning) { masterSigning.free(); @@ -262,7 +262,7 @@ export class CrossSigningInfo extends EventEmitter { } async signObject(data, type) { - const [pubkey, signing] = await this.getPrivateKey(type); + const [pubkey, signing] = await this.getCrossSigningKey(type); try { pkSign(data, signing, this.userId, pubkey); return data; diff --git a/src/crypto/index.js b/src/crypto/index.js index 48a5745c7..bbe7c8be5 100644 --- a/src/crypto/index.js +++ b/src/crypto/index.js @@ -236,11 +236,11 @@ Crypto.prototype.requestSecret = function(name, devices) { /** * Checks that a given private key matches a given public key - * This can be used by the getPrivateKey callback to verify that the + * This can be used by the getCrossSigningKey callback to verify that the * private key it is about to supply is the one that was requested. * * @param {Uint8Array} privateKey The private key - * @param {Uint8Array} expectedPublicKey The public key supplied by the getPrivateKey callback + * @param {Uint8Array} expectedPublicKey The public key supplied by the getCrossSigningKey callback * @returns {boolean} true if the key matches, otherwise false */ Crypto.prototype.checkPrivateKey = function(privateKey, expectedPublicKey) { @@ -583,7 +583,7 @@ Crypto.prototype.checkOwnCrossSigningTrust = async function() { let signing = null; try { - const ret = await this._crossSigningInfo.getPrivateKey( + const ret = await this._crossSigningInfo.getCrossSigningKey( 'master', seenPubkey, ); signing = ret[1];