proofs.rs

Claim #2 — Verification of cesu8::from_java_cesu8 (with creusot 0.14.0)

cesu8::from_java_cesu8

Recorded callable · signature and safety not independently recorded.

Tool: creusot 0.14.0

This claim has no explanation of its own. Read the report Overview, and treat the formal statement below as authoritative. See Concepts and terminology.

Preconditions

true

Creusot specification

#[ensures(decoder_specs::decode_result(result, bytes@, true))]
pub fn from_java_cesu8(bytes: &[u8]) -> Result<Cow<str>, Cesu8DecodingError>

Source at recorded commit · Recorded check

Evidence

https://github.com/MasWag/crate-proofs/blob/f9520e749b2c55e0e79971385364bdcc3238b2c4/cesu8/1.1.0/creusot/src/lib.rs#L165-L192

What is trusted

From the report

The checks depend on Creusot's Rust and standard-library models and on the translation and provers. A local external contract assumes that str::as_bytes returns the concatenation of the ordinary UTF-8 encodings of the string's scalars. In particular, the whole-input UTF-8 validator is assumed to preserve the bytes on success and, on error, exclude every scalar sequence whose ordinary UTF-8 encoding equals the input; the conventional UTF-8 encoding of each scalar and injectivity of string encoding are also model assumptions. Slice, iterator, vector and Cow operations use their standard-library contracts. The fallback proves that its resulting bytes represent valid UTF-8 before the modeled unchecked string construction. The CESU-8 encoder and parser and their relation are checked, rather than assumed.

Technical limitations

From the report

The checked source is a verification copy adapted from the 1.1.0 release. Its encoder reconstructs a supplementary scalar from four UTF-8 bytes instead of calling .chars().next() on an unchecked four-byte string slice; compatibility scans are indexed, the width table is constant, and decoder token operations are factored into helpers. These changes address verification model limitations while retaining the decoder's whole-input dispatch and surrogate bit operations. A checked arithmetic lemma relates the capacity expressions on the modeled length domain. Separate finite native tests compare the copy with the release, including all byte strings of length at most two; an independent encoding oracle checks individual Unicode scalar encodings. They do not prove equivalence for all inputs: formal equivalence of the adapted copy to the published release remains unproved.

The functional contracts observe byte and scalar contents and Cow variants, not pointer identity, allocation behavior or allocator failure. They do not establish unconditional termination or whole-crate memory safety. Error formatting and diagnostic traits are outside the six selected public contracts.

Read and join the discussion on the report →