Add Noise IK encrypted stream over Arti.
M3: framed Noise_IK_25519_ChaChaPoly_BLAKE2s on the onion pipe, QR-pinned identity proofs, plaintext only in sqlite. Live two_node send of hello wire.
This commit is contained in:
parent
4fb4648552
commit
a2dfe3b2b8
12 changed files with 1208 additions and 47 deletions
31
src/tui.rs
31
src/tui.rs
|
|
@ -1,14 +1,18 @@
|
|||
use std::io;
|
||||
|
||||
use rand::RngCore;
|
||||
use ratatui::crossterm::event::{self, Event, KeyCode, KeyEvent, KeyEventKind, KeyModifiers};
|
||||
use ratatui::layout::{Constraint, Layout};
|
||||
use ratatui::style::{Color, Style};
|
||||
use ratatui::widgets::{Block, Borders, List, ListItem, Paragraph, Wrap};
|
||||
use ratatui::{DefaultTerminal, Frame};
|
||||
|
||||
use crate::qr::{self, QrPayload};
|
||||
use crate::store::{Friend, Store};
|
||||
|
||||
pub fn fingerprint_mismatch_banner() -> &'static str {
|
||||
"fingerprint mismatch"
|
||||
}
|
||||
|
||||
pub fn run(store: Store) -> Result<(), String> {
|
||||
let mut app = App::new(store)?;
|
||||
let mut terminal = ratatui::init();
|
||||
|
|
@ -25,6 +29,8 @@ struct App {
|
|||
me_fp: String,
|
||||
me_onion: String,
|
||||
identity_sk: Vec<u8>,
|
||||
prekey_pk: Vec<u8>,
|
||||
alert: Option<String>,
|
||||
}
|
||||
|
||||
enum Screen {
|
||||
|
|
@ -47,6 +53,8 @@ impl App {
|
|||
me_fp: to_hex(&me.identity_pk),
|
||||
me_onion: me.onion,
|
||||
identity_sk: me.identity_sk,
|
||||
prekey_pk: me.prekey_pk,
|
||||
alert: None,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -126,14 +134,13 @@ impl App {
|
|||
}
|
||||
|
||||
fn open_share(&mut self) -> Result<(), String> {
|
||||
let mut spk = [0u8; 32];
|
||||
rand::rngs::OsRng.fill_bytes(&mut spk);
|
||||
let onion = if self.me_onion.is_empty() {
|
||||
"unset"
|
||||
} else {
|
||||
self.me_onion.as_str()
|
||||
};
|
||||
let payload = qr::encode(&self.identity_sk, onion, &spk).map_err(|e| e.to_string())?;
|
||||
let payload =
|
||||
qr::encode(&self.identity_sk, onion, &self.prekey_pk).map_err(|e| e.to_string())?;
|
||||
let art = qr::render_unicode(&payload).map_err(|e| e.to_string())?;
|
||||
self.screen = Screen::Share { art, payload };
|
||||
Ok(())
|
||||
|
|
@ -167,6 +174,9 @@ impl App {
|
|||
self.store
|
||||
.upsert_friend(&payload.pubkey, &payload.onion, None)
|
||||
.map_err(|e| e.to_string())?;
|
||||
self.store
|
||||
.set_friend_prekey(&payload.pubkey, &payload.signed_prekey)
|
||||
.map_err(|e| e.to_string())?;
|
||||
self.reload_friends()?;
|
||||
self.screen = Screen::Main;
|
||||
Ok(())
|
||||
|
|
@ -195,8 +205,19 @@ impl App {
|
|||
fn draw_main(&self, f: &mut Frame) {
|
||||
let area = f.area();
|
||||
let cols = Layout::vertical([Constraint::Min(1), Constraint::Length(1)]).split(area);
|
||||
let body = if self.alert.is_some() {
|
||||
Layout::vertical([Constraint::Length(1), Constraint::Min(1)]).split(cols[0])
|
||||
} else {
|
||||
Layout::vertical([Constraint::Length(0), Constraint::Min(1)]).split(cols[0])
|
||||
};
|
||||
if let Some(msg) = &self.alert {
|
||||
f.render_widget(
|
||||
Paragraph::new(msg.as_str()).style(Style::default().fg(Color::Red)),
|
||||
body[0],
|
||||
);
|
||||
}
|
||||
let panes =
|
||||
Layout::horizontal([Constraint::Percentage(36), Constraint::Min(10)]).split(cols[0]);
|
||||
Layout::horizontal([Constraint::Percentage(36), Constraint::Min(10)]).split(body[1]);
|
||||
|
||||
let items: Vec<ListItem> = self
|
||||
.friends
|
||||
|
|
|
|||
Loading…
Reference in a new issue