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

Method zip

bitvm/src/bigint/std.rs:147–171  ·  view source on GitHub ↗

Zip the top two u{16N} elements input: a0 ... a{N-1} b0 ... b{N-1} output: a0 b0 ... ... a{N-1} b{N-1}

(mut a: u32, mut b: u32)

Source from the content-addressed store, hash-verified

145 /// input: a0 ... a{N-1} b0 ... b{N-1}
146 /// output: a0 b0 ... ... a{N-1} b{N-1}
147 pub fn zip(mut a: u32, mut b: u32) -> Script {
148 a = (a + 1) * Self::N_LIMBS - 1;
149 b = (b + 1) * Self::N_LIMBS - 1;
150
151 assert_ne!(a, b);
152 if a < b {
153 script! {
154 for i in 0..Self::N_LIMBS {
155 { a + i }
156 OP_ROLL
157 { b }
158 OP_ROLL
159 }
160 }
161 } else {
162 script! {
163 for i in 0..Self::N_LIMBS {
164 { a }
165 OP_ROLL
166 { b + i + 1 }
167 OP_ROLL
168 }
169 }
170 }
171 }
172
173 pub fn copy_zip(mut a: u32, mut b: u32) -> Script {
174 a = (a + 1) * Self::N_LIMBS - 1;

Callers 6

validateMethod · 0.45
new_for_validationMethod · 0.45
signMethod · 0.45
new_for_validationMethod · 0.45
signMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected