Ejemplo
rand_core 0.9.5
Muestra verificada para cargo rand_core 0.9.5. El contrato se ejecutó en rust 1 · linux alpine/x64 · docker y pasó: RngCore next_u32 and next_u64 produce…
sha256:ab17eb7f08d5f435996186ca0224cb02dfefdc63b9e4973c8fa63a29663f3f4c
Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido.
Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas.
MIT-0
Evidencia de ejecución
El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.
- Base de evidencia
- Contrato firmado aprobado
- Recibos de verificación
- 1
- Claves de firma que lo compilaron
- 1
Entorno declarado
linux · alpine · musl x64 cargo
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| rust 1 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · cargo@1rust:1-alpine@sha256:a10e64dd139b… |
2026-09-19 |
Caso
HOW- Objetivo
- verify pkg:cargo/rand_core@0.9.5
- Paquetes
- Creado
- 2026-09-19T02:51:54Z
Contrato
- RngCore next_u32 and next_u64 produce expected sequential values
- RngCore fill_bytes populates buffer using helper
- SeedableRng seed_from_u64 initializes deterministic generator
- TryRngCore blanket implementation for RngCore provides infallible try_fill_bytes
- UnwrapMut wraps TryRngCore and reborrows correctly
Archivos
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/lib.rs
- test/contract.rs
Código fuente
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "rand_core"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c"
[[package]]
name = "sample-rand-core"
version = "1.0.0"
dependencies = [
"rand_core",
]
[package]
name = "sample-rand-core"
version = "1.0.0"
edition = "2021"
publish = false
[dependencies]
rand_core = "=0.9.5"
[[bin]]
name = "contract"
path = "test/contract.rs"
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify pkg:cargo/rand_core@0.9.5
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/rand_core@0.9.5
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:f6e294e43dc44e91501dbaa5f58f38a4c7f622c963b8924cf20166bdb1175ed9","contract":["RngCore next_u32 and next_u64 produce expected sequential values","RngCore fill_bytes populates buffer using helper","SeedableRng seed_from_u64 initializes deterministic generator","TryRngCore blanket implementation for RngCore provides infallible try_fill_bytes","UnwrapMut wraps TryRngCore and reborrows correctly"],"goal":"verify pkg:cargo/rand_core@0.9.5","kind":"HOW","packages":["pkg:cargo/rand_core@0.9.5"],"schemaVersion":1},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","distro":"alpine","ecosystem":"cargo","libc":"musl","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/rand_core@0.9.5"],"schemaVersion":1,"subject":"pkg:cargo/rand_core@0.9.5","verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify pkg:cargo/rand_core@0.9.5",
"kind": "HOW",
"packages": [
"pkg:cargo/rand_core@0.9.5"
]
}
//! Clean-room verification sample for rand_core.
pub use rand_core::*;
use rand_core::{RngCore, SeedableRng, TryRngCore, impls, le};
struct StepRng(u64);
impl RngCore for StepRng {
fn next_u32(&mut self) -> u32 {
self.next_u64() as u32
}
fn next_u64(&mut self) -> u64 {
let val = self.0;
self.0 = self.0.wrapping_add(1);
val
}
fn fill_bytes(&mut self, dst: &mut [u8]) {
impls::fill_bytes_via_next(self, dst);
}
}
struct SeedableNum(u64);
impl RngCore for SeedableNum {
fn next_u32(&mut self) -> u32 {
self.next_u64() as u32
}
fn next_u64(&mut self) -> u64 {
let val = self.0;
self.0 = self.0.wrapping_add(1);
val
}
fn fill_bytes(&mut self, dst: &mut [u8]) {
impls::fill_bytes_via_next(self, dst);
}
}
impl SeedableRng for SeedableNum {
type Seed = [u8; 8];
fn from_seed(seed: Self::Seed) -> Self {
let mut x = [0u64; 1];
le::read_u64_into(&seed, &mut x);
SeedableNum(x[0])
}
}
fn main() {
// 1. RngCore next_u32 and next_u64 produce expected sequential values
let mut rng = StepRng(100);
assert_eq!(rng.next_u64(), 100);
assert_eq!(rng.next_u64(), 101);
assert_eq!(rng.next_u32(), 102);
// 2. RngCore fill_bytes populates buffer using helper
let mut buf = [0u8; 8];
let mut rng2 = StepRng(1);
rng2.fill_bytes(&mut buf);
assert_eq!(buf, [1, 0, 0, 0, 0, 0, 0, 0]);
// 3. SeedableRng seed_from_u64 initializes deterministic generator
let mut seeded = SeedableNum::seed_from_u64(42);
let val1 = seeded.next_u64();
let mut seeded2 = SeedableNum::seed_from_u64(42);
let val2 = seeded2.next_u64();
assert_eq!(val1, val2);
// 4. TryRngCore blanket implementation for RngCore provides infallible try_fill_bytes
let mut try_buf = [0u8; 4];
let mut rng3 = StepRng(5);
assert!(rng3.try_fill_bytes(&mut try_buf).is_ok());
// 5. UnwrapMut wraps TryRngCore and reborrows correctly
let mut rng4 = StepRng(10);
let mut unwrapped = rng4.unwrap_mut();
assert_eq!(unwrapped.next_u64(), 10);
let mut reborrowed = unwrapped.re();
assert_eq!(reborrowed.next_u64(), 11);
println!("All rand_core contract assertions passed successfully.");
}
Seeder de origen
anónimo