Allow toggling pfs in dev-mode

This commits allow users to toggle pfs in dev-mode (it is already used
for pairing and group chats).

Once enabled direct and public messages sent will only be received by
users running >= 0.9.32.

Also this does not guarantee PFS (both devices need to have it enabled
it), and there still some UX work to do to ensure that, but it is useful
for testing.

A warning is displayed explaining the limitations when enabling.
This commit is contained in:
Andrea Maria Piana 2018-12-21 09:32:56 +01:00
parent 2777809db9
commit ad99ed2a28
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
13 changed files with 56 additions and 20 deletions

2
.env
View File

@ -13,7 +13,7 @@ PAIRING_ENABLED=1
CACHED_WEBVIEWS_ENABLED=1
EXTENSIONS=1
HARDWALLET_ENABLED=0
PFS_ENCRYPTION_ENABLED=0
PFS_ENCRYPTION_ENABLED=1
DEV_BUILD=1
ERC20_CONTRACT_WARNINGS=1
MAILSERVER_CONFIRMATIONS_ENABLED=0

View File

@ -10,6 +10,6 @@ DEBUG_WEBVIEW=1
GROUP_CHATS_ENABLED=1
PAIRING_ENABLED=1
EXTENSIONS=1
PFS_ENCRYPTION_ENABLED=0
PFS_ENCRYPTION_ENABLED=1
ERC20_CONTRACT_WARNINGS=1
MAILSERVER_CONFIRMATIONS_ENABLED=0

View File

@ -12,7 +12,7 @@ GROUP_CHATS_ENABLED=1
MAINNET_WARNING_ENABLED=1
CACHED_WEBVIEWS_ENABLED=1
EXTENSIONS=1
PFS_ENCRYPTION_ENABLED=0
PFS_ENCRYPTION_ENABLED=1
PAIRING_ENABLED=1
ERC20_CONTRACT_WARNINGS=1
MAILSERVER_CONFIRMATIONS_ENABLED=0

View File

@ -12,6 +12,6 @@ GROUP_CHATS_ENABLED=1
PAIRING_ENABLED=1
MAINNET_WARNING_ENABLED=1
EXTENSIONS=1
PFS_ENCRYPTION_ENABLED=0
PFS_ENCRYPTION_ENABLED=1
ERC20_CONTRACT_WARNINGS=1
MAILSERVER_CONFIRMATIONS_ENABLED=0

View File

@ -11,6 +11,6 @@ PAIRING_ENABLED=1
GROUP_CHATS_ENABLED=1
MAINNET_WARNING_ENABLED=1
EXTENSIONS=1
PFS_ENCRYPTION_ENABLED=0
PFS_ENCRYPTION_ENABLED=1
ERC20_CONTRACT_WARNINGS=1
MAILSERVER_CONFIRMATIONS_ENABLED=0

View File

@ -13,5 +13,5 @@ GROUP_CHATS_ENABLED=1
PAIRING_ENABLED=1
MAINNET_WARNING_ENABLED=1
EXTENSIONS=1
PFS_ENCRYPTION_ENABLED=0
PFS_ENCRYPTION_ENABLED=1
ERC20_CONTRACT_WARNINGS=0

View File

@ -1 +1 @@
0.17.10-beta.1
181221-204011-e80de6

View File

