| 234 | } |
| 235 | |
| 236 | pub fn schedule_iteration( |
| 237 | i: u32, |
| 238 | offset_top_sched: u32, |
| 239 | offset_rot: u32, |
| 240 | offset_and: u32, |
| 241 | offset_add: u32, |
| 242 | use_add_table: bool, |
| 243 | do_xor_with_and: bool, |
| 244 | ) -> Script { |
| 245 | script! { |
| 246 | { calculate_s( offset_top_sched - get_w_pos(i-15), offset_rot, offset_and, vec![7,18,3], true, do_xor_with_and)} |
| 247 | { calculate_s( offset_top_sched - get_w_pos(i-2), offset_rot, offset_and, vec![17,19,10], true, do_xor_with_and)} |
| 248 | { u4_fromaltstack(16) } |
| 249 | { u4_copy_u32_from(offset_top_sched - get_w_pos(i-16)+16 )} // this can be avoided arranging directly with roll |
| 250 | { u4_copy_u32_from(offset_top_sched - get_w_pos(i-7)+24 )} |
| 251 | { u4_add(8, vec![0, 8, 16, 24], offset_add + 32, use_add_table )} |
| 252 | { u4_fromaltstack(8) } |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | fn get_full_w_pos(top_table: u32, i: u32) -> u32 { |
| 257 | top_table - (i + 1) * 8 |