UNPKG

datona-lib

Version:

Core library for access to the Datona IO Platform. Datona Protocol v0.0.2. Adds HTTP and WebSocket support.

34 lines (28 loc) 1.2 kB
const chai = require('chai'); chai.use(require('chai-as-promised')); const expect = chai.expect; const should = chai.should(); const datona = require('../src/datona'); function encrypt(data, key) { } describe("Large File Transfer Test", function() { it("includes error name and message", function() { expect( new errors.DatonaError("my message").toString() ).to.equal("DatonaError - my message"); expect( new errors.CommunicationError("My Message").toString() ).to.equal("CommunicationError - My Message"); expect( new errors.ContractExpiryError("Another message").toString() ).to.equal("ContractExpiryError - Another message"); }); // Proxy re-encryption test // x is secret key var x = bigInt.randBetween(1, factor.minus(1)); var x1 = bigInt.randBetween(1, x); var x2 = x.minus(x1); // y is public key var y = g.modPow(x, prime); var r = bigInt.randBetween(1, factor.minus(1)); var c3 = g.modPow(r, prime); // mg^xr var c4 = m.multiply(y.modPow(r, prime)).mod(prime); var _decryptP = c4.multiply(c3.modPow(x1, prime).modInv(prime)).mod(prime); var _decryptF = _decryptP.multiply(c3.modPow(x2, prime).modInv(prime)).mod(prime); console.log(_decryptF); // should be 2234266 }