2014-12-13 19:56:14 +01:00
|
|
|
/**
|
2014-12-30 18:00:28 +01:00
|
|
|
* Isomorphic Bitmessage crypto module. Reexports
|
|
|
|
* [platform-specific functions]{@link module:bitmessage/crypto-platform}
|
|
|
|
* and also some common routines.
|
2014-12-18 17:47:18 +01:00
|
|
|
* @module bitmessage/crypto
|
2014-12-13 19:56:14 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
2014-12-27 16:17:41 +01:00
|
|
|
var eccrypto = require("eccrypto");
|
2014-12-26 17:47:25 +01:00
|
|
|
var cryptoPlatform = require("./crypto-platform");
|
2014-12-26 18:17:01 +01:00
|
|
|
|
2014-12-26 17:47:25 +01:00
|
|
|
Object.keys(cryptoPlatform).forEach(function(key) {
|
|
|
|
exports[key] = cryptoPlatform[key];
|
|
|
|
});
|
2014-12-27 16:17:41 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate new random private key.
|
|
|
|
* @return {Buffer} New private key.
|
|
|
|
*/
|
|
|
|
exports.getPrivate = function() {
|
|
|
|
return cryptoPlatform.randomBytes(32);
|
|
|
|
};
|
|
|
|
|
2014-12-30 18:00:28 +01:00
|
|
|
/**
|
|
|
|
* Generate public key for a given private key.
|
|
|
|
* @param {Buffer} privateKey - Private key
|
|
|
|
* @return {Buffer} Public key.
|
|
|
|
* @function
|
|
|
|
*/
|
2014-12-27 16:17:41 +01:00
|
|
|
exports.getPublic = eccrypto.getPublic;
|