CryptoAgility namespace update + fix mailbox ID issue by rollback

This commit is contained in:
ITScutaru 2025-07-16 12:20:33 +03:00
parent 39e58c64da
commit 2d58d692fb
29 changed files with 128 additions and 89 deletions

View File

@ -28,7 +28,7 @@ if (dataIdx === -1) {
const ed = Util.decodeBase64(deleteData.toSign.edPublic);
const signed = Util.decodeUTF8(JSON.stringify(deleteData.toSign));
const proof = Util.decodeBase64(deleteData.proof);
if (!Crypto.AbstractCall.verifyDetached(signed, proof, ed)) { return void console.error("Invalid signature"); }
if (!Crypto.CryptoAgility.verifyDetached(signed, proof, ed)) { return void console.error("Invalid signature"); }
edPublic = escapeKeyCharacters(deleteData.toSign.edPublic);
}

View File

@ -5,7 +5,7 @@
const Crypto = require('chainpad-crypto/crypto');
const Util = require('../lib/common-util');
const keyPair = Crypto.AbstractCall.curveKeyPair();
const keyPair = Crypto.CryptoAgility.curveKeyPair();
console.log("You've just generated a new key pair for your support mailbox.");
console.log("The public key should first be added to your config.js file ('supportMailboxPublicKey'), then save and restart the server.");

View File

