this post was submitted on 10 Aug 2026
11 points (92.3% liked)

Rust

8239 readers
32 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 3 years ago
MODERATORS
 

IMPORTANT: i dont reccommend you read through my code here. feel free to reach out for clarity on the details.

id like to investigate about rewriting my "decentralized p2p encrypted messaging app" in Rust. if you are familiar with any of the details, id like to hear your opnions on the approach.

my project is complex and would carry a significant overhead to redo in Rust. the core reason behind investigating rust is that it has better tooling for things like formal-verification. in general it seems like a better language for a project like mine. as a webdev, it was easy enough for me to put together and while i can use things like tauri to build for native, i think dioxus's approach for a native build is good.

im aiming to create something fairly unique for "secure messaging". i created a prototype (without AI) for my project to share and discuss. it demonstrates the core-concept around client-side managed secure cryptography in javascript.

https://github.com/positive-intentions/chat

javascript doesnt have a great reputation in the cryptography communities and its always a struggle to promote, so it was important for it to be open source. im proud of the work there, but i see details i overlooked. this led me to creating a new version to fix the outstanding issues. (it was things like handling key-rotation, group-messaging, etc).

https://positive-intentions.com/blog/introducing-enkrypted-chat

the MVP version lacked things like unit-tests, while the second-iteration not only had unit-test, but armed with AI, i was able to do things like create audits and formal-verification. the whole project is absurdly complicated and not worth your time to review. things like audits and formal-proofs/verification are fundamentally invalid because i used AI to create it. the attempt is genuine and i found the process educational, but cybersecurity and cryptography is specialized and has countless nuances to consider. it isnt worth your time to debug my code.

i now i think the project could benefit from being rewritten in Rust. its a much more suitable and respected language for what im trying to do, but i have never used rust to do something of this scale. i expect it will carry a huge learning curve given my background as a webdev.

https://github.com/positive-intentions/whatsup

creating a webapp for me is easy enough, but my project relies on some core technologies which i want supported on all platforms consistently. some core things i need to consider:

  • webrtc - its the core data-channel for my project. im sure that as a webapp it can be done... it might be a stretch to build a wasm to bridge to JS if nessesary, but im sure it can work. i would also like rust to build for other architectures. i think the support is also reasonable for the native build, but i wonder it there could be issues for a CLI version.
  • Module federation - in the browser-based version im using module-federation and its working as exected. it particularly helps to separate functionality, which is generally a good approach for a complex project. in Rust's cargo file, it seems i could add something like `foo_crate = { git = "https://github.com/MyOrg/foo/_crate"}`. that seems like it would also limit how i handle close-source details of the project
  • local-only storage - a core detail to my app is that it works p2p without registration. there are no databases of registered users. in a pwa i can use various forms of storage provided by the browser. i would like to use an approach that is consistent in rust to avoid bespoke code for different platforms (easier maintainance).\
  • ui framework - im using dioxus for far, but its largely AI slop... its could just as easily be leptos (im still investigating comparing the two)... but if i really think outside the box... i wonder how difficult it would be to use webcomponents from rust. i was working on a webcomponent framework and it would be interesting to seem if there would be a performance advantage to using something closer to vanillajs. webcomponents probably are not a good idea if i want better support between platforms.

maybe there are other details i should keep in mind? i think i will have to create multiple creates for things like UI components library and p2p-framework (similar to how i did it for the javascript version)

thanks for reading this far. have a nice day.

top 6 comments
sorted by: hot top controversial new old
[–] TehPers@beehaw.org 4 points 1 week ago (1 children)

id like to investigate about rewriting my "decentralized p2p encrypted messaging app" in Rust. if you are familiar with any of the details, id like to hear your opnions on the approach.

For learning purposes? If you actually intend to create a service people are supposed to use, then use something that already exists like Matrix or Signal. No encryption is secure if it isn't peer reviewed and extensively tested.

If it's just for personal learning, then that doesn't matter.

the core reason behind investigating rust is that it has better tooling for things like formal-verification.

You can do formal verification in any language, but it's mostly used for languages with certified compilers (and you'd have to use one of those compilers). For that, you'd want to look at something like Ferrocene, but that costs money.

Instead, the core reason behind using Rust should be the ability to use constant-time algorithms. This can help defend against timing attacks.

Rust also has a great crypto ecosystem, so a lot of the tools you'll want are already built for you. Use them.

things like audits and formal-proofs/verification are fundamentally invalid because i used AI to create it.

Correct. An audit depends on someone's reputation, and formal verification requires review.


Anyway, learning Rust will take some time. For backend, the ecosystem goto is usually axum, and Rust has a built-in TCP client/server but you might want to see what tokio offers if you're using async.

