CodeSampleX

Sample

rand_chacha 0.9.0: rand_chacha::rand_core::SeedableRng

Verified sample for cargo rand_chacha 0.9.0: rand_chacha::rand_core::SeedableRng. The contract ran on rust 1 · linux alpine/x64 · docker and passed.

sha256:7b11187634c1fbf0b650b8ab4f33d7eaa9285c4466ea20b4feb355f518a95fa4

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment linux · alpine · musl x64 cargo

Verification-run environments

Environment Contract Stages Run
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-10-10

Case

HOW
Goal
verify rand_chacha::rand_core::SeedableRng in pkg:cargo/rand_chacha@0.9.0
Packages
Symbols
  • rand_chacha::rand_core::SeedableRng
Created
2026-10-10T16:54:08Z

Contract

  1. ChaCha20Rng implements SeedableRng and produces identical stream given identical seed
  2. SeedableRng::seed_from_u64 deterministically seeds ChaCha12Rng from a u64 value
  3. SeedableRng::from_rng seeds a new ChaCha8Rng generator from an existing RNG instance
  4. ChaCha20Rng initialized with different seeds produces distinct outputs

Files

  • Cargo.lock
  • Cargo.toml
  • PROMPT.md
  • csx.json
  • spec.json
  • src/lib.rs
  • test/contract.rs

Download the source artifact (tar.gz)

Source

Cargo.lock
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4

[[package]]
name = "cfg-if"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"

[[package]]
name = "getrandom"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
dependencies = [
 "cfg-if",
 "libc",
 "r-efi",
 "wasip2",
]

[[package]]
name = "libc"
version = "0.2.190"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce5d3ddc6d3fa000eb1536d85e147bfe31aacaba692ed6a876f95cb7c855be78"

[[package]]
name = "ppv-lite86"
version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
dependencies = [
 "zerocopy",
]

[[package]]
name = "proc-macro2"
version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
dependencies = [
 "unicode-ident",
]

[[package]]
name = "quote"
version = "1.0.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
dependencies = [
 "proc-macro2",
]

[[package]]
name = "r-efi"
version = "5.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"

[[package]]
name = "rand_chacha"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
dependencies = [
 "ppv-lite86",
 "rand_core",
]

[[package]]
name = "rand_core"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c"
dependencies = [
 "getrandom",
]

[[package]]
name = "sample-rand-chacha"
version = "1.0.0"
dependencies = [
 "rand_chacha",
]

[[package]]
name = "syn"
version = "2.0.119"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
dependencies = [
 "proc-macro2",
 "quote",
 "unicode-ident",
]

[[package]]
name = "unicode-ident"
version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954"

[[package]]
name = "wasip2"
version = "1.0.4+wasi-0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487"
dependencies = [
 "wit-bindgen",
]

[[package]]
name = "wit-bindgen"
version = "0.57.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e"

[[package]]
name = "zerocopy"
version = "0.8.62"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86502bf56ac7c77571a32e2647bb2a15894565e981fb2a48d7bde2d91c965a9d"
dependencies = [
 "zerocopy-derive",
]

[[package]]
name = "zerocopy-derive"
version = "0.8.62"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5457206954b06561e2608c7e19cf58b1926586d999c246eebe4502f7e2039d1a"
dependencies = [
 "proc-macro2",
 "quote",
 "syn",
]
Cargo.toml
[package]
name = "sample-rand-chacha"
version = "1.0.0"
edition = "2021"
publish = false

[dependencies]
rand_chacha = "=0.9.0"

[[bin]]
name = "contract"
path = "test/contract.rs"
PROMPT.md
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 rand_chacha::rand_core::SeedableRng in pkg:cargo/rand_chacha@0.9.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:cargo/rand_chacha@0.9.0
Demonstrate these symbols/APIs:
  - rand_chacha::rand_core::SeedableRng

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.
csx.json
{"case":{"caseId":"case:sha256:f655f74a14887e6b298dd59203d357df15cfd250eec70e519968f9a98cd8ae39","contract":["ChaCha20Rng implements SeedableRng and produces identical stream given identical seed","SeedableRng::seed_from_u64 deterministically seeds ChaCha12Rng from a u64 value","SeedableRng::from_rng seeds a new ChaCha8Rng generator from an existing RNG instance","ChaCha20Rng initialized with different seeds produces distinct outputs"],"goal":"verify rand_chacha::rand_core::SeedableRng in pkg:cargo/rand_chacha@0.9.0","kind":"HOW","packages":["pkg:cargo/rand_chacha@0.9.0"],"schemaVersion":1,"symbols":["rand_chacha::rand_core::SeedableRng"]},"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_chacha@0.9.0"],"schemaVersion":1,"subject":"pkg:cargo/rand_chacha@0.9.0","symbols":["rand_chacha::rand_core::SeedableRng"],"verifierAdapter":"cargo@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify rand_chacha::rand_core::SeedableRng in pkg:cargo/rand_chacha@0.9.0",
  "kind": "HOW",
  "packages": [
    "pkg:cargo/rand_chacha@0.9.0"
  ],
  "symbols": [
    "rand_chacha::rand_core::SeedableRng"
  ]
}
src/lib.rs
//! Clean-room verification sample for rand_chacha.

pub use rand_chacha::*;
test/contract.rs
use rand_chacha::rand_core::{RngCore, SeedableRng};
use rand_chacha::{ChaCha8Rng, ChaCha12Rng, ChaCha20Rng};

fn main() {
    // 1. ChaCha20Rng implements SeedableRng and produces identical stream given identical seed
    let seed: <ChaCha20Rng as SeedableRng>::Seed = [42u8; 32];
    let mut rng1 = ChaCha20Rng::from_seed(seed);
    let mut rng2 = ChaCha20Rng::from_seed(seed);
    assert_eq!(rng1.next_u64(), rng2.next_u64());
    assert_eq!(rng1.next_u32(), rng2.next_u32());

    // 2. SeedableRng::seed_from_u64 deterministically seeds ChaCha12Rng from a u64 value
    let mut rng12_a = ChaCha12Rng::seed_from_u64(100);
    let mut rng12_b = ChaCha12Rng::seed_from_u64(100);
    assert_eq!(rng12_a.next_u32(), rng12_b.next_u32());
    assert_eq!(rng12_a.next_u64(), rng12_b.next_u64());

    // 3. SeedableRng::from_rng seeds a new ChaCha8Rng generator from an existing RNG instance
    let mut source_rng = ChaCha20Rng::seed_from_u64(999);
    let mut derived_rng = ChaCha8Rng::from_rng(&mut source_rng);
    assert_ne!(derived_rng.next_u64(), source_rng.next_u64());

    // 4. ChaCha20Rng initialized with different seeds produces distinct outputs
    let other_seed: <ChaCha20Rng as SeedableRng>::Seed = [99u8; 32];
    let mut rng3 = ChaCha20Rng::from_seed(other_seed);
    assert_ne!(rng1.next_u64(), rng3.next_u64());

    println!("All rand_chacha::rand_core::SeedableRng contract assertions passed.");
}

Origin Seeder

anonymous