MCPcopy Create free account
hub / github.com/BitVM/BitVM / maj_calculation

Function maj_calculation

bitvm/src/hash/sha256_u4.rs:208–234  ·  view source on GitHub ↗
(a: u32, b: u32, c: u32, offset_and: u32)

Source from the content-addressed store, hash-verified

206}
207
208pub fn maj_calculation(a: u32, b: u32, c: u32, offset_and: u32) -> Script {
209 script! {
210 for nib in 0..8 {
211
212 { a + 7 } // a_nib_pos
213 OP_PICK // a[nib]
214
215 { b + 7 + 1 } // a b_nib_pos
216 OP_PICK // a b
217 OP_2DUP // a b a b
218
219 { u4_xor_with_half_and_table(nib + offset_and + 4) } // a b (a^b)
220
221 { c + 7 + 3 } // a b (a^b) c_nib_pos
222 OP_PICK // a b (a^b) c
223
224 { u4_half_table_operation(nib + offset_and + 4) } // a b ((a^b) & c)
225 OP_ROT
226 OP_ROT // ((a^b) & c) a b
227
228 { u4_half_table_operation(nib + offset_and + 3) } // ((a^b) & c) (a & b)
229
230 { u4_xor_with_half_and_table(nib + offset_and + 2) } // ((a^b) & c) ^ (a & b)
231
232 }
233 }
234}
235
236pub fn schedule_iteration(
237 i: u32,

Callers 1

test_sizesFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_sizesFunction · 0.68