Realm

oa::crypto::hash

Module published by the oa::crypto module.

MdRust public API

Public Functions

pub fn keccak_f1600(input: &Matrix) -> Result<Matrix>
pub fn merkle_proofs(leaves: &Matrix, indices: &Matrix) -> Result<Matrix>
pub fn merkle_root(input: &Matrix) -> Result<Matrix>
pub fn poseidon2_babybear16( input: &Matrix, output_length: usize, ) -> Result<Matrix>
pub fn poseidon2_babybear16_permute(input: &Matrix) -> Result<Matrix>
pub fn poseidon2_babybear24( input: &Matrix, output_length: usize, ) -> Result<Matrix>
pub fn poseidon2_babybear24_permute(input: &Matrix) -> Result<Matrix>
pub fn poseidon2_koalabear16( input: &Matrix, output_length: usize, ) -> Result<Matrix>
pub fn poseidon2_koalabear16_permute(input: &Matrix) -> Result<Matrix>
pub fn poseidon2_koalabear24( input: &Matrix, output_length: usize, ) -> Result<Matrix>
pub fn poseidon2_koalabear24_permute(input: &Matrix) -> Result<Matrix>
pub fn sha224(input: &Matrix) -> Result<Matrix>
pub fn sha256(input: &Matrix) -> Result<Matrix>
pub fn sha384(input: &Matrix) -> Result<Matrix>
pub fn sha3_224(input: &Matrix) -> Result<Matrix>
pub fn sha3_256(input: &Matrix) -> Result<Matrix>
pub fn sha3_384(input: &Matrix) -> Result<Matrix>
pub fn sha3_512(input: &Matrix) -> Result<Matrix>
pub fn sha512(input: &Matrix) -> Result<Matrix>
pub fn sha512_224(input: &Matrix) -> Result<Matrix>
pub fn sha512_256(input: &Matrix) -> Result<Matrix>
pub fn shake128(input: &Matrix, output_length: usize) -> Result<Matrix>
pub fn shake256(input: &Matrix, output_length: usize) -> Result<Matrix>
pub fn verify_merkle_proofs( leaves: &Matrix, proofs: &Matrix, roots: &Matrix, leaf_count: u32, ) -> Result<Matrix>

Function Documentation