@ -67,6 +67,16 @@
{:desktop-notifications? desktop-notifications?}
{}))
(fx/defn toggle-pfs [{:keys [db] :as cofx} enabled?]
(let [settings (get-in db [:account/account :settings])
warning {:utils/show-popup {:title (i18n/label :t/pfs-warning-title)
:content (i18n/label :t/pfs-warning-content)}}]
(fx/merge cofx
(when enabled? warning)
(accounts.update/update-settings (assoc settings :pfs? enabled?)
{}))))
(fx/defn switch-web3-opt-in-mode [{:keys [db] :as cofx} opt-in]
(let [settings (get-in db [:account/account :settings])]
(accounts.update/update-settings cofx

View File

@ -153,6 +153,11 @@
(fn [cofx [_ desktop-notifications?]]
(accounts/enable-notifications cofx desktop-notifications?)))
(handlers/register-handler-fx
:accounts.ui/toggle-pfs
(fn [cofx [_ enabled?]]
(accounts/toggle-pfs cofx enabled?)))
(handlers/register-handler-fx
:accounts.ui/web3-opt-in-mode-switched
(fn [cofx [_ opt-in]]

View File

@ -85,6 +85,7 @@
StatusMessage
(send [this chat-id {:keys [message-id] :as cofx}]
(let [dev-mode? (get-in cofx [:db :account/account :dev-mode?])
pfs? (get-in cofx [:db :account/account :settings :pfs?])
current-public-key (accounts.db/current-public-key cofx)
params {:chat-id chat-id
:payload this
@ -94,7 +95,7 @@
message-type]}]
(case message-type
:public-group-user-message
(if config/pfs-encryption-enabled?
(if pfs?
(send-public-message
cofx
chat-id
@ -103,7 +104,7 @@
(send-with-sym-key cofx params))
:user-message
(if config/pfs-encryption-enabled?
(if pfs?
(send-direct-message
cofx
chat-id
@ -133,13 +134,14 @@
(defrecord MessagesSeen [message-ids]
StatusMessage
(send [this chat-id cofx]
(if config/pfs-encryption-enabled?
(let [pfs? (get-in cofx [:db :account/account :settings :pfs?])]
(if pfs?
(send-direct-message cofx
chat-id
nil
this)
(send-with-pubkey cofx {:chat-id chat-id
:payload this})))
:payload this}))))
(receive [this chat-id signature _ cofx]
(chat/receive-seen cofx chat-id signature this))
(validate [this]

View File

@ -150,8 +150,8 @@
(i18n/label :t/send-logs)]]]]))
(views/defview advanced-settings []
(views/letsubs [installations [:pairing/installations]
current-mailserver-id [:mailserver/current-id]
(views/letsubs [current-mailserver-id [:mailserver/current-id]
{:keys [settings]} [:account/account]
mailservers [:mailserver/fleet-mailservers]
mailserver-state [:mailserver/state]
node-status [:node-status]
@ -159,6 +159,7 @@
connection-stats [:connection-stats]
disconnected [:disconnected?]]
(let [render-fn (offline-messaging.views/render-row current-mailserver-id)
pfs? (:pfs? settings)
connection-message (connection-status peers-count node-status mailserver-state disconnected)]
[react/scroll-view
[react/text {:style styles/advanced-settings-title
@ -182,7 +183,15 @@
[render-fn mailserver]])]
[react/view {:style styles/title-separator}]
[react/text {:style styles/adv-settings-subtitle} (i18n/label :t/logging)]
[logging-display]])))
[logging-display]
[react/view {:style styles/title-separator}]
[react/text {:style styles/adv-settings-subtitle} (i18n/label :t/pfs)]
[react/view {:style (styles/profile-row false)}
[react/text {:style (styles/profile-row-text colors/black)} (i18n/label :notifications)]
[react/switch {:on-tint-color colors/blue
:value pfs?
:on-value-change #(re-frame/dispatch [:accounts.ui/toggle-pfs (not pfs?)])}]]])))
(views/defview installations []
(views/letsubs [installations [:pairing/installations]

View File

@ -196,6 +196,13 @@
{:label-kw :t/devices
:action-fn #(re-frame/dispatch [:navigate-to :installations])
:accessibility-label :pairing-settings-button}])
(when dev-mode?
[profile.components/settings-item-separator])
(when dev-mode?
[profile.components/settings-switch-item
{:label-kw :t/pfs
:value (:pfs? settings)
:action-fn #(re-frame/dispatch [:accounts.ui/toggle-pfs %])}])
[profile.components/settings-item-separator]
[profile.components/settings-switch-item
{:label-kw :t/dev-mode

View File

@ -23,6 +23,9 @@
"currency-display-name-tzs": "Tanzanian Shilling",
"currency-display-name-brl": "Brazil Real",
"mainnet-network": "Main network",
"pfs": "PFS Enabled",
"pfs-warning-title": "Warning, experimental feature",
"pfs-warning-content": "PFS support is still experimental, so use at your own risk.\nIf enabled, only users who are running 0.9.32 and higher will be able to read your direct and public messages. This does not guarantee PFS for all your messages yet, and it will only encrypt your messages, not the one you receive.",
"phone-national": "National",
"open-dapp": "Open ÐApp",
"new-transaction": "New Transaction",