(
stack: &mut StackTracker,
carry: &mut StackVariable,
number_count: u32,
is_last: bool,
quotient_table: StackVariable,
modulo_table: StackVariable,
)
| 248 | } |
| 249 | |
| 250 | pub fn u4_add_nibble_stack( |
| 251 | stack: &mut StackTracker, |
| 252 | carry: &mut StackVariable, |
| 253 | number_count: u32, |
| 254 | is_last: bool, |
| 255 | quotient_table: StackVariable, |
| 256 | modulo_table: StackVariable, |
| 257 | ) -> StackVariable { |
| 258 | if !carry.is_null() { |
| 259 | stack.move_var(*carry); |
| 260 | stack.op_add(); |
| 261 | } |
| 262 | |
| 263 | if modulo_table.is_null() || quotient_table.is_null() { |
| 264 | if !is_last { |
| 265 | let output_vars = vec![(1, "add_no_table".into()), (1, "carry_no_table".into())]; |
| 266 | let out = stack.custom_ex(u4_add_carry_nested(0, number_count), 1, output_vars, 0); |
| 267 | *carry = out[1]; |
| 268 | out[0] |
| 269 | } else { |
| 270 | { |
| 271 | let output_vars = vec![(1, "add_no_table".into())]; |
| 272 | stack.custom_ex(u4_add_nested(0, number_count), 1, output_vars, 0)[0] |
| 273 | } |
| 274 | } |
| 275 | } else { |
| 276 | if !is_last { |
| 277 | stack.op_dup(); |
| 278 | } |
| 279 | let var = stack.get_value_from_table(modulo_table, None); |
| 280 | |
| 281 | //we don't care about the last carry |
| 282 | if !is_last { |
| 283 | stack.op_swap(); |
| 284 | //obtain the quotinent to be used as carry for the next addition |
| 285 | *carry = stack.get_value_from_table(quotient_table, None); |
| 286 | } |
| 287 | var |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | pub fn sha256_stack( |
| 292 | stack: &mut StackTracker, |
no test coverage detected