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

Function chunk_hash_p

bitvm/src/chunk/taps_msm.rs:132–172  ·  view source on GitHub ↗
(
    hint_in_t: ark_bn254::G1Affine,
    hint_in_q: ark_bn254::G1Affine,
)

Source from the content-addressed store, hash-verified

130//vk0: G1Affine
131
132pub(crate) fn chunk_hash_p(
133 hint_in_t: ark_bn254::G1Affine,
134 hint_in_q: ark_bn254::G1Affine,
135) -> (ark_bn254::G1Affine, bool, Script, Vec<Hint>) {
136 // r (gp3) = t(msm) + q(vk0)
137 let (tx, qx, ty, qy) = (hint_in_t.x, hint_in_q.x, hint_in_t.y, hint_in_q.y);
138 let t = ark_bn254::G1Affine::new_unchecked(tx, ty);
139 let q = ark_bn254::G1Affine::new_unchecked(qx, qy);
140 let (add_scr, add_hints) = G1Affine::hinted_check_add_prevent_degenerate(t, q);
141 let r = (t + q).into_affine();
142 let ops_script = script! {
143 // [t] [hash_r, hash_t]
144
145 //Validity checks
146 { Fq2::check_validity() } { Fq2::fromaltstack() }
147
148 { Fq2::copy(0)}
149 // [t, t]
150 {G1Affine::push(q)}
151 // [t, t, q]
152 {add_scr}
153 // [t, r]
154 {1}
155 };
156
157 let _hash_script = script! {
158 {hash_messages(vec![ElementType::G1, ElementType::G1])}
159 OP_TRUE
160 };
161
162 let sc = script! {
163 {ops_script}
164 // {hash_script}
165 };
166
167 let mut all_hints = vec![];
168 all_hints.extend_from_slice(&add_hints);
169
170 let valid_inputs = true;
171 (r, valid_inputs, sc, all_hints)
172}
173
174#[cfg(test)]
175mod test {

Callers 2

test_tap_hash_var_pFunction · 0.85
wrap_hint_hash_pFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_tap_hash_var_pFunction · 0.68