Skip to content

Commit f74f0db

Browse files
committed
fix(common): warn that JSON artifacts skip the format and version checks
The magic, format, major/minor, and per-field checks live in the binary header, so `read_json` accepts a downgraded or cross-field artifact and it fails much later in Fiat-Shamir transcript replay, with an error that points somewhere else. Warn on the JSON read path so nothing trusts an untagged artifact silently. Tagging JSON properly is a breaking schema change to the verifier-server `/verify` endpoint and the wasm package; tracked in #472.
1 parent ea79d1f commit f74f0db

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

  • provekit/common/src/file/io

provekit/common/src/file/io/mod.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use {
1818
anyhow::Result,
1919
serde::{Deserialize, Serialize},
2020
std::{ffi::OsStr, path::Path},
21-
tracing::instrument,
21+
tracing::{instrument, warn},
2222
};
2323

2424
/// Trait for structures that can be serialized to and deserialized from files.
@@ -65,10 +65,26 @@ fn write_bin_with_hash_config<T: FileFormat + MaybeHashAware>(
6565
}
6666

6767
/// Read a file with format determined from extension.
68+
///
69+
/// # Warning
70+
///
71+
/// JSON files carry no header, so reading one skips the format, version, and
72+
/// proof-field checks that the binary format performs. See the warning logged
73+
/// on that path.
6874
#[instrument()]
6975
pub fn read<T: FileFormat>(path: &Path) -> Result<T> {
7076
match path.extension().and_then(OsStr::to_str) {
71-
Some("json") => read_json(path),
77+
Some("json") => {
78+
warn!(
79+
"Reading a JSON artifact. JSON files carry no header, so the format, version, and \
80+
proof-field checks that the binary `.{ext}` format performs are all skipped \
81+
here. A file written by an incompatible ProveKit version, or for a different \
82+
proof field, is not rejected up front; it fails later during verification with \
83+
an error that does not name the real cause.",
84+
ext = T::EXTENSION
85+
);
86+
read_json(path)
87+
}
7288
Some(ext) if ext == T::EXTENSION => read_bin(path, T::FORMAT, T::VERSION),
7389
_ => Err(anyhow::anyhow!(
7490
"Unsupported file extension, please specify .{} or .json",

0 commit comments

Comments
 (0)