サンプル
crypto-common 0.2.2: crypto_common::BlockSizeUser
検証済みサンプル — cargo crypto-common 0.2.2: crypto_common::BlockSizeUser. rust 1 · linux alpine/x64 · docker で contract を実行し、成功しました.
sha256:9efabef4bf54a57e573f350072c191ee8a274470f6b5b32029a0d690d0bd15ea
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
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());
}
オリジンシーダー
匿名