nobleCurves, serve file for cryptography in the browser
This commit is contained in:
@ -35,6 +35,8 @@ app.use(sessionMiddleware);
|
||||
app.use("/", routes);
|
||||
// bootstrap
|
||||
app.use('/css', express.static(__dirname + '/node_modules/bootstrap/dist/css'));
|
||||
// scripts
|
||||
app.use('/', express.static(__dirname + '/public'));
|
||||
|
||||
// socket.io
|
||||
io.engine.use(sessionMiddleware);
|
||||
|
@ -7,33 +7,33 @@ const mainController = {
|
||||
let isLoggedIn = typeof pubKey !== 'undefined';
|
||||
res.render('index', {isLoggedIn, pubKey});
|
||||
},
|
||||
style: (req, res) => {
|
||||
res.sendFile(path.resolve(__dirname + '/../public/style.css'));
|
||||
},
|
||||
script: (req, res) => {
|
||||
res.sendFile(path.resolve(__dirname + '/../public/script.js'));
|
||||
},
|
||||
ecc: (req, res) => {
|
||||
res.sendFile(path.resolve(__dirname + '/../public/ecc.js'));
|
||||
},
|
||||
ecdh: (req, res) => {
|
||||
res.sendFile(path.resolve(__dirname + '/../public/ecdh.js'));
|
||||
},
|
||||
popups: (req, res) => {
|
||||
res.sendFile(path.resolve(__dirname + '/../public/popups.js'));
|
||||
},
|
||||
chat : (req, res) => {
|
||||
res.sendFile(path.resolve(__dirname + '/../public/chat.js'));
|
||||
},
|
||||
register : (req, res) => {
|
||||
res.sendFile(path.resolve(__dirname + '/../public/register.js'));
|
||||
},
|
||||
pubkey : (req, res) => {
|
||||
res.sendFile(path.resolve(__dirname + '/../public/pubkey.js'));
|
||||
},
|
||||
registertext : (req, res) => {
|
||||
res.sendFile(path.resolve(__dirname + '/../public/registertext.js'));
|
||||
}
|
||||
// style: (req, res) => {
|
||||
// res.sendFile(path.resolve(__dirname + '/../public/style.css'));
|
||||
// },
|
||||
// script: (req, res) => {
|
||||
// res.sendFile(path.resolve(__dirname + '/../public/script.js'));
|
||||
// },
|
||||
// ecc: (req, res) => {
|
||||
// res.sendFile(path.resolve(__dirname + '/../public/ecc.js'));
|
||||
// },
|
||||
// ecdh: (req, res) => {
|
||||
// res.sendFile(path.resolve(__dirname + '/../public/ecdh.js'));
|
||||
// },
|
||||
// popups: (req, res) => {
|
||||
// res.sendFile(path.resolve(__dirname + '/../public/popups.js'));
|
||||
// },
|
||||
// chat : (req, res) => {
|
||||
// res.sendFile(path.resolve(__dirname + '/../public/chat.js'));
|
||||
// },
|
||||
// register : (req, res) => {
|
||||
// res.sendFile(path.resolve(__dirname + '/../public/register.js'));
|
||||
// },
|
||||
// pubkey : (req, res) => {
|
||||
// res.sendFile(path.resolve(__dirname + '/../public/pubkey.js'));
|
||||
// },
|
||||
// registertext : (req, res) => {
|
||||
// res.sendFile(path.resolve(__dirname + '/../public/registertext.js'));
|
||||
// }
|
||||
};
|
||||
|
||||
module.exports = mainController;
|
||||
|
@ -1,9 +1,9 @@
|
||||
// X25519 aka ECDH on Curve25519 from [RFC7748](https://www.rfc-editor.org/rfc/rfc7748)
|
||||
import { x25519 } from '@noble/curves/ed25519';
|
||||
// X25519
|
||||
// aka ECDH on Curve25519 from [RFC7748](https://www.rfc-editor.org/rfc/rfc7748)
|
||||
|
||||
export function genKeys() {
|
||||
const priv = x25519.utils.randomPrivateKey();
|
||||
const pub = x25519.getPublicKey(priv);
|
||||
const priv = nobleCurves.x25519.utils.randomPrivateKey();
|
||||
const pub = nobleCurves.x25519.getPublicKey(priv);
|
||||
return {
|
||||
privkey: priv,
|
||||
pubkey: pub
|
||||
@ -11,5 +11,5 @@ export function genKeys() {
|
||||
}
|
||||
|
||||
export function sharedKey(priv, pub) {
|
||||
return x25519.getSharedSecret(priv, pub);
|
||||
return nobleCurves.x25519.getSharedSecret(priv, pub);
|
||||
}
|
||||
|
@ -6,40 +6,40 @@ router
|
||||
.route("/")
|
||||
.get(mainController.root);
|
||||
|
||||
router
|
||||
.route("/style.css")
|
||||
.get(mainController.style);
|
||||
|
||||
router
|
||||
.route("/script.js")
|
||||
.get(mainController.script);
|
||||
|
||||
router
|
||||
.route("/ecc.js")
|
||||
.get(mainController.ecc);
|
||||
|
||||
router
|
||||
.route("/ecdh.js")
|
||||
.get(mainController.ecdh);
|
||||
|
||||
router
|
||||
.route("/popups.js")
|
||||
.get(mainController.popups);
|
||||
|
||||
router
|
||||
.route("/chat.js")
|
||||
.get(mainController.chat);
|
||||
|
||||
router
|
||||
.route("/register.js")
|
||||
.get(mainController.register);
|
||||
|
||||
router
|
||||
.route("/pubkey.js")
|
||||
.get(mainController.pubkey);
|
||||
|
||||
router
|
||||
.route("/registertext.js")
|
||||
.get(mainController.registertext);
|
||||
// router
|
||||
// .route("/style.css")
|
||||
// .get(mainController.style);
|
||||
//
|
||||
// router
|
||||
// .route("/script.js")
|
||||
// .get(mainController.script);
|
||||
//
|
||||
// router
|
||||
// .route("/ecc.js")
|
||||
// .get(mainController.ecc);
|
||||
//
|
||||
// router
|
||||
// .route("/ecdh.js")
|
||||
// .get(mainController.ecdh);
|
||||
//
|
||||
// router
|
||||
// .route("/popups.js")
|
||||
// .get(mainController.popups);
|
||||
//
|
||||
// router
|
||||
// .route("/chat.js")
|
||||
// .get(mainController.chat);
|
||||
//
|
||||
// router
|
||||
// .route("/register.js")
|
||||
// .get(mainController.register);
|
||||
//
|
||||
// router
|
||||
// .route("/pubkey.js")
|
||||
// .get(mainController.pubkey);
|
||||
//
|
||||
// router
|
||||
// .route("/registertext.js")
|
||||
// .get(mainController.registertext);
|
||||
|
||||
module.exports = router;
|
||||
|
@ -10,8 +10,9 @@ html(lang="en-US")
|
||||
script(type="module", src="/ecc.js", defer)
|
||||
if isLoggedIn
|
||||
script(src="/chat.js", defer)
|
||||
script(src="/ecdh.js", defer)
|
||||
script(src="/pubkey.js", defer)
|
||||
script(src="/noble-curves.js", defer)
|
||||
script(type="module", src="/ecdh.js", defer)
|
||||
else
|
||||
script(type="module", src="/popups.js", defer)
|
||||
script(type="module", src="/register.js", defer)
|
||||
|
Reference in New Issue
Block a user