pub fn keccak_f1600( input: &Matrix ) -> Result<Matrix>
Apply Keccak-f[1600] independently to every 200-byte row. Errors Rejects invalid shapes, dtypes, shader address limits, allocation or recording failures.
pub fn merkle_proofs( leaves: &Matrix, indices: &Matrix ) -> Result<Matrix>
Build selected SHAKE-256 Merkle inclusion proofs entirely on the device. leaves is U8 [leaf_count, 32]; indices is rank-one U32. Output is U8 [proof_count, 16 + depth * 32]. The little-endian four-word header is [version=1, leaf_count, leaf_index, valid], followed by siblings bottom-up. Out-of-range device indices set valid=0 and zero every sibling. Empty selections return ready empty storage. No host observation of indices occurs. Errors Rejects metadata, ownership, address limits, allocation or recording failures.
pub fn merkle_root( input: &Matrix ) -> Result<Matrix>
Reduce any non-empty batch of 32-byte leaf hashes to one Merkle root. Duplicates the final node of each odd level, matching the OA CPU tree. Errors Rejects invalid shapes, dtypes, shader address limits, allocation or recording failures.
pub fn poseidon2_babybear16( input: &Matrix, output_length: usize ) -> Result<Matrix>
Apply the pinned Plonky3 babybear16 Poseidon2 field sponge. U32 rows contain field elements, reduced modulo the named prime. The OA sponge has capacity eight and explicit length/domain framing. It is not a claim of NVIDIA sponge wire compatibility. Errors Rejects dtype, rank, width, address limits, allocation or recording failures.
pub fn poseidon2_babybear16_permute( input: &Matrix ) -> Result<Matrix>
Apply the pinned Plonky3 babybear16 Poseidon2 permutation. U32 rows contain field elements, reduced modulo the named prime. The OA sponge has capacity eight and explicit length/domain framing. It is not a claim of NVIDIA sponge wire compatibility. Errors Rejects dtype, rank, width, address limits, allocation or recording failures.
pub fn poseidon2_babybear24( input: &Matrix, output_length: usize ) -> Result<Matrix>
Apply the pinned Plonky3 babybear24 Poseidon2 field sponge. U32 rows contain field elements, reduced modulo the named prime. The OA sponge has capacity eight and explicit length/domain framing. It is not a claim of NVIDIA sponge wire compatibility. Errors Rejects dtype, rank, width, address limits, allocation or recording failures.
pub fn poseidon2_babybear24_permute( input: &Matrix ) -> Result<Matrix>
Apply the pinned Plonky3 babybear24 Poseidon2 permutation. U32 rows contain field elements, reduced modulo the named prime. The OA sponge has capacity eight and explicit length/domain framing. It is not a claim of NVIDIA sponge wire compatibility. Errors Rejects dtype, rank, width, address limits, allocation or recording failures.
pub fn poseidon2_koalabear16( input: &Matrix, output_length: usize ) -> Result<Matrix>
Apply the pinned Plonky3 koalabear16 Poseidon2 field sponge. U32 rows contain field elements, reduced modulo the named prime. The OA sponge has capacity eight and explicit length/domain framing. It is not a claim of NVIDIA sponge wire compatibility. Errors Rejects dtype, rank, width, address limits, allocation or recording failures.
pub fn poseidon2_koalabear16_permute( input: &Matrix ) -> Result<Matrix>
Apply the pinned Plonky3 koalabear16 Poseidon2 permutation. U32 rows contain field elements, reduced modulo the named prime. The OA sponge has capacity eight and explicit length/domain framing. It is not a claim of NVIDIA sponge wire compatibility. Errors Rejects dtype, rank, width, address limits, allocation or recording failures.
pub fn poseidon2_koalabear24( input: &Matrix, output_length: usize ) -> Result<Matrix>
Apply the pinned Plonky3 koalabear24 Poseidon2 field sponge. U32 rows contain field elements, reduced modulo the named prime. The OA sponge has capacity eight and explicit length/domain framing. It is not a claim of NVIDIA sponge wire compatibility. Errors Rejects dtype, rank, width, address limits, allocation or recording failures.
pub fn poseidon2_koalabear24_permute( input: &Matrix ) -> Result<Matrix>
Apply the pinned Plonky3 koalabear24 Poseidon2 permutation. U32 rows contain field elements, reduced modulo the named prime. The OA sponge has capacity eight and explicit length/domain framing. It is not a claim of NVIDIA sponge wire compatibility. Errors Rejects dtype, rank, width, address limits, allocation or recording failures.
pub fn sha224( input: &Matrix ) -> Result<Matrix>
Hash each U8 [batch, message_bytes] row with SHA224. Returns exact 28-byte digest rows without padding. Empty messages are valid. Records device work without a host wait. Ordinary Matrix storage is public data; secret-bearing hashing requires the separate secret execution boundary. Errors Rejects invalid rank, dtype, batch size, address limits, allocation or recording failures.
pub fn sha256( input: &Matrix ) -> Result<Matrix>
Hash each U8 [batch, message_bytes] row with SHA256. Returns exact 32-byte digest rows without padding. Empty messages are valid. Records device work without a host wait. Ordinary Matrix storage is public data; secret-bearing hashing requires the separate secret execution boundary. Errors Rejects invalid rank, dtype, batch size, address limits, allocation or recording failures.
pub fn sha384( input: &Matrix ) -> Result<Matrix>
Hash each U8 [batch, message_bytes] row with SHA384. Returns exact 48-byte digest rows without padding. Empty messages are valid. Records device work without a host wait. Ordinary Matrix storage is public data; secret-bearing hashing requires the separate secret execution boundary. Errors Rejects invalid rank, dtype, batch size, address limits, allocation or recording failures.
pub fn sha3_224( input: &Matrix ) -> Result<Matrix>
Hash each U8 [batch, message_bytes] row with SHA3-224. Returns exact 28-byte digest rows without padding. Empty messages are valid. Records device work without a host wait. Ordinary Matrix storage is public data; secret-bearing hashing requires the separate secret execution boundary. Errors Rejects invalid rank, dtype, batch size, address limits, allocation or recording failures.
pub fn sha3_256( input: &Matrix ) -> Result<Matrix>
Hash each U8 [batch, message_bytes] row with SHA3-256. Returns exact 32-byte digest rows without padding. Empty messages are valid. Records device work without a host wait. Ordinary Matrix storage is public data; secret-bearing hashing requires the separate secret execution boundary. Errors Rejects invalid rank, dtype, batch size, address limits, allocation or recording failures.
pub fn sha3_384( input: &Matrix ) -> Result<Matrix>
Hash each U8 [batch, message_bytes] row with SHA3-384. Returns exact 48-byte digest rows without padding. Empty messages are valid. Records device work without a host wait. Ordinary Matrix storage is public data; secret-bearing hashing requires the separate secret execution boundary. Errors Rejects invalid rank, dtype, batch size, address limits, allocation or recording failures.
pub fn sha3_512( input: &Matrix ) -> Result<Matrix>
Hash each U8 [batch, message_bytes] row with SHA3-512. Returns exact 64-byte digest rows without padding. Empty messages are valid. Records device work without a host wait. Ordinary Matrix storage is public data; secret-bearing hashing requires the separate secret execution boundary. Errors Rejects invalid rank, dtype, batch size, address limits, allocation or recording failures.
pub fn sha512( input: &Matrix ) -> Result<Matrix>
Hash each U8 [batch, message_bytes] row with SHA512. Returns exact 64-byte digest rows without padding. Empty messages are valid. Records device work without a host wait. Ordinary Matrix storage is public data; secret-bearing hashing requires the separate secret execution boundary. Errors Rejects invalid rank, dtype, batch size, address limits, allocation or recording failures.
pub fn sha512_224( input: &Matrix ) -> Result<Matrix>
Hash each U8 [batch, message_bytes] row with SHA-512/224. Returns exact 28-byte digest rows without padding. Empty messages are valid. Records device work without a host wait. Ordinary Matrix storage is public data; secret-bearing hashing requires the separate secret execution boundary. Errors Rejects invalid rank, dtype, batch size, address limits, allocation or recording failures.
pub fn sha512_256( input: &Matrix ) -> Result<Matrix>
Hash each U8 [batch, message_bytes] row with SHA-512/256. Returns exact 32-byte digest rows without padding. Empty messages are valid. Records device work without a host wait. Ordinary Matrix storage is public data; secret-bearing hashing requires the separate secret execution boundary. Errors Rejects invalid rank, dtype, batch size, address limits, allocation or recording failures.
pub fn shake128( input: &Matrix, output_length: usize ) -> Result<Matrix>
Hash every row with SHAKE-128. An output_length of zero selects 16 bytes. Output rows are padded to an eight-byte boundary, matching the OA donor ABI. Errors Rejects invalid shapes, dtypes, shader address limits, allocation or recording failures.
pub fn shake256( input: &Matrix, output_length: usize ) -> Result<Matrix>
Hash every row with SHAKE-256. An output_length of zero selects 32 bytes. Output rows are padded to an eight-byte boundary, matching the OA donor ABI. Errors Rejects invalid shapes, dtypes, shader address limits, allocation or recording failures.
pub fn verify_merkle_proofs( leaves: &Matrix, proofs: &Matrix, roots: &Matrix, leaf_count: u32 ) -> Result<Matrix>
Verify version-one SHAKE-256 inclusion proof frames on the device. Leaves are U8 [proof_count, 32]; proofs have the frame layout returned by leaf_count must come from trusted tree metadata, not the proof header. merkle_proofs. Roots are U8 [1, 32] or [proof_count, 32]. Return rank-one U32 flags, exactly zero or one per row. Malformed headers, indices, duplicate-last paths, tampered leaves or roots return zero. Empty batches return ready empty storage; no input content is read on the host. Errors Rejects metadata, ownership, address limits, allocation or recording failures.