샘플
rand_core 0.9.5
검증된 샘플 — cargo rand_core 0.9.5. rust 1 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: RngCore next_u32 and next_u64 produce expected sequential values
sha256:ab17eb7f08d5f435996186ca0224cb02dfefdc63b9e4973c8fa63a29663f3f4c
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux · alpine · musl x64 cargo
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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 |
케이스
HOW- 목표
- verify pkg:cargo/rand_core@0.9.5
- 패키지
- 생성일
- 2026-09-19T02:51:54Z
컨트랙트
- 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
파일
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/lib.rs
- test/contract.rs
소스
# 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.");
}
오리진 시더
익명