[–] xoron@programming.dev 1 points 1 week ago

Thanks for tips! i really appriciate the thoughts and advice. id like to drill into the feedback further.

For learning purposes?

sure. as would be the persuit of creating anything worthwhile. i consider myself an expert in javascript. there are countless learnings i had in the approach when i was working with js. rust certainly carries a learning overhead to pull of properly.

use something that already exists like Matrix or Signal

agreed. my project isnt at all compable or as stable as those tried-and-tested implementation. my project is far from comparable, but its not for lack of trying. the key detail that sets this apart from all other apps is the browser based client-side philosophy. no need to install anything. your ID is crypto-random and so the app doesnt need to rely on any central registration system like phone numbers. your ID is unguessable and to connect to someone, you have to explicitly share it. webrtc has other nuances like being to route through a shared network for secure/faster transfer. my approach to "secure messaging" in this project is fundamentally different to signal and matrix and has tradeoffs and capabilities that make a direct comparison nuanced.

No encryption is secure if it isn’t peer reviewed and extensively tested

correct. i am also looking to create something people can use. youre not the first to advise things like peer-review, but its also important to have context?/perspective?. as a unfunded-side-project, things like third-party audit are prohibitively expensive. the best i can offer is to mention the caveats (as is the first thing mentioned in the post and throughout my documentation). its clear and understandable nobody is going to take their own time to review my code/docs. i have tried for various open source funding/grants... all rejections. Kerkhoff's principles are met, but its clearly too specialized and complicated to review for most... again, its not for lack of trying.

You can do formal verification in any language

i was previsouly investigating what could be done in JS. i couldnt find anything that i liked. perhaps you have any suggestions? i wanted to avoid creating AI-slop to address this and so i though rust would be more suitable with existing "reasonably mature" tooling. i was separately working on the signal-protocol, where i added things like formal-verification... it seems to work well, but there is a bit of a diconnect when bridging js to wasm... and thus this approach for a more pure rust approach. thanks for pointing me to Ferrocene. i'll take a look. note: im aiming to avoid costs where possible.

This can help defend against timing attacks.

the signal-protocol there aims to address this, like all of my projects, it lacks third-part reviews, but i hope its comprehensively documented (https://positive-intentions.com/docs/technical/p2p-signal-protocol/). there is an unfortunate AI-stink to it that is difficult to remove from my docs, but i hope it doesnt come across as low-effort. i remember the days before AI. without it, i wouldnt be creating docs. i would still encourage you to ask me for clarity on details instead of wasting your time on the docs.

Rust also has a great crypto ecosystem

yes. it was needed for the signal protocol because i needed certain primitives that were not provided by the browser.

thanks again for all the advice. i really appriciate it. id like to avoid having a backend as part of the "philosophy" of the app. it revolves around a webrtc connection and local-only storage.

[–] INeedMana@piefed.zip 2 points 1 week ago (1 children)

I'm not an expert on Rust nor webdev but maybe wasm (I just picked a result that seemed worthwhile. IDK how much up-to-date this is) is the thing for you to explore?

[–] trem@lemmy.blahaj.zone 3 points 1 week ago

The GUI frameworks that OP mentions, Dioxus and Leptos, use WebAssembly under the hood.

Was interesting to skim through that article, though. I've been building WebAssembly GUIs for 3 years now and I'm only superficially aware of the described steps, because the frameworks abstract all that gubbins away for you. 😅

[–] trem@lemmy.blahaj.zone 2 points 1 week ago (1 children)

Have you considered just rewriting the cryptography parts in Rust and calling those from JavaScript? In the projects I've seen so far, it was always possible to move the cryptography stuff into a standalone library.
And then with a WebAssembly wrapper, you could call that from JS: https://opensource.com/article/19/3/calling-rust-javascript

Don't get me wrong, I'm a big fan of Rust. I also think the WebAssembly GUI frameworks are cool. But at this point in time, I'd say they're cool for people who don't want to write JS.
If you're happy with JS, then the ecosystem of web component libraries will very likely make you more productive than you'll be with Dioxus or Leptos.

[–] xoron@programming.dev 1 points 1 week ago* (last edited 1 week ago)

Thanks. Ive started doing that. With the signal protocol. https://github.com/positive-intentions/signal-protocol

I have a demo of the JavaScript version. The UI there is reasonably mature. https://ui.positive-intentions.com/ . Tauri would be good to package it up into a native app with a web-view, the rust approach would allow for a better native build. I see that native build is only about a couple megabytes (in contrast to a whole functional web-view as the base).

I wonder if there could be architectural benefits to having it all in rust. In particular I'm interested in the idea of "end-to-end formal verification" (I just made that term up. Not sure how to describe it).