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

Function get_segments_from_assertion

bitvm/src/chunk/api_runtime_utils.rs:131–239  ·  view source on GitHub ↗

mirror of the funtion get_assertion_from_segments

(
    assertions: Assertions,
    vk: ark_groth16::VerifyingKey<Bn254>,
)

Source from the content-addressed store, hash-verified

129
130// mirror of the funtion get_assertion_from_segments
131pub(crate) fn get_segments_from_assertion(
132 assertions: Assertions,
133 vk: ark_groth16::VerifyingKey<Bn254>,
134) -> (bool, Vec<Segment>) {
135 fn extract_proof_from_assertions(
136 state_pubs: [CompressedStateObject; NUM_PUBS],
137 state_fqs: [CompressedStateObject; NUM_U256],
138 ) -> Option<InputProofRaw> {
139 let mut ks: Vec<ark_ff::BigInt<4>> = vec![];
140 for cobj in state_pubs {
141 if let CompressedStateObject::U256(cobj) = cobj {
142 ks.push(cobj);
143 } else {
144 return None;
145 }
146 }
147 let ks: [ark_ff::BigInt<4>; NUM_PUBS] = ks.try_into().unwrap();
148
149 let mut numfqs: Vec<ark_ff::BigInt<4>> = vec![];
150 for cobj in state_fqs {
151 if let CompressedStateObject::U256(cobj) = cobj {
152 numfqs.push(cobj);
153 } else {
154 return None;
155 }
156 }
157
158 let p4 = [numfqs[1], numfqs[0]];
159 let p2 = [numfqs[3], numfqs[2]];
160 let step = 4;
161 let c = [
162 numfqs[step],
163 numfqs[step + 1],
164 numfqs[step + 2],
165 numfqs[step + 3],
166 numfqs[step + 4],
167 numfqs[step + 5],
168 ];
169 let step = step + 6;
170
171 let q4 = [
172 numfqs[step],
173 numfqs[step + 1],
174 numfqs[step + 2],
175 numfqs[step + 3],
176 ];
177
178 let eval_ins: InputProofRaw = InputProofRaw { p2, p4, q4, c, ks };
179 Some(eval_ins)
180 }
181
182 fn extract_hashes_from_assertions(
183 state_hashes: [CompressedStateObject; NUM_HASH],
184 ) -> Option<Vec<HashBytes>> {
185 // Intermediates
186 let mut hashes: Vec<HashBytes> = vec![];
187 for cobj in state_hashes {
188 if let CompressedStateObject::Hash(cobj) = cobj {

Callers 3

validate_assertionsFunction · 0.85
test_largest_chunksFunction · 0.85

Tested by 2

test_largest_chunksFunction · 0.68