autogenerated fromkeypair if not present

This commit is contained in:
Ryan X. Charles 2014-09-15 10:43:14 -07:00
parent 4a027e260a
commit fbfa64582c
2 changed files with 7 additions and 0 deletions

View File

@ -11,6 +11,8 @@ var ECIES = function ECIES() {
};
ECIES.encrypt = function(messagebuf, tokeypair, fromkeypair, ivbuf) {
if (!fromkeypair)
fromkeypair = Keypair().fromRandom();
var r = fromkeypair.privkey.bn;
var R = fromkeypair.pubkey.point;
var Rpubkey = fromkeypair.pubkey;

View File

@ -26,6 +26,11 @@ describe('#ECIES', function() {
Buffer.isBuffer(encbuf).should.equal(true);
});
it('should return a buffer if fromkey is not present', function() {
var encbuf = ECIES.encrypt(messagebuf, tokey);
Buffer.isBuffer(encbuf).should.equal(true);
});
});
describe('@decrypt', function() {