diff --git a/www/js/services/crypto-services.js b/www/js/services/crypto-services.js index f9119d841e8a45f658c6ddb03799003058d47594..d5eda53c382c36ea84729ac6eaade093aacde464 100644 --- a/www/js/services/crypto-services.js +++ b/www/js/services/crypto-services.js @@ -509,6 +509,18 @@ angular.module('cesium.crypto.services', ['ngResource', 'cesium.device.services' return deferred.promise; }; + /** + * Compute the box secret key, from a sign secret key + */ + this.box_sk_from_sign = function(signSk) { + var deferred = $q.defer(); + that.nacl.crypto_sign_ed25519_sk_to_curve25519(signSk, function(err, boxSk) { + if (err) { deferred.reject(err); return;} + deferred.resolve(boxSk); + }); + return deferred.promise; + }; + /** * Encrypt a message, from a key pair */ @@ -596,6 +608,7 @@ angular.module('cesium.crypto.services', ['ngResource', 'cesium.device.services' this.box = { keypair: { fromSignKeypair: that.box_keypair_from_sign, + skFromSignSk: that.box_sk_from_sign, pkFromSignPk: that.box_pk_from_sign }, pack: that.box,