group chat message encryption

This commit is contained in:
michaelr 2016-03-10 12:32:24 +02:00
parent 7d1c1fa5c1
commit d5d781410f
9 changed files with 95 additions and 29419 deletions

View File

@ -1,4 +1,4 @@
(defproject syng-im/protocol "0.1.0"
(defproject syng-im/protocol "0.1.1"
:description "FIXME: write this!"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
@ -11,11 +11,12 @@
[org.clojure/core.async "0.2.374" :exclusions [org.clojure/tools.reader]]
[cljsjs/chance "0.7.3-0"]
[com.andrewmcveigh/cljs-time "0.4.0"]
[cljsjs/web3 "0.15.3-0"]]
[cljsjs/web3 "0.15.3-0"]
[cljsjs/eccjs "0.3.1-0"]]
:plugins [[lein-cljsbuild "1.1.2" :exclusions [[org.clojure/clojure]]]]
:source-paths ["src"]
:source-paths ["src/cljs"]
:clean-targets ^{:protect false} ["resources/public/js/compiled" "target"]

View File

@ -1,15 +1,28 @@
(ns syng-im.utils.encryption
(:require [cljsjs.chance]))
(:require [cljsjs.chance]
[cljsjs.eccjs]))
(def default-curve 384)
(defn new-keypair
"Returns {:private \"private key\" :public \"public key\""
[]
(let [random-fake (.guid js/chance)]
{:private random-fake
:public random-fake}))
(let [{:keys [enc dec]} (-> (.generate js/ecc (.-ENC_DEC js/ecc) default-curve)
(js->clj :keywordize-keys true))]
{:private dec
:public enc}))
(defn encrypt [public-key content]
content)
(.encrypt js/ecc public-key content))
(defn decrypt [private-key content]
content)
(.decrypt js/ecc private-key content))
(comment
(init)
(def keypair (new-keypair))
(def encd (encrypt (:public keypair) "Hello world"))
(decrypt (:private keypair) encd)
)

View File

@ -11,10 +11,13 @@
[org.clojure/core.async "0.2.374"
:exclusions [org.clojure/tools.reader]]
[com.cemerick/piggieback "0.2.1"]
;; comment for prod build
[cljsjs/chance "0.7.3-0"]
[cljsjs/web3 "0.15.3-0"]
[com.andrewmcveigh/cljs-time "0.4.0"]
;[syng-im/protocol "0.1.0"]
[cljsjs/eccjs "0.3.1-0"]
;; uncomment for prod build
;[syng-im/protocol "0.1.1"]
]
:plugins [[lein-figwheel "0.5.0-6"]

View File

@ -1,49 +1,75 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/style.css" rel="stylesheet" type="text/css">
<style type="text/css">
input[type=text] {
width: 530px;
margin-bottom: 5px;
}
label {
width: 80px;
display: inline-block;
}
</style>
</head>
<body>
<!--<div id="app">-->
<!--<h2>Figwheel template</h2>-->
<!--<p>Checkout your developer console.</p>-->
<!--</div>-->
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/style.css" rel="stylesheet" type="text/css">
<style type="text/css">
input[type=text] {
width: 530px;
margin-bottom: 5px;
}
label {
width: 80px;
display: inline-block;
}
#group-chat-container {
border-top: 20px solid lightblue;
}
</style>
</head>
<body>
<!--<div id="app">-->
<!--<h2>Figwheel template</h2>-->
<!--<p>Checkout your developer console.</p>-->
<!--</div>-->
<div>
<label for="rpc-url">RPC URL</label>
<input id="rpc-url" type="text" value="http://localhost:4546"/>
<button id="connect-button">Connect</button>
</div>
<div>
<div>
<label for="chat">Chat:</label>
</div>
<textarea id="chat" rows="20" cols="150"></textarea>
</div>
<div>
<label for="msg">Message:</label>
<input id="msg" type="text"/>
</div>
<div>
<label for="my-identity">My Identity</label>
<input id="my-identity" readonly=readonly type="text"/>
</div>
<div>
<label for="to-identity">To Identity</label>
<input id="to-identity" type="text"/>
</div>
<div id="group-chat-container">
<div>
<div>
<label for="rpc-url">RPC URL</label>
<input id="rpc-url" type="text" value="http://localhost:4546" />
<button id="connect-button">Connect</button>
<label for="group-chat">Group Chat:</label>
</div>
<textarea id="group-chat" rows="20" cols="150"></textarea>
</div>
<div>
<label for="group-msg">Message:</label>
<input id="group-msg" type="text"/>
</div>
<div>
<div>
<div>
<label for="chat">Chat:</label>
</div>
<textarea id="chat" rows="20" cols="150"></textarea>
<label for="to-identities">To Identities:</label>
</div>
<div>
<label for="msg">Message:</label>
<input id="msg" type="text" />
</div>
<div>
<label for="my-identity">My Identity</label>
<input id="my-identity" readonly=readonly type="text" />
</div>
<div>
<label for="to-identity">To Identity</label>
<input id="to-identity" type="text" />
</div>
<!--<script src="js/compiled/syng_im.js" type="text/javascript"></script>-->
<script src="js/compiled/app.js" type="text/javascript"></script>
</body>
<textarea id="to-identities" rows="5" cols="150"></textarea>
</div>
<div>
<button id="start-group-chat-button">Start Group Chat</button>
</div>
</div>
<script src="js/compiled/app.js" type="text/javascript"></script>
</body>
</html>

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long