샘플
crypto-common 0.2.2: crypto_common::BlockSizeUser
검증된 샘플 — cargo crypto-common 0.2.2: crypto_common::BlockSizeUser. rust 1 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: Implementing BlockSizeUser with…
sha256:9efabef4bf54a57e573f350072c191ee8a274470f6b5b32029a0d690d0bd15ea
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
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-11-12 |
케이스
HOW- 목표
- verify crypto_common::BlockSizeUser in pkg:cargo/crypto-common@0.2.2
- 심벌
-
- crypto_common::BlockSizeUser
- 생성일
- 2026-11-12T06:05:10Z
컨트랙트
- Implementing BlockSizeUser with a typenum ArraySize sets BlockSize::USIZE and returns the byte count from block_size() via static dispatch (BlockSizeUser is not dyn-compatible because block_size has no self receiver)
- Block<B> constructs a fixed-size hybrid_array::Array<u8, B::BlockSize> matching B::block_size() and rejects mismatched slice lengths in TryFrom<&[u8]>
- Blanket BlockSizeUser implementations for &T and &mut T preserve T::BlockSize across shared, mutable, and owned generic callers
- AddBlockSize, SubBlockSize, and ParBlocksSizeUser compose type-level block sizes from BlockSizeUser::BlockSize
파일
- 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 = "crypto-common"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453"
dependencies = [
"hybrid-array",
]
[[package]]
name = "hybrid-array"
version = "0.4.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17"
dependencies = [
"typenum",
]
[[package]]
name = "sample-crypto-common-block-size-user"
version = "1.0.0"
dependencies = [
"crypto-common",
]
[[package]]
name = "typenum"
version = "1.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
[package]
name = "sample-crypto-common-block-size-user"
version = "1.0.0"
edition = "2021"
publish = false
[dependencies]
crypto-common = "=0.2.2"
[[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 crypto_common::BlockSizeUser in pkg:cargo/crypto-common@0.2.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/crypto-common@0.2.2
Demonstrate these symbols/APIs:
- crypto_common::BlockSizeUser
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:d31fedf0724e2b66f1ec074a61938d53d31e00854d03ce84437d5ee255e478bc","contract":["Implementing BlockSizeUser with a typenum ArraySize sets BlockSize::USIZE and returns the byte count from block_size() via static dispatch (BlockSizeUser is not dyn-compatible because block_size has no self receiver)","Block\u003cB\u003e constructs a fixed-size hybrid_array::Array\u003cu8, B::BlockSize\u003e matching B::block_size() and rejects mismatched slice lengths in TryFrom\u003c\u0026[u8]\u003e","Blanket BlockSizeUser implementations for \u0026T and \u0026mut T preserve T::BlockSize across shared, mutable, and owned generic callers","AddBlockSize, SubBlockSize, and ParBlocksSizeUser compose type-level block sizes from BlockSizeUser::BlockSize"],"goal":"verify crypto_common::BlockSizeUser in pkg:cargo/crypto-common@0.2.2","kind":"HOW","packages":["pkg:cargo/crypto-common@0.2.2"],"schemaVersion":1,"symbols":["crypto_common::BlockSizeUser"]},"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/crypto-common@0.2.2"],"schemaVersion":1,"subject":"pkg:cargo/crypto-common@0.2.2","symbols":["crypto_common::BlockSizeUser"],"verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify crypto_common::BlockSizeUser in pkg:cargo/crypto-common@0.2.2",
"kind": "HOW",
"packages": [
"pkg:cargo/crypto-common@0.2.2"
],
"symbols": [
"crypto_common::BlockSizeUser"
]
}
//! Minimal verification library for `crypto_common::BlockSizeUser`.
pub use crypto_common::BlockSizeUser;
use crypto_common::{
AddBlockSize, Block, BlockSizeUser, ParBlocks, ParBlocksSizeUser, SubBlockSize,
typenum::{U4, U8, U16, U24, U64, Unsigned},
};
struct BlockCipher128;
impl BlockSizeUser for BlockCipher128 {
type BlockSize = U16;
}
impl ParBlocksSizeUser for BlockCipher128 {
type ParBlocksSize = U4;
}
struct BlockHash512;
impl BlockSizeUser for BlockHash512 {
type BlockSize = U64;
}
fn mask_block<B: BlockSizeUser>(_processor: B, block: &mut Block<B>, mask: u8) -> usize {
for byte in block.as_mut_slice() {
*byte ^= mask;
}
B::block_size()
}
fn main() {
// 1. Implementing BlockSizeUser defines BlockSize (ArraySize) and derives block_size() via static dispatch
assert_eq!(BlockCipher128::block_size(), 16);
assert_eq!(<BlockCipher128 as BlockSizeUser>::BlockSize::USIZE, 16);
assert_eq!(BlockHash512::block_size(), 64);
assert_eq!(<BlockHash512 as BlockSizeUser>::BlockSize::USIZE, 64);
// 2. Block<B> allocates a fixed-size hybrid_array::Array<u8, B::BlockSize> with exact slice conversion
let mut block = Block::<BlockCipher128>::default();
assert_eq!(block.len(), BlockCipher128::block_size());
assert_eq!(block.as_slice(), &[0u8; 16]);
let sample_bytes = [0xA5u8; 16];
let borrowed_block =
<&Block<BlockCipher128>>::try_from(sample_bytes.as_slice()).expect("exact 16-byte slice");
assert_eq!(borrowed_block.as_slice(), &sample_bytes);
assert!(<&Block<BlockCipher128>>::try_from(&[0u8; 15][..]).is_err());
assert!(<&Block<BlockCipher128>>::try_from(&[0u8; 17][..]).is_err());
// 3. Blanket BlockSizeUser impls on &T and &mut T preserve BlockSize for generic static dispatch
assert_eq!(<&BlockCipher128 as BlockSizeUser>::block_size(), 16);
assert_eq!(<&mut BlockCipher128 as BlockSizeUser>::block_size(), 16);
assert_eq!(<&BlockHash512 as BlockSizeUser>::block_size(), 64);
let mut cipher = BlockCipher128;
assert_eq!(mask_block(&cipher, &mut block, 0x5A), 16);
assert_eq!(block.as_slice(), &[0x5Au8; 16]);
assert_eq!(mask_block(&mut cipher, &mut block, 0x5A), 16);
assert_eq!(block.as_slice(), &[0x00u8; 16]);
assert_eq!(mask_block(cipher, &mut block, 0xFF), 16);
assert_eq!(block.as_slice(), &[0xFFu8; 16]);
// 4. AddBlockSize, SubBlockSize, and ParBlocksSizeUser compose type-level sizes from BlockSizeUser
assert_eq!(<AddBlockSize<U8, BlockCipher128> as Unsigned>::USIZE, 24);
assert_eq!(<SubBlockSize<U24, BlockCipher128> as Unsigned>::USIZE, 8);
let par_blocks = ParBlocks::<BlockCipher128>::default();
assert_eq!(par_blocks.len(), 4);
assert_eq!(par_blocks[0].len(), BlockCipher128::block_size());
}
오리진 시더
익명