|
|
@ -1,13 +1,10 @@
|
|
|
|
define([
|
|
|
|
define([
|
|
|
|
|
|
|
|
'/common/common-util.js',
|
|
|
|
'/bower_components/tweetnacl/nacl-fast.min.js',
|
|
|
|
'/bower_components/tweetnacl/nacl-fast.min.js',
|
|
|
|
], function () {
|
|
|
|
], function (Util) {
|
|
|
|
var Nacl = window.nacl;
|
|
|
|
var Nacl = window.nacl;
|
|
|
|
|
|
|
|
|
|
|
|
var uid = function () {
|
|
|
|
var uid = Util.uid;
|
|
|
|
return Number(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER))
|
|
|
|
|
|
|
|
.toString(32).replace(/\./g, '');
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var signMsg = function (data, signKey) {
|
|
|
|
var signMsg = function (data, signKey) {
|
|
|
|
var buffer = Nacl.util.decodeUTF8(JSON.stringify(data));
|
|
|
|
var buffer = Nacl.util.decodeUTF8(JSON.stringify(data));
|
|
|
|
return Nacl.util.encodeBase64(Nacl.sign.detached(buffer, signKey));
|
|
|
|
return Nacl.util.encodeBase64(Nacl.sign.detached(buffer, signKey));
|
|
|
|