implement and use prototype curve encryptors
This commit is contained in:
@@ -9,24 +9,8 @@ define([
|
||||
|
||||
var Nacl = window.nacl;
|
||||
|
||||
var alice = Nacl.box.keyPair();
|
||||
var bob = Nacl.box.keyPair();
|
||||
|
||||
var packed = Curve.encrypt('pewpew', bob.publicKey, alice.secretKey);
|
||||
console.log(packed);
|
||||
|
||||
var message = Curve.decrypt(packed, alice.publicKey, bob.secretKey);
|
||||
|
||||
console.log(message);
|
||||
|
||||
Cryptpad.removeLoadingScreen();
|
||||
Cryptpad.alert(message);
|
||||
|
||||
return {};
|
||||
|
||||
//var Messages = Cryptpad.Messages;
|
||||
var onReady = function () {
|
||||
|
||||
if (!APP.initialized) {
|
||||
APP.initialized = true;
|
||||
}
|
||||
@@ -37,22 +21,42 @@ define([
|
||||
var onDisconnect = function () {};
|
||||
var onChange = function () {};
|
||||
|
||||
var andThen = function (profileHash) {
|
||||
var secret = Cryptpad.getSecrets('profile', profileHash);
|
||||
var readOnly = APP.readOnly = secret.keys && !secret.keys.editKeyStr;
|
||||
var andThen = function () {
|
||||
var hash = window.location.hash.slice(1);
|
||||
|
||||
var info = Cryptpad.parseTypeHash('invite', hash);
|
||||
console.log(info);
|
||||
|
||||
if (!info.pubkey) {
|
||||
Cryptpad.removeLoadingScreen();
|
||||
Cryptpad.alert('invalid invite');
|
||||
return;
|
||||
}
|
||||
|
||||
var proxy = Cryptpad.getProxy();
|
||||
var mySecret = proxy.curvePrivate;
|
||||
|
||||
var encryptor = Curve.createEncryptor(info.pubkey, mySecret);
|
||||
|
||||
Cryptpad.removeLoadingScreen();
|
||||
var message = 'hello!';
|
||||
Cryptpad.alert(message);
|
||||
|
||||
var listmapConfig = {
|
||||
data: {},
|
||||
websocketURL: Cryptpad.getWebsocketURL(),
|
||||
channel: secret.channel,
|
||||
readOnly: readOnly,
|
||||
validateKey: secret.keys.validateKey || undefined,
|
||||
crypto: Crypto.createEncryptor(secret.keys),
|
||||
network: Cryptpad.getNetwork(),
|
||||
channel: info.channel,
|
||||
readOnly: false, //undefined,
|
||||
validateKey: undefined,
|
||||
crypto: encryptor,
|
||||
userName: 'profile',
|
||||
logLevel: 1,
|
||||
};
|
||||
var lm = APP.lm = Listmap.create(listmapConfig);
|
||||
lm.proxy.on('create', onInit)
|
||||
.on('ready', onReady)
|
||||
.on('ready', function () {
|
||||
console.log(JSON.stringify(lm.proxy));
|
||||
})
|
||||
.on('disconnect', onDisconnect)
|
||||
.on('change', [], onChange);
|
||||
};
|
||||
@@ -84,11 +88,7 @@ define([
|
||||
|
||||
Cryptpad.ready(function () {
|
||||
Cryptpad.reportAppUsage();
|
||||
|
||||
if (window.location.hash) {
|
||||
return void andThen(window.location.hash.slice(1));
|
||||
}
|
||||
andThen();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user