1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-12-13 07:42:14 +03:00

pksign was moved to olmlib

This commit is contained in:
Hubert Chathi
2019-07-03 16:00:44 -04:00
parent 46a8486245
commit 6cd09c6af2
3 changed files with 0 additions and 46 deletions

View File

@@ -52,7 +52,6 @@ import { isCryptoAvailable } from './crypto';
import { encodeRecoveryKey, decodeRecoveryKey } from './crypto/recoverykey'; import { encodeRecoveryKey, decodeRecoveryKey } from './crypto/recoverykey';
import { keyForNewBackup, keyForExistingBackup } from './crypto/backup_password'; import { keyForNewBackup, keyForExistingBackup } from './crypto/backup_password';
import { randomString } from './randomstring'; import { randomString } from './randomstring';
import { pkSign } from './crypto/PkSigning';
import IndexedDBCryptoStore from './crypto/store/indexeddb-crypto-store'; import IndexedDBCryptoStore from './crypto/store/indexeddb-crypto-store';

View File

@@ -1,43 +0,0 @@
/*
Copyright 2019 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
const anotherjson = require('another-json');
/**
* Higher level wrapper around olm.PkSigning that signs JSON objects
* @param {Object} obj Object to sign
* @param {Uint8Array} seed The private key seed (32 bytes)
* @param {string} userId The user ID who owns the signing key
*/
export function pkSign(obj, seed, userId) {
const signing = new global.Olm.PkSigning();
try {
const pubkey = signing.init_with_seed(seed);
const sigs = obj.signatures || {};
const mysigs = sigs[userId] || {};
sigs[userId] = mysigs;
delete obj.signatures;
const unsigned = obj.unsigned;
if (obj.unsigned) delete obj.unsigned;
mysigs['ed25519:' + pubkey] = signing.sign(anotherjson.stringify(obj));
obj.signatures = sigs;
if (unsigned) obj.unsigned = unsigned;
} finally {
signing.free();
}
}

View File

@@ -50,8 +50,6 @@ import {
newUnknownMethodError, newUnknownMethodError,
} from './verification/Error'; } from './verification/Error';
import { pkSign } from './PkSigning';
const defaultVerificationMethods = { const defaultVerificationMethods = {
[ScanQRCode.NAME]: ScanQRCode, [ScanQRCode.NAME]: ScanQRCode,
[ShowQRCode.NAME]: ShowQRCode, [ShowQRCode.NAME]: ShowQRCode,