@ -9,11 +9,11 @@ let Util = require('../lib/common-util');
let msgStr = "This is a test";
let keys = Crypto.AbstractCall.signKeyPair();
let keys = Crypto.CryptoAgility.signKeyPair();
let pub = keys.publicKey;
let msg = Util.decodeUTF8(msgStr);
let signedMsg = Crypto.AbstractCall.sign(msg, keys.secretKey);
let signedMsg = Crypto.CryptoAgility.sign(msg, keys.secretKey);
let sig = signedMsg.subarray(0, 64);
LibSodium.ready.then(() => {
@ -57,8 +57,8 @@ console.log(LibSodium.crypto_sign_verify_detached(sig, msg, pub));
console.log('start tweetnacl');
a = +new Date();
for (let i = 0; i < n; i++) {
Crypto.AbstractCall.signOpen(signedMsg, pub);
Crypto.AbstractCall.verifyDetached(msg, sig, pub);
Crypto.CryptoAgility.signOpen(signedMsg, pub);
Crypto.CryptoAgility.verifyDetached(msg, sig, pub);
}
console.log('end tweetnacl ', (+new Date() - a), ' ms');

View File

@ -70,7 +70,7 @@ nThen(function (w) {
//console.log(i);
if (i-- <= 0) { return void done(); }
var ciphertext = Util.encodeBase64(Crypto.AbstractCall.bytes(256));
var ciphertext = Util.encodeBase64(Crypto.CryptoAgility.bytes(256));
client.anonRpc.send('WRITE_PRIVATE_MESSAGE', [
client.channel,

View File

@ -40,7 +40,7 @@ process.on('unhandledRejection', function (err) {
});
var makeCurveKeys = function () {
var pair = Crypto.AbstractCall.curveKeyPair();
var pair = Crypto.CryptoAgility.curveKeyPair();
return {
curvePrivate: Util.encodeBase64(pair.secretKey),
curvePublic: Util.encodeBase64(pair.publicKey),
@ -48,7 +48,7 @@ var makeCurveKeys = function () {
};
var makeEdKeys = function () {
var keys = Crypto.AbstractCall.signKeyPairFromSeed(Crypto.AbstractCall.bytes(Crypto.AbstractCall.signSeedLength()));
var keys = Crypto.CryptoAgility.signKeyPairFromSeed(Crypto.CryptoAgility.bytes(Crypto.CryptoAgility.signSeedLength()));
return {
edPrivate: Util.encodeBase64(keys.secretKey),
edPublic: Util.encodeBase64(keys.publicKey),

View File

@ -15,12 +15,12 @@ var factory = function (Util, Crypto, Keys) {
// This implementation must match that on the server
// it's used for a checksum
Hash.hashChannelList = function (list) {
return Util.encodeBase64(Crypto.AbstractCall.createHash(Util
return Util.encodeBase64(Crypto.CryptoAgility.createHash(Util
.decodeUTF8(JSON.stringify(list))));
};
Hash.generateSignPair = function () {
var ed = Crypto.AbstractCall.signKeyPair();
var ed = Crypto.CryptoAgility.signKeyPair();
var makeSafe = function (key) {
return Crypto.b64RemoveSlashes(key).replace(/=+$/g, '');
};
@ -35,13 +35,13 @@ var factory = function (Util, Crypto, Keys) {
Hash.getSignPublicFromPrivate = function (edPrivateSafeStr) {
var edPrivateStr = Crypto.b64AddSlashes(edPrivateSafeStr);
var privateKey = Util.decodeBase64(edPrivateStr);
var keyPair = Crypto.AbstractCall.signKeyPairFromSecretKey(privateKey);
var keyPair = Crypto.CryptoAgility.signKeyPairFromSecretKey(privateKey);
return Util.encodeBase64(keyPair.publicKey);
};
Hash.getCurvePublicFromPrivate = function (curvePrivateSafeStr) {
var curvePrivateStr = Crypto.b64AddSlashes(curvePrivateSafeStr);
var privateKey = Util.decodeBase64(curvePrivateStr);
var keyPair = Crypto.AbstractCall.boxKeyPairFromSecretKey(privateKey);
var keyPair = Crypto.CryptoAgility.boxKeyPairFromSecretKey(privateKey);
return Util.encodeBase64(keyPair.publicKey);
};
@ -117,7 +117,7 @@ var factory = function (Util, Crypto, Keys) {
Hash.ephemeralChannelLength = 34;
Hash.createChannelId = function (ephemeral) {
var id = uint8ArrayToHex(Crypto.AbstractCall.bytes(ephemeral? 17: 16));
var id = uint8ArrayToHex(Crypto.CryptoAgility.bytes(ephemeral? 17: 16));
if ([32, 34].indexOf(id.length) === -1 || /[^a-f0-9]/.test(id)) {
throw new Error('channel ids must consist of 32 hex characters');
}
@ -138,7 +138,7 @@ var factory = function (Util, Crypto, Keys) {
Hash.getBoxPublicFromSecret = function (priv) {
if (!priv) { return; }
var u8_priv = Hash.decodeBase64(priv);
var pair = Crypto.AbstractCall.boxKeyPairFromSecretKey(u8_priv);
var pair = Crypto.CryptoAgility.boxKeyPairFromSecretKey(u8_priv);
return Hash.encodeBase64(pair.publicKey);
};
@ -148,7 +148,7 @@ var factory = function (Util, Crypto, Keys) {
Hash.checkBoxKeyPair = function (priv, pub) {
if (!pub || !priv) { return false; }
var u8_priv = Hash.decodeBase64(priv);
var pair = Crypto.AbstractCall.boxKeyPairFromSecretKey(u8_priv);
var pair = Crypto.CryptoAgility.boxKeyPairFromSecretKey(u8_priv);
return pub === Hash.encodeBase64(pair.publicKey);
};
@ -653,7 +653,7 @@ Version 4: Data URL when not a realtime link yet (new pad or "static" app)
var keys = secret && secret.keys;
var secondary = keys && keys.secondaryKey;
if (!secondary) { return; }
var curvePair = Crypto.AbstractCall.boxKeyPairFromSecretKey(Util.decodeUTF8(secondary).slice(0,32));
var curvePair = Crypto.CryptoAgility.boxKeyPairFromSecretKey(Util.decodeUTF8(secondary).slice(0,32));
var ret = {};
ret.form_public = Util.encodeBase64(curvePair.publicKey);
var privateKey = ret.form_private = Util.encodeBase64(curvePair.secretKey);

View File

@ -10,11 +10,11 @@ const factory = (Crypto) => {
window.atob = window.atob || function (str) { return Buffer.from(str, 'base64').toString('binary'); };
window.btoa = window.btoa || function (str) { return Buffer.from(str, 'binary').toString('base64'); };
Util.encodeBase64 = Crypto.AbstractCall.encodeBase64;
Util.decodeBase64 = Crypto.AbstractCall.decodeBase64;
Util.encodeBase64 = Crypto.CryptoAgility.encodeBase64;
Util.decodeBase64 = Crypto.CryptoAgility.decodeBase64;
Util.encodeUTF8 = Crypto.AbstractCall.encodeUTF8;
Util.decodeUTF8 = Crypto.AbstractCall.decodeUTF8;
Util.encodeUTF8 = Crypto.CryptoAgility.encodeUTF8;
Util.decodeUTF8 = Crypto.CryptoAgility.decodeUTF8;
Util.slice = function (A, start, end) {
return Array.prototype.slice.call(A, start, end);

View File

@ -26,7 +26,7 @@ const factory = (nThen, Util, ApiConfig = {}, Nacl, Crypto) => {
};
var clone = o => JSON.parse(JSON.stringify(o));
var randomToken = () => Util.encodeBase64(Crypto.AbstractCall.bytes(24));
var randomToken = () => Util.encodeBase64(Crypto.CryptoAgility.bytes(24));
var postData = function (url, data, cb) {
var CB = Util.once(Util.mkAsync(cb));
fetch(url, {
@ -83,7 +83,7 @@ const factory = (nThen, Util, ApiConfig = {}, Nacl, Crypto) => {
copy.txid = txid;
copy.date = date;
var toSign = Util.decodeUTF8(JSON.stringify(copy));
var sig = Crypto.AbstractCall.signDetached(toSign, keypair.secretKey);
var sig = Crypto.CryptoAgility.signDetached(toSign, keypair.secretKey);
var encoded = Util.encodeBase64(sig);
var obj2 = {
sig: encoded,

View File

@ -23,7 +23,7 @@ const factory = (Util, ApiConfig = {}, ServerCommand, Nacl, Crypto) => {
// [b64_public, b64_sig, b64_block [version, nonce, content]]
Block.seed = function () {
return Crypto.AbstractCall.createHash(Util.decodeUTF8('pewpewpew'));
return Crypto.CryptoAgility.createHash(Util.decodeUTF8('pewpewpew'));
};
// should be deterministic from a seed...
@ -35,12 +35,12 @@ const factory = (Util, ApiConfig = {}, ServerCommand, Nacl, Crypto) => {
throw new Error('INVALID_SEED_LENGTH');
}
var signSeed = seed.subarray(0, Crypto.AbstractCall.signSeedLength());
var symmetric = seed.subarray(Crypto.AbstractCall.signSeedLength(),
Crypto.AbstractCall.signSeedLength() + Crypto.AbstractCall.secretboxKeyLength());
var signSeed = seed.subarray(0, Crypto.CryptoAgility.signSeedLength());
var symmetric = seed.subarray(Crypto.CryptoAgility.signSeedLength(),
Crypto.CryptoAgility.signSeedLength() + Crypto.CryptoAgility.secretboxKeyLength());
// Generate standard keys using the existing method
var sign = Crypto.AbstractCall.signKeyPairFromSeed(signSeed);
var sign = Crypto.CryptoAgility.signKeyPairFromSeed(signSeed);
// Store the post-quantum keys separately for future use (no server validation issues)
var pqSignPair = null;
@ -92,21 +92,21 @@ const factory = (Util, ApiConfig = {}, ServerCommand, Nacl, Crypto) => {
// (UTF8 content, keys object) => Uint8Array block
Block.encrypt = function (version, content, keys) {
var u8 = Util.decodeUTF8(content);
var nonce = Crypto.AbstractCall.bytes(Crypto.AbstractCall.secretboxNonceLength());
var nonce = Crypto.CryptoAgility.bytes(Crypto.CryptoAgility.secretboxNonceLength());
return Block.join([
[0],
nonce,
Crypto.AbstractCall.secretbox(u8, nonce, keys.symmetric)
Crypto.CryptoAgility.secretbox(u8, nonce, keys.symmetric)
]);
};
// (uint8Array block) => payload object
Block.decrypt = function (u8_content, keys) {
// version is currently ignored since there is only one
var nonce = u8_content.subarray(1, 1 + Crypto.AbstractCall.secretboxNonceLength());
var box = u8_content.subarray(1 + Crypto.AbstractCall.secretboxNonceLength());
var nonce = u8_content.subarray(1, 1 + Crypto.CryptoAgility.secretboxNonceLength());
var box = u8_content.subarray(1 + Crypto.CryptoAgility.secretboxNonceLength());
var plaintext = Crypto.AbstractCall.secretboxOpen(box, nonce, keys.symmetric);
var plaintext = Crypto.CryptoAgility.secretboxOpen(box, nonce, keys.symmetric);
try {
return JSON.parse(Util.encodeUTF8(plaintext));
} catch (e) {
@ -117,13 +117,13 @@ const factory = (Util, ApiConfig = {}, ServerCommand, Nacl, Crypto) => {
// (Uint8Array block) => signature
Block.sign = function (ciphertext, keys) {
var hash = Crypto.AbstractCall.createHash(ciphertext);
var hash = Crypto.CryptoAgility.createHash(ciphertext);
// Generate hybrid signature if post-quantum capabilities are available
if (keys.hasPQ && keys.pqSignPair) {
try {
// Generate classical signature (always required for server compatibility)
var classicalSig = Crypto.AbstractCall.signDetached(hash, keys.sign.secretKey);
var classicalSig = Crypto.CryptoAgility.signDetached(hash, keys.sign.secretKey);
// Generate post-quantum signature
var pqSig = Crypto.PQC.ml_dsa.ml_dsa44.internal.sign(keys.pqSignPair.secretKey, hash);
@ -149,7 +149,7 @@ const factory = (Util, ApiConfig = {}, ServerCommand, Nacl, Crypto) => {
}
// Classical signature with a type marker
classicalSig = Crypto.AbstractCall.signDetached(hash, keys.sign.secretKey);
classicalSig = Crypto.CryptoAgility.signDetached(hash, keys.sign.secretKey);
var taggedSig = new Uint8Array(classicalSig.length + 1);
taggedSig[0] = 0; // Type 0 indicates classical only
taggedSig.set(classicalSig, 1);

View File

@ -15,7 +15,7 @@ var factory = function (Util, Nacl, Crypto) {
// this handles that in a generic way
var signMsg = function (data, signKey) {
var buffer = Util.decodeUTF8(JSON.stringify(data));
return Util.encodeBase64(Crypto.AbstractCall.signDetached(buffer, signKey));
return Util.encodeBase64(Crypto.CryptoAgility.signDetached(buffer, signKey));
};
// sendMsg takes a pre-formed message, does a little validation

View File

@ -422,7 +422,7 @@ const factory = (Sortify, UserObject, ProxyManager,
var initTempRpc = (clientId, cb) => {
if (store.rpc) { return void cb(store.rpc); }
var kp = Crypto.AbstractCall.signKeyPair();
var kp = Crypto.CryptoAgility.signKeyPair();
var keys = {
edPublic: Util.encodeBase64(kp.publicKey),
edPrivate: Util.encodeBase64(kp.secretKey)
@ -881,9 +881,9 @@ const factory = (Sortify, UserObject, ProxyManager,
toSign.drive = store.driveChannel;
toSign.edPublic = edPublic;
var signKey = Util.decodeBase64(store.proxy.edPrivate);
var proof = Crypto.AbstractCall.signDetached(Util.decodeUTF8(Sortify(toSign)), signKey);
var proof = Crypto.CryptoAgility.signDetached(Util.decodeUTF8(Sortify(toSign)), signKey);
var check = Crypto.AbstractCall.verifyDetached(Util.decodeUTF8(Sortify(toSign)),
var check = Crypto.CryptoAgility.verifyDetached(Util.decodeUTF8(Sortify(toSign)),
proof,
Util.decodeBase64(edPublic));
@ -1781,7 +1781,7 @@ const factory = (Sortify, UserObject, ProxyManager,
if (!channel || !ownerKey) { return void console.error("Can't delete BAR pad"); }
try {
var signKey = Hash.decodeBase64(ownerKey);
var pair = Crypto.AbstractCall.signKeyPairFromSecretKey(signKey);
var pair = Crypto.CryptoAgility.signKeyPairFromSecretKey(signKey);
Pinpad.create(store.network, {
edPublic: Hash.encodeBase64(pair.publicKey),
edPrivate: Hash.encodeBase64(pair.secretKey)

View File

@ -10,21 +10,30 @@ var factory = function (Util, Cred, Nacl, Crypto) {
// ed and curve keys can be random...
Invite.generateKeys = function () {
var ed = Crypto.AbstractCall.signKeyPair();
var curve = Crypto.AbstractCall.curveKeyPair();
var ed = Crypto.CryptoAgility.signKeyPair();
var curve = Crypto.CryptoAgility.curveKeyPair();
var kem = Crypto.PQC.ml_dsa.ml_kem512().keygen();
var dsa = Crypto.PQC.ml_dsa.ml_dsa44.keygen();
return {
edPublic: encode64(ed.publicKey),
edPrivate: encode64(ed.secretKey),
curvePublic: encode64(curve.publicKey),
curvePrivate: encode64(curve.secretKey),
kemPublic: encode64(kem.publicKey),
kemPrivate: encode64(kem.secretKey),
dsaPublic: encode64(dsa.publicKey),
dsaPrivate: encode64(dsa.secretKey),
};
};
Invite.generateSignPair = function () {
var ed = Crypto.AbstractCall.signKeyPair();
var ed = Crypto.CryptoAgility.signKeyPair();
var dsa = Crypto.PQC.ml_dsa.ml_dsa44.keygen();
return {
validateKey: encode64(ed.publicKey),
signKey: encode64(ed.secretKey),
dsaPublic: encode64(dsa.publicKey),
dsaPrivate: encode64(dsa.secretKey),
};
};
@ -32,7 +41,7 @@ var factory = function (Util, Cred, Nacl, Crypto) {
var dispense = Cred.dispenser(decode64(b64));
return {
channel: Util.uint8ArrayToHex(dispense(16)),
cryptKey: dispense(Crypto.AbstractCall.secretboxKeyLength()),
cryptKey: dispense(Crypto.CryptoAgility.secretboxKeyLength()),
};
};
@ -58,13 +67,13 @@ var factory = function (Util, Cred, Nacl, Crypto) {
var decodeUTF8 = Util.decodeUTF8;
Invite.encryptHash = function (data, seedStr) {
var array = decodeUTF8(seedStr);
var bytes = Crypto.AbstractCall.createHash(array);
var bytes = Crypto.CryptoAgility.createHash(array);
var cryptKey = bytes.subarray(0, 32);
return Crypto.encrypt(data, cryptKey);
};
Invite.decryptHash = function (encryptedStr, seedStr) {
var array = decodeUTF8(seedStr);
var bytes = Crypto.AbstractCall.createHash(array);
var bytes = Crypto.CryptoAgility.createHash(array);
var cryptKey = bytes.subarray(0, 32);
return Crypto.decrypt(encryptedStr, cryptKey);
};

View File

@ -12,6 +12,8 @@ const factory = (Crypto, Hash, Util, Constants, Realtime) => {
profile: proxy.profile && proxy.profile.view,
edPublic: proxy.edPublic,
curvePublic: proxy.curvePublic,
dsaPublic: proxy.dsaPublic,
kemPublic: proxy.kemPublic,
notifications: Util.find(proxy, ['mailboxes', 'notifications', 'channel']),
avatar: proxy.profile && proxy.profile.avatar,
badge: proxy.profile && proxy.profile.badge,

View File

@ -78,10 +78,12 @@ proxy.mailboxes = {
var getMyKeys = function (ctx) {
var proxy = ctx.store && ctx.store.proxy;
if (!proxy.curvePrivate || !proxy.curvePublic) { return; }
if (!proxy.curvePrivate || !proxy.curvePublic || !proxy.kemPublic || !proxy.kemPrivate) { return; }
return {
curvePrivate: proxy.curvePrivate,
curvePublic: proxy.curvePublic
curvePublic: proxy.curvePublic,
kemPrivate: proxy.kemPrivate,
kemPublic: proxy.kemPublic
};
};
@ -158,16 +160,42 @@ proxy.mailboxes = {
});
};
Mailbox.sendToAnon = function (anonRpc, type, msg, user, cb) {
var curveSeed = Crypto.AbstractCall.bytes(32);
var curvePair = Crypto.AbstractCall.boxKeyPairFromSecretKey(new Uint8Array(curveSeed));
var curveSeed = Crypto.CryptoAgility.bytes(32);
var curvePair = Crypto.CryptoAgility.boxKeyPairFromSecretKey(new Uint8Array(curveSeed));
var curvePrivate = Util.encodeBase64(curvePair.secretKey);
var curvePublic = Util.encodeBase64(curvePair.publicKey);
// Generate ephemeral PQC keys if PQC is available
var kemPrivate, kemPublic;
if (Crypto.PQC && Crypto.PQC.ml_kem && Crypto.PQC.ml_kem.ml_kem512) {
try {
var kemSeed = Crypto.CryptoAgility.bytes(64);
var kemPair = Crypto.PQC.ml_kem.ml_kem512.keygen(new Uint8Array(kemSeed));
kemPrivate = Util.encodeBase64(kemPair.secretKey);
kemPublic = Util.encodeBase64(kemPair.publicKey);
} catch (e) {
console.warn('Failed to generate ephemeral PQC keys:', e);
}
}
var proxyData = {
curvePrivate: curvePrivate,
curvePublic: curvePublic
};
if (kemPrivate && kemPublic) {
proxyData.kemPrivate = kemPrivate;
proxyData.kemPublic = kemPublic;
}
sendTo({
store: {
anon_rpc: anonRpc,
proxy: {
curvePrivate: curvePrivate,
curvePublic: curvePublic
curvePublic: curvePublic,
kemPrivate: kemPrivate,
kemPublic: kemPublic,
}
}
}, type, msg, user, cb);

View File

@ -301,7 +301,7 @@ const factory = (Util, Hash, Realtime, Pinpad, Crypt,
if (!curvePrivate) { return void cb('EFORBIDDEN'); }
let edPrivate, edPublic;
try {
let pair = Crypto.AbstractCall.signKeyPairFromSeed(Util.decodeBase64(curvePrivate));
let pair = Crypto.CryptoAgility.signKeyPairFromSeed(Util.decodeBase64(curvePrivate));
edPrivate = Util.encodeBase64(pair.secretKey);
edPublic = Util.encodeBase64(pair.publicKey);
} catch (e) {
@ -998,7 +998,7 @@ const factory = (Util, Hash, Realtime, Pinpad, Crypt,
let updateServerKey = (ctx, curvePublic, curvePrivate, cb) => {
let edPublic;
try {
let pair = Crypto.AbstractCall.signKeyPairFromSeed(Util.decodeBase64(curvePrivate));
let pair = Crypto.CryptoAgility.signKeyPairFromSeed(Util.decodeBase64(curvePrivate));
edPublic = Util.encodeBase64(pair.publicKey);
} catch (e) {
return void cb(e);
@ -1020,7 +1020,7 @@ const factory = (Util, Hash, Realtime, Pinpad, Crypt,
let proxy = ctx.store.proxy;
let edPublic = proxy.edPublic;
const keyPair = Crypto.AbstractCall.curveKeyPair();
const keyPair = Crypto.CryptoAgility.curveKeyPair();
const newKeyPub = Util.encodeBase64(keyPair.publicKey);
const newKey = Util.encodeBase64(keyPair.secretKey);

View File

@ -653,9 +653,9 @@ const factory = (Util, Hash, Constants, Realtime, ProxyManager,
var hash = Hash.createRandomHash('team', password);
var secret = Hash.getSecrets('team', hash, password);
var roHash = Hash.getViewHashFromKeys(secret);
var keyPair = Crypto.AbstractCall.signKeyPair(); // keyPair.secretKey , keyPair.publicKey
var keyPair = Crypto.CryptoAgility.signKeyPair(); // keyPair.secretKey , keyPair.publicKey
var curvePair = Crypto.AbstractCall.curveKeyPair(); // curvePair.secretKey, curvePair.publicKey
var curvePair = Crypto.CryptoAgility.curveKeyPair(); // curvePair.secretKey, curvePair.publicKey
var rosterSeed = Crypto.Team.createSeed();
var rosterKeys = Crypto.Team.deriveMemberKeys(rosterSeed, {
@ -1866,10 +1866,10 @@ const factory = (Util, Hash, Constants, Realtime, ProxyManager,
if (team.keys && team.keys.mailbox) { return team.keys.mailbox; }
var strSeed = Util.find(team, ['keys', 'roster', 'edit']);
if (!strSeed) { return; }
var hash = Crypto.AbstractCall.createHash(Util.decodeUTF8(strSeed));
var hash = Crypto.CryptoAgility.createHash(Util.decodeUTF8(strSeed));
var seed = hash.slice(0,32);
var mailboxChannel = Util.uint8ArrayToHex(hash.slice(32,48));
var curvePair = Crypto.AbstractCall.boxKeyPairFromSecretKey(seed);
var curvePair = Crypto.CryptoAgility.boxKeyPairFromSecretKey(seed);
return {
channel: mailboxChannel,
viewed: [],
@ -1918,7 +1918,7 @@ const factory = (Util, Hash, Constants, Realtime, ProxyManager,
if (!edPrivate || !edPublic) { return true; }
try {
var secretKey = Util.decodeBase64(edPrivate);
var pair = Crypto.AbstractCall.signKeyPairFromSecretKey(secretKey);
var pair = Crypto.CryptoAgility.signKeyPairFromSecretKey(secretKey);
return Util.encodeBase64(pair.publicKey) === edPublic;
} catch (e) {
return false;

View File

@ -2758,7 +2758,7 @@ define([
var msg = Util.decodeUTF8(Sortify(clone));
var sig = Util.decodeBase64(json.proof);
var pub = Util.decodeBase64(json.blockId);
return Crypto.AbstractCall.verifyDetached(msg, sig, pub);
return Crypto.CryptoAgility.verifyDetached(msg, sig, pub);
};
// Msg.admin_totpRecoveryHint.admin_totpRecoveryTitle

View File

@ -315,7 +315,7 @@ define([
}, "test that protocol relative URLs are rejected");
assert(function (cb) {
var keys = Block.genkeys(Crypto.AbstractCall.bytes(64));
var keys = Block.genkeys(Crypto.CryptoAgility.bytes(64));
var hash = Block.getBlockHash(keys);
var parsed = Block.parseBlockHash(hash);

View File

@ -221,7 +221,7 @@ Note: This must currently be reversed manually (by deleting the mfa config file)
var $b32Secret = $('#base32-secret');
var randomSecret = () => {
var U8 = Crypto.AbstractCall.bytes(20);
var U8 = Crypto.CryptoAgility.bytes(20);
return Base32.encode(U8);
};

View File

@ -54,7 +54,7 @@ define([
opt.kemPublic = undefined;
}
var curvePair = Crypto.AbstractCall.boxKeyPairFromSecretKey(new Uint8Array(curveSeed));
var curvePair = Crypto.CryptoAgility.boxKeyPairFromSecretKey(new Uint8Array(curveSeed));
opt.curvePrivate = Util.encodeBase64(curvePair.secretKey);
opt.curvePublic = Util.encodeBase64(curvePair.publicKey);
@ -69,7 +69,7 @@ define([
opt.blockHash = Block.getBlockHash(blockKeys);
// derive a private key from the ed seed
var signingKeypair = Crypto.AbstractCall.signKeyPairFromSeed(new Uint8Array(edSeed));
var signingKeypair = Crypto.CryptoAgility.signKeyPairFromSeed(new Uint8Array(edSeed));
opt.edPrivate = Util.encodeBase64(signingKeypair.secretKey);
opt.edPublic = Util.encodeBase64(signingKeypair.publicKey);
@ -232,7 +232,7 @@ define([
opt.userHash = blockInfo.User_hash;
} else {
console.log("allocating random bytes for a new user object");
opt = allocateBytes(Crypto.AbstractCall.bytes(Exports.requiredBytes));
opt = allocateBytes(Crypto.CryptoAgility.bytes(Exports.requiredBytes));
// create a random v2 hash, since we don't need backwards compatibility
opt.userHash = Hash.createRandomHash('drive');
var secret = Hash.getSecrets('drive', opt.userHash);

View File

@ -244,8 +244,8 @@ define([
// Make proof
var curve = answer.curvePrivate;
var mySecret = Util.decodeBase64(curve);
var nonce = Crypto.AbstractCall.bytes(24);
var proofBytes = Crypto.AbstractCall.box(h, nonce, theirs, mySecret);
var nonce = Crypto.CryptoAgility.bytes(24);
var proofBytes = Crypto.CryptoAgility.box(h, nonce, theirs, mySecret);
var proof = Util.encodeBase64(nonce) +'|'+ Util.encodeBase64(proofBytes);
var lineData = {
channel: data.channel,

View File

@ -9,12 +9,12 @@ var factory = function (Util, Nacl, Scrypt, Crypto) {
Invite.deriveSeeds = function (safeSeed) {
// take the hash of the provided seed
var seed = safeSeed.replace(/\-/g, '/');
var u8_seed = Crypto.AbstractCall.createHash(Util.decodeBase64(seed));
var u8_seed = Crypto.CryptoAgility.createHash(Util.decodeBase64(seed));
// hash the first half again for scrypt's input
var subseed1 = Crypto.AbstractCall.createHash(u8_seed.subarray(0, 32));
var subseed1 = Crypto.CryptoAgility.createHash(u8_seed.subarray(0, 32));
// hash the remainder for the invite content
var subseed2 = Crypto.AbstractCall.createHash(u8_seed.subarray(32));
var subseed2 = Crypto.CryptoAgility.createHash(u8_seed.subarray(32));
return {
scrypt: Util.encodeBase64(subseed1),

View File

@ -212,7 +212,7 @@ define([
}).nThen(function (waitFor) {
$content.empty();
var next = waitFor();
recoverySecret = Util.encodeBase64(Crypto.AbstractCall.bytes(24));
recoverySecret = Util.encodeBase64(Crypto.CryptoAgility.bytes(24));
var button = h('button.btn.btn-primary', [
h('i.fa.fa-check'),
h('span', Messages.done)
@ -241,7 +241,7 @@ define([
});
}).nThen(function () {
var randomSecret = function () {
var U8 = Crypto.AbstractCall.bytes(20);
var U8 = Crypto.CryptoAgility.bytes(20);
return Base32.encode(U8);
};
$content.empty();

View File

@ -456,7 +456,7 @@ var factory = function (Util, Crypto) {
var metadataLength = Decrypt.decodePrefix(prefix);
var metaBox = new Uint8Array(u8.subarray(2, 2 + metadataLength));
var metaChunk = Crypto.AbstractCall.secretboxOpen(metaBox, Decrypt.createNonce(), key);
var metaChunk = Crypto.CryptoAgility.secretboxOpen(metaBox, Decrypt.createNonce(), key);
try {
return JSON.parse(Util.encodeUTF8(metaChunk));
@ -494,7 +494,7 @@ var factory = function (Util, Crypto) {
// Get metadata
var metaBox = new Uint8Array(u8.subarray(2, 2 + metadataLength));
var metaChunk = Crypto.AbstractCall.secretboxOpen(metaBox, nonce, key);
var metaChunk = Crypto.CryptoAgility.secretboxOpen(metaBox, nonce, key);
Decrypt.increment(nonce);
@ -513,7 +513,7 @@ var factory = function (Util, Crypto) {
var box = new Uint8Array(u8.subarray(start, end));
// Decrypt the chunk
var plaintext = Crypto.AbstractCall.secretboxOpen(box, nonce, key);
var plaintext = Crypto.CryptoAgility.secretboxOpen(box, nonce, key);
Decrypt.increment(nonce);
if (!plaintext) { return void cb('DECRYPTION_FAILURE'); }

View File

@ -2496,7 +2496,7 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
}
try {
debug("Decrypt with key " + data.key);
FileCrypto.decrypt(u8, Crypto.AbstractCall.decodeBase64(data.key), function (err, res) {
FileCrypto.decrypt(u8, Crypto.CryptoAgility.decodeBase64(data.key), function (err, res) {
APP.loadingImage--;
if (err || !res.content) {
debug("Decrypting failed");

File diff suppressed because one or more lines are too long

View File

@ -92,7 +92,7 @@ define([
var metaBox = new Uint8Array(u8.subarray(2, 2 + metadataLength));
var metaChunk = Crypto.AbstractCall.secretboxOpen(metaBox, nonce, key);
var metaChunk = Crypto.CryptoAgility.secretboxOpen(metaBox, nonce, key);
increment(nonce);
try {
@ -117,7 +117,7 @@ define([
var box = new Uint8Array(u8.subarray(start, end));
// decrypt the chunk
var plaintext = Crypto.AbstractCall.secretboxOpen(box, nonce, key);
var plaintext = Crypto.CryptoAgility.secretboxOpen(box, nonce, key);
increment(nonce);
if (!plaintext) { return cb('DECRYPTION_ERROR'); }
@ -185,7 +185,7 @@ define([
if (state === 0) { // metadata...
part = new Uint8Array(plaintext);
box = Crypto.AbstractCall.secretbox(part, nonce, key);
box = Crypto.CryptoAgility.secretbox(part, nonce, key);
increment(nonce);
if (box.length > 65535) {
@ -205,7 +205,7 @@ define([
end = start + plainChunkLength;
part = u8.subarray(start, end);
box = Crypto.AbstractCall.secretbox(part, nonce, key);
box = Crypto.CryptoAgility.secretbox(part, nonce, key);
increment(nonce);
i++;

View File

@ -34,8 +34,8 @@ define([
};
var anonProof = function (channel, theirPub, anonKeys) {
var u8_plain = Util.decodeUTF8(channel);
var u8_nonce = Crypto.AbstractCall.bytes(Crypto.AbstractCall.boxNonceLength());
var u8_cipher = Crypto.AbstractCall.box(
var u8_nonce = Crypto.CryptoAgility.bytes(Crypto.CryptoAgility.boxNonceLength());
var u8_cipher = Crypto.CryptoAgility.box(
u8_plain,
u8_nonce,
Util.decodeBase64(theirPub),
@ -144,9 +144,9 @@ define([
var proofTxt = proofObj.proof;
try {
var u8_bundle = Util.decodeBase64(proofTxt);
var u8_nonce = u8_slice(u8_bundle, 0, Crypto.AbstractCall.boxNonceLength());
var u8_cipher = u8_slice(u8_bundle, Crypto.AbstractCall.boxNonceLength());
var u8_plain = Crypto.AbstractCall.boxOpen(
var u8_nonce = u8_slice(u8_bundle, 0, Crypto.CryptoAgility.boxNonceLength());
var u8_cipher = u8_slice(u8_bundle, Crypto.CryptoAgility.boxNonceLength());
var u8_plain = Crypto.CryptoAgility.boxOpen(
u8_cipher,
u8_nonce,
Util.decodeBase64(pub),
@ -328,7 +328,7 @@ define([
var keys = Utils.secret && Utils.secret.keys;
myKeys.signingKey = keys.secondarySignKey;
var ephemeral_keypair = Crypto.AbstractCall.curveKeyPair();
var ephemeral_keypair = Crypto.CryptoAgility.curveKeyPair();
var ephemeral_private = Util.encodeBase64(ephemeral_keypair.secretKey);
myKeys.ephemeral_keypair = ephemeral_keypair;

View File

@ -79,7 +79,7 @@ define([
date: new Date().toISOString(),
blockId: Util.encodeBase64(pub),
};
var proof = Crypto.AbstractCall.signDetached(Util.decodeUTF8(Sortify(toSign)), sec);
var proof = Crypto.CryptoAgility.signDetached(Util.decodeUTF8(Sortify(toSign)), sec);
toSign.proof = Util.encodeBase64(proof);
proofStr = JSON.stringify(toSign, 0, 2);
$mfaProof.html(proofStr);