openvm_sha2_circuit/sha2_chips/block_hasher_chip/
config.rs1use openvm_sha2_air::{Sha256Config, Sha2BlockHasherSubairConfig, Sha384Config, Sha512Config};
2
3use crate::{Sha2BlockHasherDigestColsRef, Sha2BlockHasherRoundColsRef};
4
5pub trait Sha2BlockHasherVmConfig: Sha2BlockHasherSubairConfig {
6 const BLOCK_HASHER_ROUND_WIDTH: usize;
8 const BLOCK_HASHER_DIGEST_WIDTH: usize;
10 const BLOCK_HASHER_WIDTH: usize;
12}
13
14impl Sha2BlockHasherVmConfig for Sha256Config {
15 const BLOCK_HASHER_ROUND_WIDTH: usize =
16 Sha2BlockHasherRoundColsRef::<u8>::width::<Sha256Config>();
17 const BLOCK_HASHER_DIGEST_WIDTH: usize =
18 Sha2BlockHasherDigestColsRef::<u8>::width::<Sha256Config>();
19 const BLOCK_HASHER_WIDTH: usize =
20 if Self::BLOCK_HASHER_ROUND_WIDTH > Self::BLOCK_HASHER_DIGEST_WIDTH {
21 Self::BLOCK_HASHER_ROUND_WIDTH
22 } else {
23 Self::BLOCK_HASHER_DIGEST_WIDTH
24 };
25}
26
27impl Sha2BlockHasherVmConfig for Sha512Config {
28 const BLOCK_HASHER_ROUND_WIDTH: usize =
29 Sha2BlockHasherRoundColsRef::<u8>::width::<Sha512Config>();
30 const BLOCK_HASHER_DIGEST_WIDTH: usize =
31 Sha2BlockHasherDigestColsRef::<u8>::width::<Sha512Config>();
32 const BLOCK_HASHER_WIDTH: usize = if <Self as Sha2BlockHasherVmConfig>::BLOCK_HASHER_ROUND_WIDTH
33 > Self::BLOCK_HASHER_DIGEST_WIDTH
34 {
35 Self::BLOCK_HASHER_ROUND_WIDTH
36 } else {
37 Self::BLOCK_HASHER_DIGEST_WIDTH
38 };
39}
40
41impl Sha2BlockHasherVmConfig for Sha384Config {
42 const BLOCK_HASHER_ROUND_WIDTH: usize =
43 Sha2BlockHasherRoundColsRef::<u8>::width::<Sha384Config>();
44 const BLOCK_HASHER_DIGEST_WIDTH: usize =
45 Sha2BlockHasherDigestColsRef::<u8>::width::<Sha384Config>();
46 const BLOCK_HASHER_WIDTH: usize =
47 if Self::BLOCK_HASHER_ROUND_WIDTH > Self::BLOCK_HASHER_DIGEST_WIDTH {
48 Self::BLOCK_HASHER_ROUND_WIDTH
49 } else {
50 Self::BLOCK_HASHER_DIGEST_WIDTH
51 };
52}