diff --git a/app/common/index.js b/app/common/index.js
index 1606e444639a591150e6902164192b7a705cc743..2a9483b86c60969e031f9a9802310eb4644438e9 100644
--- a/app/common/index.js
+++ b/app/common/index.js
@@ -1,14 +1,8 @@
 "use strict";
 
 module.exports = {
-  hashf: require('./lib/hashf'),
-  dos2unix: require('./lib/dos2unix'),
-  keyring: require('./lib/crypto/keyring'),
-  base58: require('./lib/crypto/base58'),
-  rawer: require('./lib/rawer'),
   buid: require('./lib/buid'),
   document: require('./lib/document'),
   constants: require('./lib/constants'),
-  txunlock: require('./lib/txunlock'),
   parsers: require('./lib/parsers')
 }
diff --git a/app/common/lib/buid.js b/app/common/lib/buid.js
index 55d12bb479f8e0724f5cd25a908735367560a51d..a08fb70e4193fcf4dacb51cd4c020d733bfe7582 100644
--- a/app/common/lib/buid.js
+++ b/app/common/lib/buid.js
@@ -1,6 +1,4 @@
 "use strict";
-const hashf = require('./hashf');
-
 const BLOCK_UID = /^(0|[1-9]\d{0,18})-[A-F0-9]{64}$/;
 
 const buidFunctions = function(number, hash) {
@@ -20,7 +18,7 @@ module.exports = {
 
   format: {
 
-    hashf: (value) => hashf(String(value)).toUpperCase(),
+    hashf: (value) => require('../../lib/common-libs').hashf(String(value)),
 
     isBuid: (value) => {
       return (typeof value === 'string') && value.match(BLOCK_UID) ? true : false;
diff --git a/app/common/lib/crypto/base58.js b/app/common/lib/crypto/base58.js
deleted file mode 100644
index db14015cb7535f043fd0f0c06f8c146a48d8c621..0000000000000000000000000000000000000000
--- a/app/common/lib/crypto/base58.js
+++ /dev/null
@@ -1,9 +0,0 @@
-"use strict"
-
-const assert = require('assert')
-const bs58 = require('bs58')
-
-module.exports = {
-  encode: (bytes) => bs58.encode(bytes),
-  decode: (data) => new Uint8Array(bs58.decode(data))
-};
diff --git a/app/common/lib/crypto/keyring.js b/app/common/lib/crypto/keyring.js
deleted file mode 100644
index ca74b84507cb02c445dae3370476f2a4500e2fd7..0000000000000000000000000000000000000000
--- a/app/common/lib/crypto/keyring.js
+++ /dev/null
@@ -1,75 +0,0 @@
-"use strict";
-const nacl        = require('tweetnacl');
-const base58      = require('./base58');
-const seedrandom  = require('seedrandom');
-const naclBinding = require('naclb');
-
-nacl.util = require('./nacl-util');
-
-const crypto_sign_BYTES = 64;
-
-/**
- * Verify a signature against data & public key.
- * Return true of false as callback argument.
- */
-function verify(rawMsg, rawSig, rawPub) {
-  const msg = nacl.util.decodeUTF8(rawMsg);
-  const sig = nacl.util.decodeBase64(rawSig);
-  const pub = base58.decode(rawPub);
-  const m = new Uint8Array(crypto_sign_BYTES + msg.length);
-  const sm = new Uint8Array(crypto_sign_BYTES + msg.length);
-  let i;
-  for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];
-  for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];
-
-  // Call to verification lib...
-  return naclBinding.verify(m, sm, pub);
-}
-
-function Key(pub, sec) {
-  /*****************************
-  *
-  *      GENERAL CRYPTO
-  *
-  *****************************/
-
-  this.publicKey = pub;
-  this.secretKey = sec;
-
-  const rawSec = () => base58.decode(this.secretKey);
-
-  this.json = () => { return {
-    pub: this.publicKey,
-    sec: this.secretKey
-  }};
-
-  this.sign = (msg) => Promise.resolve(this.signSync(msg));
-
-  this.signSync = (msg) => {
-    const m = nacl.util.decodeUTF8(msg);
-    const signedMsg = naclBinding.sign(m, rawSec());
-    const sig = new Uint8Array(crypto_sign_BYTES);
-    for (let i = 0; i < sig.length; i++) {
-      sig[i] = signedMsg[i];
-    }
-    return nacl.util.encodeBase64(sig);
-  };
-}
-
-function randomKey() {
-  const byteseed = new Uint8Array(32)
-  for (let i = 0; i < 32; i++) {
-    byteseed[i] = Math.floor(seedrandom()() *  255) + 1
-  }
-  const keypair = nacl.sign.keyPair.fromSeed(byteseed)
-  return new Key(
-    base58.encode(keypair.publicKey),
-    base58.encode(keypair.secretKey)
-  )
-}
-
-module.exports ={
-  randomKey,
-  Key: (pub, sec) => new Key(pub, sec),
-  verify: verify
-};
diff --git a/app/common/lib/crypto/nacl-util.js b/app/common/lib/crypto/nacl-util.js
deleted file mode 100644
index 05cebc0f408ea69106c6a1f7994976c353f936a7..0000000000000000000000000000000000000000
--- a/app/common/lib/crypto/nacl-util.js
+++ /dev/null
@@ -1,50 +0,0 @@
-// Written in 2014-2016 by Dmitry Chestnykh and Devi Mandiri.
-// Public domain.
-(function(root, f) {
-  'use strict';
-  if (typeof module !== 'undefined' && module.exports) module.exports = f();
-  else if (root.nacl) root.nacl.util = f();
-  else {
-    root.nacl = {};
-    root.nacl.util = f();
-  }
-}(this, function() {
-  'use strict';
-
-  let util = {};
-
-  util.decodeUTF8 = function(s) {
-    let i, d = unescape(encodeURIComponent(s)), b = new Uint8Array(d.length);
-    for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
-    return b;
-  };
-
-  util.encodeUTF8 = function(arr) {
-    let i, s = [];
-    for (i = 0; i < arr.length; i++) s.push(String.fromCharCode(arr[i]));
-    return decodeURIComponent(escape(s.join('')));
-  };
-
-  util.encodeBase64 = function(arr) {
-    if (typeof btoa === 'undefined' || !window) {
-      return (new Buffer(arr)).toString('base64');
-    } else {
-      let i, s = [], len = arr.length;
-      for (i = 0; i < len; i++) s.push(String.fromCharCode(arr[i]));
-      return btoa(s.join(''));
-    }
-  };
-
-  util.decodeBase64 = function(s) {
-    if (typeof atob === 'undefined' || !window) {
-      return new Uint8Array(Array.prototype.slice.call(new Buffer(s, 'base64'), 0));
-    } else {
-      let i, d = atob(s), b = new Uint8Array(d.length);
-      for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
-      return b;
-    }
-  };
-
-  return util;
-
-}));
diff --git a/app/common/lib/document/block.js b/app/common/lib/document/block.js
index c0c3f9eea0a9b95280a86a630a2dc1d554c6be94..0abe95475b1fbc5aee1c1ffb119ad20aaf6499e9 100644
--- a/app/common/lib/document/block.js
+++ b/app/common/lib/document/block.js
@@ -2,7 +2,6 @@
 const _ = require('underscore')
 const constants = require('../constants');
 const regex = require('../regex');
-const hashf = require('../hashf');
 const Transaction = require('./transaction');
 
 // Constants
@@ -151,6 +150,7 @@ module.exports = class Block {
 
   static getHash(json) {
     const raw = Block.toRAWHashAndNonce(json)
+    const hashf = require('../../../lib/common-libs').hashf
     return hashf(raw).toUpperCase()
   }
 
diff --git a/app/common/lib/document/certification.js b/app/common/lib/document/certification.js
index 3cc70e69efab9c9051b410a7dfbfe2e065d41d1d..490d2ede414e8e0aae9a468c5a9197a66fd1f859 100644
--- a/app/common/lib/document/certification.js
+++ b/app/common/lib/document/certification.js
@@ -1,7 +1,6 @@
 "use strict";
 const constants = require('../constants');
 const regex = require('../regex');
-const hashf = require('../hashf');
 
 // Constants
 const SIGNED = true
diff --git a/app/common/lib/document/identity.js b/app/common/lib/document/identity.js
index 2792fe73e204d23dab8ef75fea8a82fd7355628d..23c5c93f8fbd06c9b4d2591b994e047b20b99f32 100644
--- a/app/common/lib/document/identity.js
+++ b/app/common/lib/document/identity.js
@@ -1,7 +1,6 @@
 "use strict";
 const constants = require('../constants');
 const regex = require('../regex');
-const hashf = require('../hashf');
 
 // Constants
 const SIGNED = true
@@ -74,6 +73,7 @@ module.exports = class Identity {
    */
 
   getTargetHash() {
+    const hashf = require('../../../lib/common-libs').hashf
     return hashf(this.uid + this.buid + this.pubkey).toUpperCase();
   }
 
diff --git a/app/common/lib/document/transaction.js b/app/common/lib/document/transaction.js
index aad1e08c72ed7c681c39def0785bd2d9e7cc98e5..f19dbd629b4abe544d613362ce78e3a3f1526798 100644
--- a/app/common/lib/document/transaction.js
+++ b/app/common/lib/document/transaction.js
@@ -1,7 +1,7 @@
 "use strict";
 const constants = require('../constants');
 const regex = require('../regex');
-const hashf = require('../hashf');
+const hashf = require('../../../lib/common-libs').hashf
 
 // Constants
 const SIGNED = false
diff --git a/app/common/lib/dos2unix.js b/app/common/lib/dos2unix.js
deleted file mode 100644
index 32fdce59314af70c76489f3140ba64bf76fd916b..0000000000000000000000000000000000000000
--- a/app/common/lib/dos2unix.js
+++ /dev/null
@@ -1,23 +0,0 @@
-"use strict";
-const util     = require('util');
-const stream   = require('stream');
-
-module.exports = function (str) {
-  if (str)
-    return dos2unix(str);
-  else
-    return new Dos2UnixStream();
-};
-
-const dos2unix = (str) => str.replace(/\r\n/g, '\n');
-
-function Dos2UnixStream () {
-  stream.Transform.apply(this);
-
-  this._write = function (str, enc, done) {
-    this.push(dos2unix(str.toString()));
-    done();
-  }
-}
-
-util.inherits(Dos2UnixStream, stream.Transform);
diff --git a/app/common/lib/hashf.js b/app/common/lib/hashf.js
deleted file mode 100644
index f1a1bd2ee50e8f580c866ca2b602c74d796621bc..0000000000000000000000000000000000000000
--- a/app/common/lib/hashf.js
+++ /dev/null
@@ -1,8 +0,0 @@
-"use strict";
-
-module.exports = function (str){
-  return require("crypto")
-    .createHash("sha256")
-    .update(str)
-    .digest("hex");
-};
diff --git a/app/common/lib/parsers/GenericParser.js b/app/common/lib/parsers/GenericParser.js
index a1424acee8cc9718b84732cda43dec823f23fa4b..255c47aba4342c9586c4c8cb029b53001a806c47 100644
--- a/app/common/lib/parsers/GenericParser.js
+++ b/app/common/lib/parsers/GenericParser.js
@@ -1,7 +1,7 @@
 "use strict";
 const util                 = require('util');
 const stream               = require('stream');
-const hashf                = require('../hashf');
+const hashf                = require('../../../lib/common-libs').hashf
 const constants            = require('../constants');
 
 module.exports = GenericParser;
diff --git a/app/common/lib/parsers/block.js b/app/common/lib/parsers/block.js
index 31118f50fd042de68d3734a16fefa9bc4634cc1e..6bf04985b93155e28d80bfbdd974ab63f444aaaa 100644
--- a/app/common/lib/parsers/block.js
+++ b/app/common/lib/parsers/block.js
@@ -2,8 +2,8 @@
 const util          = require('util');
 const GenericParser = require('./GenericParser');
 const Block         = require('../../../../app/common/lib/document/block');
-const hashf         = require('../../../../app/common/lib/hashf');
-const rawer         = require('../../../../app/common/lib/rawer');
+const hashf         = require('../../../../app/lib/common-libs').hashf
+const rawer         = require('../../../../app/lib/common-libs').rawer
 const constants     = require('../../../../app/common/lib/constants');
 
 module.exports = BlockParser;
diff --git a/app/common/lib/parsers/certification.js b/app/common/lib/parsers/certification.js
index 11d0321f5acc7646544b6fe3909ff6df80614464..554eb22c873bbbe23b544b0820228acf6d7e195a 100644
--- a/app/common/lib/parsers/certification.js
+++ b/app/common/lib/parsers/certification.js
@@ -1,7 +1,7 @@
 "use strict";
 const GenericParser = require('./GenericParser');
 const util          = require('util');
-const rawer         = require('../../../../app/common/lib/rawer');
+const rawer         = require('../../../../app/lib/common-libs').rawer
 const constants     = require('../../../../app/common/lib/constants');
 
 module.exports = CertificationParser;
diff --git a/app/common/lib/parsers/identity.js b/app/common/lib/parsers/identity.js
index 4f0c41ff669819c694bb0a3f35c7ae4c490fc60e..1cde03e90bb4a9844c61fb564daf66d9af3ea75b 100644
--- a/app/common/lib/parsers/identity.js
+++ b/app/common/lib/parsers/identity.js
@@ -1,8 +1,8 @@
 "use strict";
 const GenericParser = require('./GenericParser');
 const util          = require('util');
-const rawer         = require('../../../../app/common/lib/rawer');
-const hashf         = require('../../../../app/common/lib/hashf');
+const rawer         = require('../../../../app/lib/common-libs').rawer
+const hashf         = require('../../../../app/lib/common-libs').hashf
 const constants     = require('../../../../app/common/lib/constants');
 
 module.exports = IdentityParser;
diff --git a/app/common/lib/parsers/membership.js b/app/common/lib/parsers/membership.js
index 2435ae5267b444d0baa8a537ab20464229c3bb66..6cad686530b5ed3b98b85253999530b32a899191 100644
--- a/app/common/lib/parsers/membership.js
+++ b/app/common/lib/parsers/membership.js
@@ -1,7 +1,7 @@
 "use strict";
 const GenericParser = require('./GenericParser');
 const ucp           = require('../buid');
-const rawer         = require('../rawer');
+const rawer         = require('../../../lib/common-libs/index').rawer
 const util          = require('util');
 const constants     = require('../constants');
 
diff --git a/app/common/lib/parsers/peer.js b/app/common/lib/parsers/peer.js
index 122f6ee34a6b13747d32fcb81abe284c58b97ee0..9d106084dc9d0e3eae9d266647add3802a19fbe1 100644
--- a/app/common/lib/parsers/peer.js
+++ b/app/common/lib/parsers/peer.js
@@ -1,6 +1,6 @@
 "use strict";
 const GenericParser = require('./GenericParser');
-const rawer         = require('../rawer');
+const rawer         = require('../../../lib/common-libs/index').rawer
 const util          = require('util');
 const constants     = require('../constants');
 
diff --git a/app/common/lib/parsers/revocation.js b/app/common/lib/parsers/revocation.js
index f86528bdeed6e0cf556b4351e8e5764458808807..1713f7407a74721788433735f32182197de887b5 100644
--- a/app/common/lib/parsers/revocation.js
+++ b/app/common/lib/parsers/revocation.js
@@ -1,8 +1,8 @@
 "use strict";
 const GenericParser = require('./GenericParser');
 const util          = require('util');
-const rawer         = require('../rawer');
-const hashf         = require('../hashf');
+const rawer         = require('../../../lib/common-libs').rawer
+const hashf         = require('../../../lib/common-libs').hashf
 const constants     = require('../constants');
 
 module.exports = RevocationParser;
diff --git a/app/common/lib/parsers/transaction.js b/app/common/lib/parsers/transaction.js
index 727607e1902d11d3be32f450a4e2a9acca77b08c..7b552a19c79c163670f23c15a6f896866b8dfe09 100644
--- a/app/common/lib/parsers/transaction.js
+++ b/app/common/lib/parsers/transaction.js
@@ -1,6 +1,6 @@
 "use strict";
 const GenericParser = require('./GenericParser');
-const rawer         = require('../rawer');
+const rawer         = require('../../../lib/common-libs/index').rawer
 const constants     = require('../constants');
 const util          = require('util');
 
diff --git a/app/common/lib/rawer.js b/app/common/lib/rawer.js
deleted file mode 100644
index a99aa2a1173bf97af10d811103a23a0a2a8cb05e..0000000000000000000000000000000000000000
--- a/app/common/lib/rawer.js
+++ /dev/null
@@ -1,92 +0,0 @@
-"use strict";
-const dos2unix = require('./dos2unix');
-const document = require('./document');
-
-const DOCUMENTS_VERSION = 10;
-const SIGNED = false
-const UNSIGNED = true
-
-module.exports = new function() {
-
-  this.getOfficialIdentity = (json, withSig) => {
-    return document.Identity.toRAW(json, withSig !== false) // Defaut with sig
-  };
-
-  this.getOfficialCertification = (json) => {
-    let raw = getNormalHeader('Certification', json);
-    raw += "IdtyIssuer: " + json.idty_issuer + '\n';
-    raw += "IdtyUniqueID: " + json.idty_uid + '\n';
-    raw += "IdtyTimestamp: " + json.idty_buid + '\n';
-    raw += "IdtySignature: " + json.idty_sig + '\n';
-    raw += "CertTimestamp: " + json.buid + '\n';
-    if (json.sig) {
-      raw += json.sig + '\n';
-    }
-    return dos2unix(raw);
-  };
-
-  this.getOfficialRevocation = (json) => {
-    let raw = getNormalHeader('Revocation', json);
-    raw += "IdtyUniqueID: " + json.uid + '\n';
-    raw += "IdtyTimestamp: " + json.buid + '\n';
-    raw += "IdtySignature: " + json.sig + '\n';
-    if (json.revocation) {
-      raw += json.revocation + '\n';
-    }
-    return dos2unix(raw);
-  };
-
-  this.getPeerWithoutSignature = (json) => document.Peer.fromJSON(json).getRawUnsigned()
-
-  this.getPeer = (json) => document.Peer.fromJSON(json).getRaw()
-
-  this.getMembershipWithoutSignature = (json) => {
-    return document.Membership.toRAW(json)
-  };
-
-  this.getMembership = (json) => {
-    return dos2unix(signed(this.getMembershipWithoutSignature(json), json));
-  };
-
-  this.getBlockInnerPart = (json) => {
-    return document.Block.toRAWInnerPart(json)
-  };
-
-  this.getBlockWithInnerHashAndNonce = (json) => {
-    return document.Block.toRAWinnerPartWithHashAndNonce(json)
-  };
-
-  this.getBlockInnerHashAndNonce = (json) => {
-    return document.Block.toRAWHashAndNonce(json, UNSIGNED)
-  };
-
-  this.getBlockInnerHashAndNonceWithSignature = (json) => {
-    return document.Block.toRAWHashAndNonce(json, SIGNED)
-  };
-
-  this.getBlock = (json) => {
-    return dos2unix(signed(this.getBlockWithInnerHashAndNonce(json), json));
-  };
-
-  this.getTransaction = (json) => {
-    return document.Transaction.toRAW(json)
-  };
-
-  this.getCompactTransaction = (json) => {
-    return document.Transaction.getCompactTransaction(json)
-  };
-
-  let getNormalHeader = (doctype, json) => {
-    let raw = "";
-    raw += "Version: " + (json.version || DOCUMENTS_VERSION) + "\n";
-    raw += "Type: " + doctype + "\n";
-    raw += "Currency: " + json.currency + "\n";
-    raw += "Issuer: " + json.issuer + "\n";
-    return raw;
-  };
-
-  let signed = (raw, json) => {
-    raw += json.signature + '\n';
-    return raw;
-  };
-};
diff --git a/app/lib/common-libs/dos2unix.ts b/app/lib/common-libs/dos2unix.ts
new file mode 100644
index 0000000000000000000000000000000000000000..cf7ee5ebc996fa6212e5ab5fafe26cca0488c9a6
--- /dev/null
+++ b/app/lib/common-libs/dos2unix.ts
@@ -0,0 +1,3 @@
+export function dos2unix(str:string) {
+  return str.replace(/\r\n/g, '\n')
+}
diff --git a/app/lib/common-libs/index.ts b/app/lib/common-libs/index.ts
new file mode 100644
index 0000000000000000000000000000000000000000..5ff95cdec843ec64925ce75561b2f03083a56747
--- /dev/null
+++ b/app/lib/common-libs/index.ts
@@ -0,0 +1,16 @@
+import * as rawer from './rawer'
+import {Base58decode, Base58encode} from "./crypto/base58"
+import {unlock as txunlock} from "./txunlock"
+import {hashf} from "../common";
+
+const base58 = {
+  decode: Base58decode,
+  encode: Base58encode
+}
+
+export {
+  rawer,
+  base58,
+  txunlock,
+  hashf
+}
diff --git a/app/lib/common-libs/rawer.ts b/app/lib/common-libs/rawer.ts
new file mode 100644
index 0000000000000000000000000000000000000000..6aea2554baf681b02cb8e11aba4d7be40b9def85
--- /dev/null
+++ b/app/lib/common-libs/rawer.ts
@@ -0,0 +1,95 @@
+import {dos2unix} from "./dos2unix"
+
+const DOCUMENTS_VERSION = 10;
+const SIGNED = false
+const UNSIGNED = true
+
+function document() {
+  return require('../../common/lib/document')
+}
+
+export const getOfficialIdentity = (json:any, withSig = true) => {
+  return document().Identity.toRAW(json, withSig !== false) // Defaut with sig
+}
+
+export const getOfficialCertification = (json:any) => {
+  let raw = getNormalHeader('Certification', json);
+  raw += "IdtyIssuer: " + json.idty_issuer + '\n';
+  raw += "IdtyUniqueID: " + json.idty_uid + '\n';
+  raw += "IdtyTimestamp: " + json.idty_buid + '\n';
+  raw += "IdtySignature: " + json.idty_sig + '\n';
+  raw += "CertTimestamp: " + json.buid + '\n';
+  if (json.sig) {
+    raw += json.sig + '\n';
+  }
+  return dos2unix(raw);
+}
+
+export const getOfficialRevocation = (json:any) => {
+  let raw = getNormalHeader('Revocation', json);
+  raw += "IdtyUniqueID: " + json.uid + '\n';
+  raw += "IdtyTimestamp: " + json.buid + '\n';
+  raw += "IdtySignature: " + json.sig + '\n';
+  if (json.revocation) {
+    raw += json.revocation + '\n';
+  }
+  return dos2unix(raw);
+}
+
+export const getPeerWithoutSignature = (json:any) => {
+  return document().Peer.fromJSON(json).getRawUnsigned()
+}
+
+export const getPeer = (json:any) => {
+  return document().Peer.fromJSON(json).getRaw()
+}
+
+export const getMembershipWithoutSignature = (json:any) => {
+  return document().Membership.toRAW(json)
+}
+
+export const getMembership = (json:any) => {
+  return dos2unix(signed(getMembershipWithoutSignature(json), json));
+}
+
+export const getBlockInnerPart = (json:any) => {
+  return document().Block.toRAWInnerPart(json)
+}
+
+export const getBlockWithInnerHashAndNonce = (json:any) => {
+  return document().Block.toRAWinnerPartWithHashAndNonce(json)
+}
+
+export const getBlockInnerHashAndNonce = (json:any) => {
+  return document().Block.toRAWHashAndNonce(json, UNSIGNED)
+}
+
+export const getBlockInnerHashAndNonceWithSignature = (json:any) => {
+  return document().Block.toRAWHashAndNonce(json, SIGNED)
+}
+
+export const getBlock = (json:any) => {
+  return dos2unix(signed(getBlockWithInnerHashAndNonce(json), json));
+}
+
+export const getTransaction = (json:any) => {
+  return document().Transaction.toRAW(json)
+}
+
+export const getCompactTransaction = (json:any) => {
+  return document().Transaction.getCompactTransaction(json)
+}
+
+function getNormalHeader(doctype:string, json:any) {
+  let raw = "";
+  raw += "Version: " + (json.version || DOCUMENTS_VERSION) + "\n";
+  raw += "Type: " + doctype + "\n";
+  raw += "Currency: " + json.currency + "\n";
+  raw += "Issuer: " + json.issuer + "\n";
+  return raw;
+}
+
+function signed(raw:string, json:any) {
+  raw += json.signature + '\n';
+  return raw;
+}
diff --git a/app/common/lib/txunlock.js b/app/lib/common-libs/txunlock.ts
similarity index 86%
rename from app/common/lib/txunlock.js
rename to app/lib/common-libs/txunlock.ts
index e423355f05f8b154887bc67e4fa4081d04bd800e..a136cfd30406fe096c6a662b18f84b8ee086edc5 100644
--- a/app/common/lib/txunlock.js
+++ b/app/lib/common-libs/txunlock.ts
@@ -1,7 +1,7 @@
 "use strict";
 
 let Parser = require("jison").Parser;
-let buid = require('./buid');
+let buid = require('../../../app/common/lib/buid')
 
 let grammar = {
   "lex": {
@@ -43,24 +43,24 @@ let grammar = {
   }
 };
 
-module.exports = function unlock(conditionsStr, executions, metadata) {
+export function unlock(conditionsStr:string, executions:any, metadata:any) {
 
   let parser = new Parser(grammar);
 
   parser.yy = {
     i: 0,
-    sig: function (pubkey) {
+    sig: function (pubkey:string) {
       let sigParam = executions[this.i++];
       return (sigParam && pubkey === sigParam.pubkey && sigParam.sigOK) || false;
     },
-    xHx: function(hash) {
+    xHx: function(hash:string) {
       let xhxParam = executions[this.i++];
       return buid.format.hashf(xhxParam) === hash;
     },
-    cltv: function(deadline) {
+    cltv: function(deadline:string) {
       return metadata.currentTime && metadata.currentTime >= parseInt(deadline);
     },
-    csv: function(amountToWait) {
+    csv: function(amountToWait:string) {
       return metadata.elapsedTime && metadata.elapsedTime >= parseInt(amountToWait);
     }
   };
@@ -70,4 +70,4 @@ module.exports = function unlock(conditionsStr, executions, metadata) {
   } catch(e) {
     return false;
   }
-};
+}
\ No newline at end of file
diff --git a/app/lib/common.ts b/app/lib/common.ts
index edf0ef0929e144fc7c953d9ba2aeb6d654b60cfc..e644a73d7ce76f8f336f7bb57919319687313b67 100644
--- a/app/lib/common.ts
+++ b/app/lib/common.ts
@@ -1,5 +1,9 @@
-const common = require('../../app/common')
+import * as crypto from 'crypto'
 
-export function hashf(str:string) {
-  return common.hashf(str).toUpperCase()
+export const hashf = function hashf(str:string) {
+  return crypto
+    .createHash("sha256")
+    .update(str)
+    .digest("hex")
+    .toUpperCase()
 }
diff --git a/app/lib/dal/sqliteDAL/MetaDAL.ts b/app/lib/dal/sqliteDAL/MetaDAL.ts
index 8dccc0eef4f55f040a2c5414321d1f488566eaf7..073ef573076efc716dea3d62f196e3e3b8f1a244 100644
--- a/app/lib/dal/sqliteDAL/MetaDAL.ts
+++ b/app/lib/dal/sqliteDAL/MetaDAL.ts
@@ -11,11 +11,11 @@ import {WalletDAL} from "./WalletDAL"
 import {MIndexDAL} from "./index/MIndexDAL"
 import {DBBlock} from "../../db/DBBlock"
 import {IdentityDTO} from "../../dto/IdentityDTO"
+import {rawer} from "../../common-libs/index";
 
 const _ = require('underscore')
 const logger = require('../../logger').NewLogger('metaDAL');
 const common = require('../../../../app/common');
-const rawer = require('../../../../app/common').rawer;
 const constants = require('./../../constants');
 
 export interface DBMeta {
diff --git a/app/lib/indexer.ts b/app/lib/indexer.ts
index cb2f4b22e1461007e84e922f5f2b0bf172d2ee1b..7ef5df43f63e3a19fcce05ae8bb4a3569e530118 100644
--- a/app/lib/indexer.ts
+++ b/app/lib/indexer.ts
@@ -8,14 +8,12 @@ import {TransactionDTO} from "./dto/TransactionDTO"
 import {DBHead} from "./db/DBHead"
 import {LOCAL_RULES_HELPERS} from "./rules/local_rules"
 import {verify} from "./common-libs/crypto/keyring";
+import {rawer, txunlock} from "./common-libs/index";
 
-const co              = require('co');
 const _               = require('underscore');
 const common          = require('../../app/common');
 
 const constants       = common.constants
-const rawer           = common.rawer
-const unlock          = common.txunlock
 const Block           = common.document.Block
 const Membership      = common.document.Membership
 
@@ -2011,7 +2009,7 @@ function txSourceUnlock(ENTRY:SindexEntry, source:SindexEntry, HEAD: DBHead) {
       unlocksMetadata.elapsedTime = HEAD.medianTime - source.written_time;
     }
 
-    if (unlock(source.conditions, unlocksForCondition, unlocksMetadata)) {
+    if (txunlock(source.conditions, unlocksForCondition, unlocksMetadata)) {
       return true;
     }
   }
diff --git a/app/lib/rules/global_rules.ts b/app/lib/rules/global_rules.ts
index ca4eff2c43b1d64db092b442a7c42f61c20092ed..077323c777ee4a3397b193e998aff455def12c7e 100644
--- a/app/lib/rules/global_rules.ts
+++ b/app/lib/rules/global_rules.ts
@@ -6,16 +6,15 @@ import {TransactionDTO} from "../dto/TransactionDTO"
 import * as local_rules from "./local_rules"
 import {BlockDTO} from "../dto/BlockDTO"
 import {verify} from "../common-libs/crypto/keyring"
+import {rawer, txunlock} from "../common-libs/index";
 
 const _              = require('underscore');
 const common         = require('../../../app/common');
 const indexer        = require('../indexer').Indexer
 
 const constants      = common.constants
-const rawer          = common.rawer
 const Identity       = common.document.Identity
 const Transaction    = common.document.Transaction
-const unlock         = common.txunlock
 
 // Empty logger by default
 let logger = {
@@ -127,7 +126,7 @@ export const GLOBAL_RULES_FUNCTIONS = {
           }
 
           try {
-            if (!unlock(dbSrc.conditions, unlocksForCondition, unlocksMetadata)) {
+            if (!txunlock(dbSrc.conditions, unlocksForCondition, unlocksMetadata)) {
               throw Error('Locked');
             }
           } catch (e) {
diff --git a/app/lib/rules/local_rules.ts b/app/lib/rules/local_rules.ts
index b67f44b6f0a2a0ad1ad3732a8d22752780fcd36a..7913db3916ccca67cb1fac0d8ed23b56d60e6a09 100644
--- a/app/lib/rules/local_rules.ts
+++ b/app/lib/rules/local_rules.ts
@@ -5,12 +5,12 @@ import {CindexEntry, IndexEntry, Indexer, MindexEntry, SindexEntry} from "../ind
 import {BaseDTO, TransactionDTO} from "../dto/TransactionDTO"
 import {DBBlock} from "../db/DBBlock"
 import {verify} from "../common-libs/crypto/keyring"
+import {hashf} from "../common"
 
 const _          = require('underscore');
 const common     = require('../../../app/common');
 
 const constants       = common.constants
-const hashf           = common.hashf
 const Block           = common.document.Block
 const Identity        = common.document.Identity
 const Membership      = common.document.Membership
diff --git a/app/modules/bma/lib/controllers/AbstractController.ts b/app/modules/bma/lib/controllers/AbstractController.ts
index baf52825aa4075f5131288379c717da0d22ff3cf..9206e3f68e0ae3279d835da06b546ce1c2a04db9 100644
--- a/app/modules/bma/lib/controllers/AbstractController.ts
+++ b/app/modules/bma/lib/controllers/AbstractController.ts
@@ -1,6 +1,5 @@
 import {Server} from "../../../../../server"
-
-const dos2unix = require('../dos2unix')
+import {dos2unix} from "../../../../lib/common-libs/dos2unix"
 
 export abstract class AbstractController {
 
diff --git a/app/modules/bma/lib/dos2unix.ts b/app/modules/bma/lib/dos2unix.ts
deleted file mode 100644
index bbc290fc2f9c29643300f88cc1268e749c1d87cb..0000000000000000000000000000000000000000
--- a/app/modules/bma/lib/dos2unix.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-module.exports = function dos2unix(str:string) {
-  return str.replace(/\r\n/g, '\n')
-}
diff --git a/app/modules/crawler/index.ts b/app/modules/crawler/index.ts
index 3a777527cba57746d4b4ff7d2d80595fca6690b4..4cfdda9e39b5294c428a6aa8fe62fee327550a26 100644
--- a/app/modules/crawler/index.ts
+++ b/app/modules/crawler/index.ts
@@ -5,6 +5,7 @@ import {Crawler} from "./lib/crawler"
 import {Synchroniser} from "./lib/sync"
 import {req2fwd} from "./lib/req2fwd"
 import {CrawlerConstants} from "./lib/constants"
+import {rawer} from "../../lib/common-libs/index";
 
 const common = require('../../../app/common');
 const Peer = common.document.Peer
@@ -180,7 +181,7 @@ export const CrawlerDependency = {
           const lookup = await sourcePeer.getLookup(search);
           for (const res of lookup.results) {
             for (const uid of res.uids) {
-              const rawIdty = common.rawer.getOfficialIdentity({
+              const rawIdty = rawer.getOfficialIdentity({
                 currency: 'g1',
                 issuer: res.pubkey,
                 uid: uid.uid,
@@ -194,7 +195,7 @@ export const CrawlerDependency = {
                 logger.error(e);
               }
               for (const received of uid.others) {
-                const rawCert = common.rawer.getOfficialCertification({
+                const rawCert = rawer.getOfficialCertification({
                   currency: 'g1',
                   issuer: received.pubkey,
                   idty_issuer: res.pubkey,
@@ -233,7 +234,7 @@ export const CrawlerDependency = {
                 block = await sourcePeer.getBlock(signed.cert_time.block)
                 mapBlocks[block.number] = block
               }
-              const rawCert = common.rawer.getOfficialCertification({
+              const rawCert = rawer.getOfficialCertification({
                 currency: 'g1',
                 issuer: certBy.pubkey,
                 idty_issuer: signed.pubkey,
@@ -302,7 +303,7 @@ export const CrawlerDependency = {
           for (const theMS of pendingMSS) {
             console.log('New membership pending for %s', theMS.uid);
             try {
-              rawMS = common.rawer.getMembership({
+              rawMS = rawer.getMembership({
                 currency: 'g1',
                 issuer: theMS.issuer,
                 block: theMS.block,
diff --git a/app/modules/crawler/lib/req2fwd.ts b/app/modules/crawler/lib/req2fwd.ts
index bccb576bfa264a042b733253cdd4d73c9e1be059..31fbd703d5dca0c3fea4a848e968052f889484fd 100644
--- a/app/modules/crawler/lib/req2fwd.ts
+++ b/app/modules/crawler/lib/req2fwd.ts
@@ -1,4 +1,6 @@
 import {Contacter} from "./contacter"
+import {verify} from "../../../lib/common-libs/crypto/keyring"
+import {rawer} from "../../../lib/common-libs/index";
 
 const common = require('../../../../app/common')
 
@@ -15,7 +17,7 @@ export const req2fwd = async (requirements:any, toHost:string, toPort:number, lo
         logger.info('New identity %s', idty.uid);
         identities[iid] = idty;
         try {
-          const rawIdty = common.rawer.getOfficialIdentity({
+          const rawIdty = rawer.getOfficialIdentity({
             currency: 'g1',
             issuer: idty.pubkey,
             uid: idty.uid,
@@ -33,7 +35,7 @@ export const req2fwd = async (requirements:any, toHost:string, toPort:number, lo
         if (!certs[cid]) {
           await new Promise((res) => setTimeout(res, 300));
           certs[cid] = received;
-          const rawCert = common.rawer.getOfficialCertification({
+          const rawCert = rawer.getOfficialCertification({
             currency: 'g1',
             issuer: received.from,
             idty_issuer: idty.pubkey,
@@ -43,7 +45,7 @@ export const req2fwd = async (requirements:any, toHost:string, toPort:number, lo
             buid: received.blockstamp,
             sig: received.sig
           });
-          const rawCertNoSig = common.rawer.getOfficialCertification({
+          const rawCertNoSig = rawer.getOfficialCertification({
             currency: 'g1',
             issuer: received.from,
             idty_issuer: idty.pubkey,
@@ -53,7 +55,7 @@ export const req2fwd = async (requirements:any, toHost:string, toPort:number, lo
             buid: received.blockstamp
           });
           try {
-            const chkSig = common.keyring.verify(rawCertNoSig, received.sig, received.from)
+            const chkSig = verify(rawCertNoSig, received.sig, received.from)
             if (!chkSig) {
               throw "Wrong signature for certification?!"
             }
@@ -70,7 +72,7 @@ export const req2fwd = async (requirements:any, toHost:string, toPort:number, lo
         if (!mss[id]) {
           mss[id] = theMS
           try {
-            const rawMS = common.rawer.getMembership({
+            const rawMS = rawer.getMembership({
               currency: 'g1',
               issuer: idty.pubkey,
               userid: idty.uid,
diff --git a/app/modules/crawler/lib/sandbox.ts b/app/modules/crawler/lib/sandbox.ts
index af03705e174121ddaef2354ead0583a017095d09..954bd31580013d1baabba654fe196c0b6f1b6870 100644
--- a/app/modules/crawler/lib/sandbox.ts
+++ b/app/modules/crawler/lib/sandbox.ts
@@ -1,8 +1,8 @@
 "use strict";
 import {Contacter} from "./contacter"
 import {Server} from "../../../../server"
+import {rawer} from "../../../lib/common-libs/index";
 
-const rawer = require('../../../../app/common').rawer;
 const parsers = require('../../../../app/common').parsers;
 
 export const pullSandbox = async (currency:string, fromHost:string, fromPort:number, toHost:string, toPort:number, logger:any) => {
diff --git a/app/modules/crawler/lib/sync.ts b/app/modules/crawler/lib/sync.ts
index 95981ede90123a809d832e2f9969a6744379fd30..d42e5c56e205beae13cdd67f7cbd2f544c7cf67e 100644
--- a/app/modules/crawler/lib/sync.ts
+++ b/app/modules/crawler/lib/sync.ts
@@ -11,6 +11,9 @@ import { tx_cleaner } from "./tx_cleaner";
 import { AbstractDAO } from "./pulling";
 import { DBBlock } from "../../../lib/db/DBBlock";
 import { BlockchainService } from "../../../service/BlockchainService";
+import {rawer} from "../../../lib/common-libs/index";
+import {dos2unix} from "../../../lib/common-libs/dos2unix"
+import {hashf} from "../../../lib/common"
 
 const util         = require('util');
 const _            = require('underscore');
@@ -19,9 +22,6 @@ const multimeter   = require('multimeter');
 const makeQuerablePromise = require('querablep');
 const common       = require('../../../../app/common');
 const Peer         = common.document.Peer;
-const dos2unix = common.dos2unix;
-const hashf = common.hashf;
-const rawer = common.rawer;
 
 const CONST_BLOCKS_CHUNK = 250;
 const EVAL_REMAINING_INTERVAL = 1000;
@@ -188,7 +188,7 @@ export class Synchroniser extends stream.Duplex {
       // We use cautious mode if it is asked, or not particulary asked but blockchain has been started
       const cautious = (askedCautious === true || localNumber >= 0);
       const shuffledPeers = noShufflePeers ? peers : _.shuffle(peers);
-      const downloader = new P2PDownloader(localNumber, to, rCurrent.hash, shuffledPeers, this.watcher, this.logger, hashf, rawer, this.dal, this.slowOption);
+      const downloader = new P2PDownloader(localNumber, to, rCurrent.hash, shuffledPeers, this.watcher, this.logger, hashf, this.dal, this.slowOption);
 
       downloader.start();
 
@@ -618,7 +618,6 @@ class P2PDownloader {
     private watcher:Watcher,
     private logger:any,
     private hashf:any,
-    private rawer:any,
     private dal:FileDAL,
     private slowOption:any) {
 
diff --git a/app/modules/prover/lib/blockGenerator.ts b/app/modules/prover/lib/blockGenerator.ts
index 2854cb6f3de1065b9a0df20a6b581a390b09d663..7e49eef84b0abaf9ad2e35f8b9465481e2c9a5ed 100644
--- a/app/modules/prover/lib/blockGenerator.ts
+++ b/app/modules/prover/lib/blockGenerator.ts
@@ -8,14 +8,14 @@ import {Indexer} from "../../../lib/indexer"
 import {FileDAL} from "../../../lib/dal/fileDAL"
 import {DBBlock} from "../../../lib/db/DBBlock"
 import {verify} from "../../../lib/common-libs/crypto/keyring"
+import {rawer} from "../../../lib/common-libs/index";
+import {hashf} from "../../../lib/common";
 
 const _               = require('underscore');
 const moment          = require('moment');
 const inquirer        = require('inquirer');
 const common          = require('../../../../app/common');
 
-const hashf         = common.hashf;
-const rawer         = common.rawer;
 const Block         = common.document.Block;
 const Membership    = common.document.Membership;
 const Transaction   = common.document.Transaction;
diff --git a/app/modules/prover/lib/permanentProver.ts b/app/modules/prover/lib/permanentProver.ts
index 42ac4442c48571761a4c59d71f0dddc2a08c8b1c..09c0ff6a4e8f54cdee4543df3309e4c5742e7c62 100644
--- a/app/modules/prover/lib/permanentProver.ts
+++ b/app/modules/prover/lib/permanentProver.ts
@@ -3,10 +3,10 @@ import {ConfDTO} from "../../../lib/dto/ConfDTO"
 import {BlockProver} from "./blockProver"
 import {Constants} from "./constants"
 import {DBBlock} from "../../../lib/db/DBBlock"
+import {dos2unix} from "../../../lib/common-libs/dos2unix"
 
 const querablep = require('querablep');
 const common = require('../../../../app/common');
-const dos2unix = common.dos2unix;
 const parsers = common.parsers;
 
 export class PermanentProver {
diff --git a/app/modules/prover/lib/proof.ts b/app/modules/prover/lib/proof.ts
index 96c597842b5e39723b376a54ce95aee7b49d35f5..e569f5a362c205887a964541ff9016e749aa14b7 100644
--- a/app/modules/prover/lib/proof.ts
+++ b/app/modules/prover/lib/proof.ts
@@ -4,11 +4,11 @@ import {DBBlock} from "../../../lib/db/DBBlock"
 import {ConfDTO} from "../../../lib/dto/ConfDTO"
 import {Constants} from "./constants"
 import {KeyGen} from "../../../lib/common-libs/crypto/keyring"
+import {dos2unix} from "../../../lib/common-libs/dos2unix"
+import {rawer} from "../../../lib/common-libs/index";
 
 const moment = require('moment');
-const dos2unix = require('../../../../app/common').dos2unix;
 const querablep = require('querablep');
-const rawer = require('../../../../app/common').rawer;
 
 const PAUSES_PER_TURN = 5;
 
diff --git a/app/service/MembershipService.ts b/app/service/MembershipService.ts
index 6c6d83a4f137e4582576e95c9a180064c90a5aa3..a64b16de3887a346db18a964e4de309c22aa5020 100644
--- a/app/service/MembershipService.ts
+++ b/app/service/MembershipService.ts
@@ -6,7 +6,6 @@ import {LOCAL_RULES_HELPERS} from "../lib/rules/local_rules"
 import {GLOBAL_RULES_HELPERS} from "../lib/rules/global_rules"
 import {MembershipDTO} from "../lib/dto/MembershipDTO"
 
-const hashf           = require('../../app/common').hashf;
 const constants       = require('../lib/constants');
 
 export class MembershipService {
diff --git a/app/service/PeeringService.ts b/app/service/PeeringService.ts
index 70d515191a89efad9a699685c56bea9a59cf3e0a..bba228ff6e8f5d2d72ed4f719600d728a441d37e 100644
--- a/app/service/PeeringService.ts
+++ b/app/service/PeeringService.ts
@@ -6,15 +6,14 @@ import {DBBlock} from "../lib/db/DBBlock"
 import {Multicaster} from "../lib/streams/multicaster"
 import {PeerDTO} from "../lib/dto/PeerDTO"
 import {verify} from "../lib/common-libs/crypto/keyring"
+import {dos2unix} from "../lib/common-libs/dos2unix"
+import {rawer} from "../lib/common-libs/index";
 
 const util           = require('util');
 const _              = require('underscore');
 const events         = require('events');
 const rp             = require('request-promise');
 const logger         = require('../lib/logger').NewLogger('peering');
-const dos2unix       = require('../../app/common').dos2unix;
-const hashf          = require('../../app/common').hashf;
-const rawer          = require('../../app/common').rawer;
 const constants      = require('../lib/constants');
 
 export interface Keyring {
diff --git a/server.ts b/server.ts
index 5756973ace26cc6ad754043fb621d4ad51d5d1c8..7a76c5f54214fffac3ff17ed796a31d278c9b1da 100644
--- a/server.ts
+++ b/server.ts
@@ -30,7 +30,6 @@ const parsers     = require('./app/common').parsers;
 const constants   = require('./app/lib/constants');
 const jsonpckg    = require('./package.json');
 const directory   = require('./app/lib/system/directory');
-const rawer       = require('./app/common').rawer;
 const logger      = require('./app/lib/logger').NewLogger('server');
 
 export class Server extends stream.Duplex implements HookableServer {
@@ -62,7 +61,6 @@ export class Server extends stream.Duplex implements HookableServer {
     this.conf = ConfDTO.mock()
     this.version = jsonpckg.version;
     this.logger = logger;
-    this.rawer = rawer;
 
     this.paramsP = directory.getHomeParams(memoryOnly, home)
 
diff --git a/test/fast/modules/common/crypto.js b/test/fast/modules/common/crypto.js
index ce72bc5c5f33da167901817a1ec9fd37b905dd29..1bdd4f6a30f4f7d54cbfcfcd036788e67dfb69cc 100644
--- a/test/fast/modules/common/crypto.js
+++ b/test/fast/modules/common/crypto.js
@@ -2,11 +2,11 @@
 const should = require('should');
 const co  = require('co');
 const nacl   = require('tweetnacl');
-const base58 = require('../../../../app/common/lib/crypto/base58');
-const keyring      = require('../../../../app/common/lib/crypto/keyring');
+const base58 = require('../../../../app/lib/common-libs').base58
+const keyring      = require('../../../../app/lib/common-libs/crypto/keyring');
 
-const enc = nacl.util.encodeBase64,
-    dec = nacl.util.decodeBase64;
+const enc = require('../../../../app/lib/common-libs/crypto/nacl-util').encodeBase64,
+       dec = require('../../../../app/lib/common-libs/crypto/nacl-util').decodeBase64
 
 let pub, sec, rawPub, rawSec;
 
@@ -14,7 +14,7 @@ describe('ed25519 tests:', function(){
 
   before(() => co(function*() {
     // Generate the keypair
-    const keyPair = keyring.Key('HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd', '51w4fEShBk1jCMauWu4mLpmDVfHksKmWcygpxriqCEZizbtERA6de4STKRkQBpxmMUwsKXRjSzuQ8ECwmqN1u2DP');
+    const keyPair = keyring.KeyGen('HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd', '51w4fEShBk1jCMauWu4mLpmDVfHksKmWcygpxriqCEZizbtERA6de4STKRkQBpxmMUwsKXRjSzuQ8ECwmqN1u2DP');
     pub = base58.decode(keyPair.publicKey);
     sec = base58.decode(keyPair.secretKey);
     rawPub = base58.encode(pub);
@@ -33,7 +33,7 @@ describe('ed25519 tests:', function(){
 
   it('good signature from generated key should be verified', function(done){
     const msg = "Some message to be signed";
-    const sig = keyring.Key(rawPub, rawSec).signSync(msg);
+    const sig = keyring.KeyGen(rawPub, rawSec).signSync(msg);
     const verified = keyring.verify(msg, sig, rawPub);
     verified.should.equal(true);
     done();
@@ -42,7 +42,7 @@ describe('ed25519 tests:', function(){
   it('wrong signature from generated key should NOT be verified', function(done){
     const msg = "Some message to be signed";
     const cor = dec(enc(msg) + 'delta');
-    const sig = keyring.Key(rawPub, rawSec).signSync(msg);
+    const sig = keyring.KeyGen(rawPub, rawSec).signSync(msg);
     const verified = keyring.verify(cor, sig, rawPub);
     verified.should.equal(false);
     done();
diff --git a/test/fast/modules/common/grammar-test.js b/test/fast/modules/common/grammar-test.js
index 3e27dcc86e0114a0984019a39ce85ac50463362a..72270bf8d3502ceb4c8a7cc17a049dc10ad98845 100644
--- a/test/fast/modules/common/grammar-test.js
+++ b/test/fast/modules/common/grammar-test.js
@@ -1,6 +1,6 @@
 "use strict";
 
-const unlock    = require('../../../../app/common/lib/txunlock');
+const unlock    = require('../../../../app/lib/common-libs').txunlock
 const should    = require('should');
 
 describe('Grammar', () => {
diff --git a/test/fast/modules/common/randomKey.js b/test/fast/modules/common/randomKey.js
index 7a21f9cf89a0f1c049537e15f7e4c06a2734331f..6bc1f41355a19bf4002f3c7237ed1878f1a56893 100644
--- a/test/fast/modules/common/randomKey.js
+++ b/test/fast/modules/common/randomKey.js
@@ -2,10 +2,11 @@
 const should = require('should');
 const co  = require('co');
 const nacl   = require('tweetnacl');
-const keyring      = require('../../../../app/common/lib/crypto/keyring');
+const keyring      = require('../../../../app/lib/common-libs/crypto/keyring');
 
-const enc = nacl.util.encodeBase64,
-    dec = nacl.util.decodeBase64;
+
+const enc = require('../../../../app/lib/common-libs/crypto/nacl-util').encodeBase64,
+  dec = require('../../../../app/lib/common-libs/crypto/nacl-util').decodeBase64
 
 let key;
 
@@ -18,7 +19,7 @@ describe('Random keypair', function(){
 
   it('good signature from generated key should be verified', function(done){
     const msg = "Some message to be signed";
-    const sig = keyring.Key(key.publicKey, key.secretKey).signSync(msg);
+    const sig = keyring.KeyGen(key.publicKey, key.secretKey).signSync(msg);
     const verified = keyring.verify(msg, sig, key.publicKey);
     verified.should.equal(true);
     done();
@@ -27,7 +28,7 @@ describe('Random keypair', function(){
   it('wrong signature from generated key should NOT be verified', function(done){
     const msg = "Some message to be signed";
     const cor = dec(enc(msg) + 'delta');
-    const sig = keyring.Key(key.publicKey, key.secretKey).signSync(msg);
+    const sig = keyring.KeyGen(key.publicKey, key.secretKey).signSync(msg);
     const verified = keyring.verify(cor, sig, key.publicKey);
     verified.should.equal(false);
     done();
diff --git a/test/integration/cli.js b/test/integration/cli.js
index a6bdcfe2bb782ad3f28e896e5b8bbf44e8a9b141..7f7fd57fc3dc893bf6466b4e8d74a504dc0e08eb 100644
--- a/test/integration/cli.js
+++ b/test/integration/cli.js
@@ -8,7 +8,7 @@ const _         = require('underscore');
 const toolbox   = require('./tools/toolbox');
 const duniter   = require('../../index');
 const merkleh   = require('../../app/lib/helpers/merkle');
-const hashf     = require('../../app/common').hashf;
+const hashf     = require('../../app/lib/common-libs').hashf
 const constants = require('../../app/lib/constants');
 const MerkleDTO = require('../../app/lib/dto/MerkleDTO').MerkleDTO
 
diff --git a/test/integration/tools/user.js b/test/integration/tools/user.js
index c25105a7d51f974105fd98804959b6127339df9d..cbf62fa4fb4941da6421744067e02aac6d210450 100644
--- a/test/integration/tools/user.js
+++ b/test/integration/tools/user.js
@@ -7,8 +7,8 @@ const contacter = require('../../../app/modules/crawler').CrawlerDependency.duni
 const common  = require('../../../app/common');
 const ucp     = common.buid;
 const parsers = require('../../../app/common').parsers;
-const keyring	= common.keyring;
-const rawer		= common.rawer;
+const rawer = require('../../../app/lib/common-libs').rawer
+const keyring = require('../../../app/lib/common-libs/crypto/keyring')
 const constants = require('../../../app/lib/constants');
 const CertificationDTO = require('../../../app/lib/dto/CertificationDTO').CertificationDTO
 const MembershipDTO = require('../../../app/lib/dto/MembershipDTO').MembershipDTO
@@ -55,7 +55,7 @@ function User (uid, options, node) {
       issuer: pub,
       currency: node.server.conf.currency
     });
-    createdIdentity += keyring.Key(pub, sec).signSync(createdIdentity) + '\n';
+    createdIdentity += keyring.KeyGen(pub, sec).signSync(createdIdentity) + '\n';
     yield that.submitIdentity(createdIdentity, fromServer);
   });
 
@@ -82,7 +82,7 @@ function User (uid, options, node) {
     };
     _.extend(cert, overrideProps || {});
     const rawCert = rawer.getOfficialCertification(cert);
-    cert.sig = keyring.Key(pub, sec).signSync(rawCert, sec);
+    cert.sig = keyring.KeyGen(pub, sec).signSync(rawCert, sec);
     return CertificationDTO.fromJSONObject(cert);
   });
 
@@ -118,7 +118,7 @@ function User (uid, options, node) {
     };
     _.extend(revocation, overrideProps || {});
     const rawRevocation = rawer.getOfficialRevocation(revocation);
-    revocation.revocation = keyring.Key(pub, sec).signSync(rawRevocation);
+    revocation.revocation = keyring.KeyGen(pub, sec).signSync(rawRevocation);
     return RevocationDTO.fromJSONObject(revocation);
   });
 
@@ -145,7 +145,7 @@ function User (uid, options, node) {
     };
     _.extend(join, overrideProps || {});
     const rawJoin = rawer.getMembershipWithoutSignature(join);
-    join.signature = keyring.Key(pub, sec).signSync(rawJoin);
+    join.signature = keyring.KeyGen(pub, sec).signSync(rawJoin);
     return MembershipDTO.fromJSONObject(join)
   });
 
@@ -275,9 +275,9 @@ function User (uid, options, node) {
   });
 
   function signed(raw, user2) {
-    let signatures = [keyring.Key(pub, sec).signSync(raw)];
+    let signatures = [keyring.KeyGen(pub, sec).signSync(raw)];
     if (user2) {
-      signatures.push(keyring.Key(user2.pub, user2.sec).signSync(raw));
+      signatures.push(keyring.KeyGen(user2.pub, user2.sec).signSync(raw));
     }
     return raw + signatures.join('\n') + '\n';
   }
@@ -325,7 +325,7 @@ function User (uid, options, node) {
     });
     _.extend(peer, overrideProps || {});
     const rawPeer = rawer.getPeerWithoutSignature(peer);
-    peer.signature = keyring.Key(pub, sec).signSync(rawPeer);
+    peer.signature = keyring.KeyGen(pub, sec).signSync(rawPeer);
     return PeerDTO.fromJSONObject(peer)
   });