From 646d8e7341d15216e8a744f9ae8536c80db09200 Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 17 Jul 2019 14:50:22 +0200 Subject: [PATCH] add some comments to common-hash for new APIs --- www/common/common-hash.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/www/common/common-hash.js b/www/common/common-hash.js index 3f613ae4f..e49b0e217 100644 --- a/www/common/common-hash.js +++ b/www/common/common-hash.js @@ -85,16 +85,27 @@ define([ return id; }; + /* Given a base64-encoded public key, deterministically derive a channel id + Used for support mailboxes + */ Hash.getChannelIdFromKey = function (publicKey) { if (!publicKey) { return; } return uint8ArrayToHex(Hash.decodeBase64(publicKey).subarray(0,16)); }; + + /* Given a base64-encoded asymmetric private key + derive the corresponding public key + */ Hash.getBoxPublicFromSecret = function (priv) { if (!priv) { return; } var u8_priv = Hash.decodeBase64(priv); var pair = Nacl.box.keyPair.fromSecretKey(u8_priv); return Hash.encodeBase64(pair.publicKey); }; + + /* Given a base64-encoded private key and public key + check that the keys are part of a valid keypair + */ Hash.checkBoxKeyPair = function (priv, pub) { if (!pub || !priv) { return false; } var u8_priv = Hash.decodeBase64(priv);