File tree Expand file tree Collapse file tree 1 file changed +27
-12
lines changed
extensions/sha2/circuit/src/sha2_chip Expand file tree Collapse file tree 1 file changed +27
-12
lines changed Original file line number Diff line number Diff line change @@ -115,20 +115,35 @@ impl<F: PrimeField32, C: ShaChipConfig> StepExecutorE1<F> for Sha2VmStep<C> {
115
115
) ;
116
116
}
117
117
Rv32Sha2Opcode :: SHA512 => {
118
- memory_write :: < { Sha512Config :: WRITE_SIZE } > (
119
- state. memory ,
120
- RV32_MEMORY_AS ,
121
- dst,
122
- output. as_slice ( ) . try_into ( ) . unwrap ( ) ,
123
- ) ;
118
+ for i in 0 ..C :: NUM_WRITES {
119
+ memory_write :: < { Sha512Config :: WRITE_SIZE } > (
120
+ state. memory ,
121
+ RV32_MEMORY_AS ,
122
+ dst + ( i * Sha512Config :: WRITE_SIZE ) as u32 ,
123
+ output. as_slice ( )
124
+ [ i * Sha512Config :: WRITE_SIZE ..( i + 1 ) * Sha512Config :: WRITE_SIZE ]
125
+ . try_into ( )
126
+ . unwrap ( ) ,
127
+ ) ;
128
+ }
124
129
}
125
130
Rv32Sha2Opcode :: SHA384 => {
126
- memory_write :: < { Sha384Config :: WRITE_SIZE } > (
127
- state. memory ,
128
- RV32_MEMORY_AS ,
129
- dst,
130
- output. as_slice ( ) . try_into ( ) . unwrap ( ) ,
131
- ) ;
131
+ // Pad the output with zeros to 64 bytes
132
+ let output = output
133
+ . into_iter ( )
134
+ . chain ( iter:: repeat ( 0 ) . take ( 16 ) )
135
+ . collect :: < Vec < _ > > ( ) ;
136
+ for i in 0 ..C :: NUM_WRITES {
137
+ memory_write :: < { Sha384Config :: WRITE_SIZE } > (
138
+ state. memory ,
139
+ RV32_MEMORY_AS ,
140
+ dst + ( i * Sha384Config :: WRITE_SIZE ) as u32 ,
141
+ output. as_slice ( )
142
+ [ i * Sha384Config :: WRITE_SIZE ..( i + 1 ) * Sha384Config :: WRITE_SIZE ]
143
+ . try_into ( )
144
+ . unwrap ( ) ,
145
+ ) ;
146
+ }
132
147
}
133
148
}
134
149
You can’t perform that action at this time.
0 commit comments