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

Function ch_calculation

bitvm/src/hash/sha256_u4.rs:178–206  ·  view source on GitHub ↗
(e: u32, f: u32, g: u32, offset_and: u32)

Source from the content-addressed store, hash-verified

176}
177
178pub fn ch_calculation(e: u32, f: u32, g: u32, offset_and: u32) -> Script {
179 script! {
180 for nib in 0..8 {
181
182 { e + 7 } // e_nib_pos
183 OP_PICK // e[nib]
184 OP_DUP // e e
185
186 OP_NEGATE
187 OP_15
188 OP_ADD // e ~e
189
190 { g + 7 + 2} // e ~e g_nib_pos (account for e and ~e)
191 OP_PICK // e ~e g
192
193 { u4_half_table_operation(nib + offset_and + 3) } // e ( ~e & g )
194 OP_SWAP // ( ~e & g ) e
195
196
197 { f + 7 + 2} // ( ~e & g ) e f_nib_pos
198 OP_PICK // ( ~e & g ) e f
199
200 { u4_half_table_operation(nib + offset_and + 3) } // ( ~e & g ) (e & f)
201 { u4_xor_with_half_and_table(nib + offset_and + 2) } // ( ~e & g ) ^ (e & f)
202
203 //OP_TOALTSTACK
204 }
205 }
206}
207
208pub fn maj_calculation(a: u32, b: u32, c: u32, offset_and: u32) -> Script {
209 script! {

Callers 1

test_sizesFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_sizesFunction · 0.68