summaryrefslogtreecommitdiff
path: root/crates/chat-crypto/src/main.rs
diff options
context:
space:
mode:
authorDoan Luu Duc Tai <doan@luuduct.ai>2026-10-30 21:39:57 -0500
committerDoan Luu Duc Tai <doan@luuduct.ai>2026-10-30 21:39:57 -0500
commite6b350a1d48ca0490b7a3447bb8d0a4235514b76 (patch)
tree57ae2a9c5455f335e8c34b293f4f13975cb3d09e /crates/chat-crypto/src/main.rs
parent0a4da3b86eb69f0f09b802a55e36fa9cf1bbf38c (diff)
Implement experimental file-based encrypted private chat
Add fixed-suite Rust/WASI identity files, signed challenge authentication, ciphertext-only SQLite storage, a minimal LibreJS-compatible interface, and consistent backup snapshots. Keep production unchanged and document the local workflow, limits, source distribution, and browser recovery tests.
Diffstat (limited to 'crates/chat-crypto/src/main.rs')
-rw-r--r--crates/chat-crypto/src/main.rs18
1 files changed, 15 insertions, 3 deletions
diff --git a/crates/chat-crypto/src/main.rs b/crates/chat-crypto/src/main.rs
index b6749cf..9ecfe22 100644
--- a/crates/chat-crypto/src/main.rs
+++ b/crates/chat-crypto/src/main.rs
@@ -13,11 +13,23 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
-#![doc = "Command entry point for the isolated cryptographic compatibility probe."]
+#![doc = "Isolated WASI command entry point for chat cryptography."]
-use std::io::{self, Write};
+use std::io::{self, Read, Write};
fn main() -> io::Result<()> {
- let result = stack_chat_crypto::compatibility_probe().map_err(io::Error::other)?;
+ let mut request = zeroize::Zeroizing::new(String::new());
+ io::stdin()
+ .lock()
+ .take(8_388_609)
+ .read_to_string(&mut request)?;
+ let result = if request.is_empty() {
+ stack_chat_crypto::compatibility_probe().map_err(io::Error::other)?
+ } else {
+ match stack_chat_crypto::dispatch(&request) {
+ Ok(output) => output,
+ Err(error) => serde_json::to_string(&serde_json::json!({"error":error}))?,
+ }
+ };
writeln!(io::stdout().lock(), "{result}")
}