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

Method to_hash

bitvm/src/chunk/elements.rs:193–214  ·  view source on GitHub ↗

Blake3 Hash data types For U256Data (which is a single BigInteger) we do not hash but return as is BigInt are used to represent groth16 proof

(self)

Source from the content-addressed store, hash-verified

191 // For U256Data (which is a single BigInteger) we do not hash but return as is
192 // BigInt are used to represent groth16 proof
193 pub fn to_hash(self) -> CompressedStateObject {
194 match self {
195 DataType::G2EvalData(r) => {
196 let hash_t = r.hash_t();
197 let hash_le = r.hash_le();
198 let hash = extern_hash_nibbles(vec![hash_t, hash_le]);
199 CompressedStateObject::Hash(hash)
200 }
201 DataType::Fp6Data(r) => {
202 let hash = extern_hash_fps(
203 r.to_base_prime_field_elements()
204 .collect::<Vec<ark_bn254::Fq>>(),
205 );
206 CompressedStateObject::Hash(hash)
207 }
208 DataType::U256Data(f) => CompressedStateObject::U256(f),
209 DataType::G1Data(r) => {
210 let hash = extern_hash_fps(vec![r.x, r.y]);
211 CompressedStateObject::Hash(hash)
212 }
213 }
214 }
215
216 pub fn output_is_field_element(&self) -> bool {
217 matches!(self, DataType::U256Data(_))

Callers 4

test_tap_hash_var_pFunction · 0.80
compareFunction · 0.80
test_chunk_frob_fp12Function · 0.80

Calls 4

extern_hash_nibblesFunction · 0.85
extern_hash_fpsFunction · 0.85
hash_tMethod · 0.80
hash_leMethod · 0.80

Tested by 2

test_tap_hash_var_pFunction · 0.64
test_chunk_frob_fp12Function · 0.64