telehash/telehash-js

e3x native build problems, with fix to fall back to js-nacl (pure JS sodium)

automenta opened this issue · 4 comments

using node v0.12.2
i encountered build problems such as:

/home/me/.node-gyp/0.12.2/deps/v8/include/v8.h:2114:8: note:   candidate expects 2 arguments, 3 provided
../sodium.cc:1257:71: error: no matching function for call to 'v8::Object::Set(NanIntern::FactoryBase<v8::String>::return_t, NanIntern::IntegerFactory<v8::Integer>::return_t, v8::PropertyAttribute)'
     target->Set(NanNew<String>(#NAME), NanNew<Integer>(NAME), ReadOnly)

after some modifications i was able to get my telehash example to run without errors (but didn't actually test its operation). it involved modifications in both telehash-js and c3x and i'm not sure exactly why this works but jer probably will:

in package.json i use:

        "e3x-cs3a": "latest",
        "telehash": "telehash/telehash-js"

in e3x-cs3a/node.js

exports = module.exports = require('./cs3a.js'); // load common module

// try compiled sodium, fall back to pure js one
try{
  if(process.env.PURE == 'true') throw new Error("pure requested");
  var sodium = require("sodium").api;
  exports.crypt(sodium);
}catch(E){
  console.warn("Native CS3a unavailable, using 'js-nacl'.");
  var nacl_factory = require("js-nacl");
  exports.crypt( nacl_factory.instantiate() );
}

in telehash/lib/mesh.js in generate()

...
    for (var csid in pairs) {
      var pair = pairs[csid];
      if (pair.key && pair.secret) { //not sure why but one of the pairs ends up nullish
          id.keys[csid] = base32.encode(pairs[csid].key);     
          id.secrets[csid] = base32.encode(pairs[csid].secret);
      }
    }
...

i think these are all the modifications i needed but i'm not sure if theyre correct

Ok, so worked on this some today, and those fixes to e3x-cs3a should make this work for you, could you try a new clean install/build and just close this if so or let me know if anything else went wrong? Thx!

yeah i think this corrected the problem. im working on an app which might be able to demonstrate telehash's capabilities. just getting back into node.js after a long period of java work

Awesome! as you can see, I'm aiming to make telehash-js an easy to use module, but there's quite a bit under the hood to power it and it all needs more rigorous testing together in the real world...

cleaning house. this issue seems to have been resolved for quite some time so I'm going to close it. New issues for the crypto end of things can probably be pointed towards e3x or even subtle