Verified Commit 0cb4e920 authored by Aral Balkan's avatar Aral Balkan
Browse files

Update to use the renamed secure-ephemeral-messaging-channel

parent 499dfc18
......@@ -31,12 +31,12 @@ const platform = require('platform')
const crypto = require('crypto')
const { EphemeralMessagingChannel } = require('@hypha/ephemeral-messaging-channel')
const { SecureEphemeralMessagingChannel } = require('@hypha/secure-ephemeral-messaging-channel')
// The secure ephemeral messaging channel will be initialised once the
// secret key used for symmetric encryption is derived (after the person
// has either signed up or signed in to their hypha.)
let ephemeralMessagingChannel
let secureEphemeralMessagingChannel
// App-specific
const { to_hex } = require('./lib/helpers')
......@@ -83,8 +83,8 @@ async function createDomain() {
}
// Create the secure ephemeral messaging channel
console.log('About to create secure ephemeral messaging channel with secret key', model.keys.ephemeralMessagingChannelSecretKey.toString('hex'))
ephemeralMessagingChannel = new EphemeralMessagingChannel(model.keys.ephemeralMessagingChannelSecretKey)
console.log('About to create secure ephemeral messaging channel with secret key', model.keys.secureEphemeralMessagingChannelSecretKey.toString('hex'))
secureEphemeralMessagingChannel = new SecureEphemeralMessagingChannel(model.keys.secureEphemeralMessagingChannelSecretKey)
// This is the origin node; pass in the write key also.
createDatabase(model.keys.nodeReadKey, model.keys.nodeWriteKey)
......@@ -117,7 +117,7 @@ async function joinExistingDomain(passphrase) {
model.keys = originalKeys
// Create the secure ephemeral messaging channel
ephemeralMessagingChannel = new EphemeralMessagingChannel(model.keys.ephemeralMessagingChannelSecretKey)
secureEphemeralMessagingChannel = new SecureEphemeralMessagingChannel(model.keys.secureEphemeralMessagingChannelSecretKey)
console.log(`About to create database with read key: ${originalKeys.nodeReadKeyInHex}`)
createDatabase(originalKeys.nodeReadKey)
......@@ -198,11 +198,11 @@ function generateKeys(passphrase, domain) {
// messaging channel from the secretSignKey (node write key).
const context = Buffer.from('ephemera')
// Note: sodium_malloc and memory locking are not supported in the browser.
const ephemeralMessagingChannelSecretKey = Buffer.alloc(sodium.crypto_secretbox_KEYBYTES)
sodium.crypto_kdf_derive_from_key(ephemeralMessagingChannelSecretKey, 1, context, nodeKeys.nodeWriteKey)
const secureEphemeralMessagingChannelSecretKey = Buffer.alloc(sodium.crypto_secretbox_KEYBYTES)
sodium.crypto_kdf_derive_from_key(secureEphemeralMessagingChannelSecretKey, 1, context, nodeKeys.nodeWriteKey)
nodeKeys.ephemeralMessagingChannelSecretKey = ephemeralMessagingChannelSecretKey
nodeKeys.ephemeralMessagingChannelSecretKeyInHex = ephemeralMessagingChannelSecretKey.toString('hex')
nodeKeys.secureEphemeralMessagingChannelSecretKey = secureEphemeralMessagingChannelSecretKey
nodeKeys.secureEphemeralMessagingChannelSecretKeyInHex = secureEphemeralMessagingChannelSecretKey.toString('hex')
resolve(nodeKeys)
})
......@@ -258,10 +258,10 @@ function createDatabase(readKey, writeKey = null) {
})
// Watch the database for ephemeral messages.
ephemeralMessagingChannel.addDatabase(db)
// ephemeralMessagingChannel.watchDat(db)
secureEphemeralMessagingChannel.addDatabase(db)
// secureEphemeralMessagingChannel.watchDat(db)
ephemeralMessagingChannel.on('message', (database, peer, message) => {
secureEphemeralMessagingChannel.on('message', (database, peer, message) => {
console.log('*** Ephemeral message received. ***')
console.log(`Peer.feed.key ${peer.feed.key.toString('hex')}, peer.feed.id ${peer.feed.id.toString('hex')} has sent a mesage on database with key and id ${database.key.toString('hex')} ${database.id.toString('hex')}`, message)
......@@ -297,7 +297,7 @@ function createDatabase(readKey, writeKey = null) {
})
ephemeralMessagingChannel.on('received-bad-message', (error, database, peer) => {
secureEphemeralMessagingChannel.on('received-bad-message', (error, database, peer) => {
console.log('!!! Emphemeral message: received bad message !!!', error, database, peer)
})
......@@ -349,7 +349,7 @@ function createDatabase(readKey, writeKey = null) {
// Why is this and what’s the encryption that we’re turning off here and what effects does this have on privacy and security? (TODO: investigate and file issue if necessary.)
encrypt: false,
live: true,
extensions: ['encrypted-ephemeral']
extensions: ['secure-ephemeral']
})
console.log('localStream', localStream)
......@@ -380,7 +380,7 @@ function createDatabase(readKey, writeKey = null) {
// Create the local replication stream.
const localReplicationStream = db.replicate({
live: true,
extensions: ['encrypted-ephemeral']
extensions: ['secure-ephemeral']
})
console.log('[[[ About to start replicating over webrtc. localReplicationStream.id = ]]]', localReplicationStream.id.toString('hex'))
......@@ -490,7 +490,7 @@ view.on('requestAuthorisation', () => {
}
const messageHash = createMessageHash(message)
ephemeralMessagingChannel.broadcast(model.db, message)
secureEphemeralMessagingChannel.broadcast(model.db, message)
ephemeralMessageHashes[messageHash] = true
console.log(`Broadcast message with hash ${messageHash}`)
......
......@@ -156,8 +156,8 @@
<legend>Symmetric encryption key for ephemeral messaging channel</legend>
<p>The ephemeral messaging channel (implemented as a Dat protocol extension) is symmetrically encrypted using this key derived from the passphrase (precisely: from the first 32 bytes of the Ed25519 secret key which is derived from the passphrase). The channel is currently used only for authorising new nodes for a single hypha. If we decide to implement ephemeral messaging between different hyphas/people, we will implement X25519 (see below).</p>
<div>
<label for='ephemeralMessagingChannelSecretKey'>Secret key:</label>
<input type='text' id='ephemeralMessagingChannelSecretKey' readonly>
<label for='secureEphemeralMessagingChannelSecretKey'>Secret key:</label>
<input type='text' id='secureEphemeralMessagingChannelSecretKey' readonly>
</div>
</fieldset>
......
......@@ -40,7 +40,7 @@ const errorsTextArea = document.getElementById('errors')
const publicSigningKeyTextField = document.getElementById('publicSigningKey')
const localReadKeyTextField = document.getElementById('localReadKey')
const localWriteKeyTextField = document.getElementById('localWriteKey')
const ephemeralMessagingChannelSecretKeyTextField = document.getElementById('ephemeralMessagingChannelSecretKey')
const secureEphemeralMessagingChannelSecretKeyTextField = document.getElementById('secureEphemeralMessagingChannelSecretKey')
const privateSigningKeyTextArea = document.getElementById('privateSigningKey')
const publicEncryptionKeyTextField = document.getElementById('publicEncryptionKey')
const privateEncryptionKeyTextField = document.getElementById('privateEncryptionKey')
......@@ -281,7 +281,7 @@ class View extends EventEmitter {
privateEncryptionKeyTextField.value = this.model.keys.privateEncryptionKeyInHex
localReadKeyTextField.value = this.model.keys.localReadKeyInHex
localWriteKeyTextField.value = this.model.keys.localWriteKeyInHex
ephemeralMessagingChannelSecretKeyTextField.value = this.model.keys.ephemeralMessagingChannelSecretKeyInHex
secureEphemeralMessagingChannelSecretKeyTextField.value = this.model.keys.secureEphemeralMessagingChannelSecretKeyInHex
}
......
......@@ -219,9 +219,9 @@
"utp-native": "^2.0.1"
}
},
"@hypha/ephemeral-messaging-channel": {
"version": "git+https://git@source.ind.ie/hypha/ephemeral-messaging-channel.git#f53fbf92959cdb121dde39ea6e8774ee444939eb",
"from": "git+https://git@source.ind.ie/hypha/ephemeral-messaging-channel.git",
"@hypha/secure-ephemeral-messaging-channel": {
"version": "git+https://git@source.ind.ie/hypha/secure-ephemeral-messaging-channel.git#ea3e5132affeda8aa9af6e79c5e0c9f535c13305",
"from": "git+https://git@source.ind.ie/hypha/secure-ephemeral-messaging-channel.git",
"requires": {
"protocol-buffers-encodings": "^1.1.0",
"sodium-universal": "^2.0.0"
......
......@@ -19,7 +19,7 @@
"author": "Aral Balkan",
"license": "AGPL-3.0-or-later",
"dependencies": {
"@hypha/ephemeral-messaging-channel": "git+https://git@source.ind.ie/hypha/ephemeral-messaging-channel.git",
"@hypha/secure-ephemeral-messaging-channel": "git+https://git@source.ind.ie/hypha/secure-ephemeral-messaging-channel.git",
"@babel/core": "^7.2.2",
"@hyperswarm/network": "0.0.4",
"babelify": "^10.0.0",
......
......@@ -22,8 +22,8 @@ const router = express.Router()
const hyperdbs = {}
// TODO: Create unprivileged relay functionality.
// const { EphemeralMessagingChannel } = require('@hypha/ephameral-messaging-channel')
// const ephemeralMessagingChannel = new ephemeralMessagingChannel()
// const { SecureEphemeralMessagingChannel } = require('@hypha/ephameral-messaging-channel')
// const secureEphemeralMessagingChannel = new SecureEphemeralMessagingChannel()
// Create secure signalhub server.
const signalHub = signalHubServer({
......@@ -115,9 +115,9 @@ server.on('connect', (event) => {
// Join the ephemeral messaging channel on this database.
// Watch the database for ephemeral messages.
// ephemeralMessagingChannel.watchDat(db)
// secureEphemeralMessagingChannel.watchDat(db)
// ephemeralMessagingChannel.on('message', (database, peer, {contentType, payload}) => {
// secureEphemeralMessagingChannel.on('message', (database, peer, {contentType, payload}) => {
// // TODO: Once the ephemeral messaging channel is encrypted, all we
// // will be doing on the always-on node is to relay received messages to the
......@@ -136,10 +136,10 @@ server.on('connect', (event) => {
// // Relay the message back to the database (so that it is sent to other web nodes
// // via WebSocket and other native nodes over TCP).
// // Note (todo): also, we should probably not broadcast this to all nodes but only to known writers.
// ephemeralMessagingChannel.broadcast(db, {contentType, payload})
// secureEphemeralMessagingChannel.broadcast(db, {contentType, payload})
// })
// ephemeralMessagingChannel.on('received-bad-message', (error, database, peer, messageBuffer) => {
// secureEphemeralMessagingChannel.on('received-bad-message', (error, database, peer, messageBuffer) => {
// console.log('!!! Emphemeral message: received bad message !!!')
// console.log(`Peer.feed.key: ${peer.feed.key.toString('hex')}, peer.feed.id ${peer.feed.id.toString('hex')}, database: ${database}, message buffer: ${messageBuffer}`, error)
// })
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment