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

Function final_circuit

final-spv/src/lib.rs:41–65  ·  view source on GitHub ↗

The final circuit that verifies the output of the header chain circuit.

(guest: &impl ZkvmGuest)

Source from the content-addressed store, hash-verified

39
40/// The final circuit that verifies the output of the header chain circuit.
41pub fn final_circuit(guest: &impl ZkvmGuest) {
42 let start = env::cycle_count();
43 let input: FinalCircuitInput = guest.read_from_host::<FinalCircuitInput>();
44 guest.verify(HEADER_CHAIN_GUEST_ID, &input.block_header_circuit_output);
45 input.spv.verify(
46 input
47 .block_header_circuit_output
48 .chain_state
49 .block_hashes_mmr,
50 );
51 let mut hasher = blake3::Hasher::new();
52
53 hasher.update(&input.spv.transaction.txid());
54 hasher.update(
55 &input
56 .block_header_circuit_output
57 .chain_state
58 .best_block_hash,
59 );
60 hasher.update(&input.block_header_circuit_output.chain_state.total_work);
61 let final_output = hasher.finalize();
62 guest.commit(final_output.as_bytes());
63 let end = env::cycle_count();
64 println!("Final circuit took {:?} cycles", end - start);
65}

Callers 1

mainFunction · 0.85

Calls 4

txidMethod · 0.80
verifyMethod · 0.45
finalizeMethod · 0.45
commitMethod · 0.45

Tested by

no test coverage detected