Markdown shows whether its ENS signature holds when read #5

Merged
temeddix merged 2 commits from verify-on-read into main 2026-09-25 20:11:59 +00:00
Showing only changes of commit 283a666bff - Show all commits
+7 -1
View File
@@ -33,6 +33,9 @@ const MAX_CHUNK: u32 = 1024 * 1024;
/// plus 110 per byte, so a larger file would run out mid-call and leave the /// plus 110 per byte, so a larger file would run out mid-call and leave the
/// save's outcome unknown. It is refused up front instead. /// save's outcome unknown. It is refused up front instead.
const MAX_SIGNED: usize = 96 * 1024; const MAX_SIGNED: usize = 96 * 1024;
/// Room a save may carry beyond [`MAX_SIGNED`] before its verdict line is
/// dropped, so a file read back at the limit can be saved unedited.
const BADGE_ALLOWANCE: usize = 4 * 1024;
/// The largest Markdown file a read decorates with a verdict line. Memona /// The largest Markdown file a read decorates with a verdict line. Memona
/// opens files of at most one transfer, and a larger one streams through. /// opens files of at most one transfer, and a larger one streams through.
const MAX_DECORATED: usize = MAX_CHUNK as usize; const MAX_DECORATED: usize = MAX_CHUNK as usize;
@@ -270,7 +273,7 @@ impl GuestWriter for DavWriter {
return self.send(&data); return self.send(&data);
Outdated
Review

A stored Markdown file at the documented 96 KiB limit is rendered with the injected ens-verification line, so saving that unedited read-back exceeds this pre-strip limit and fails with Unsupported. Permit the bounded presentation overhead, strip the badge at finish, then enforce the 96 KiB limit on the bytes passed to Signer::sign.

Profile: codex · gpt-5.6-terra

A stored Markdown file at the documented 96 KiB limit is rendered with the injected `ens-verification` line, so saving that unedited read-back exceeds this pre-strip limit and fails with `Unsupported`. Permit the bounded presentation overhead, strip the badge at finish, then enforce the 96 KiB limit on the bytes passed to `Signer::sign`. > Profile: `codex` · `gpt-5.6-terra`
}; };
let mut markdown = markdown.borrow_mut(); let mut markdown = markdown.borrow_mut();
if markdown.len() + data.len() > MAX_SIGNED { if markdown.len() + data.len() > MAX_SIGNED + BADGE_ALLOWANCE {
return Err(ErrorCode::Unsupported); return Err(ErrorCode::Unsupported);
} }
markdown.extend_from_slice(&data); markdown.extend_from_slice(&data);
@@ -291,6 +294,9 @@ impl GuestWriter for DavWriter {
let text = let text =
std::str::from_utf8(&markdown).map_err(|_| ErrorCode::InvalidInput)?; std::str::from_utf8(&markdown).map_err(|_| ErrorCode::InvalidInput)?;
let stored = badge::strip(text); let stored = badge::strip(text);
if stored.len() > MAX_SIGNED {
return Err(ErrorCode::Unsupported);
}
let signed = session(|session| session.signer.sign(stored.as_bytes()))?; let signed = session(|session| session.signer.sign(stored.as_bytes()))?;
for piece in signed.chunks(MAX_CHUNK as usize) { for piece in signed.chunks(MAX_CHUNK as usize) {
self.send(piece)?; self.send(piece)?;