Skip to content

Commit

Permalink
review: remove VK from inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
einar-polygon committed Jun 28, 2024
1 parent 70d961e commit d7518f6
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions evm_arithmetization/src/fixed_recursive_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ where
rhs: AggregationChildTarget<D>,
mix_pv_hash: HashOutTarget,
dummy_pis: Vec<Target>,
vk_len: usize,
cyclic_vk: VerifierCircuitTarget,
}

Expand Down Expand Up @@ -371,6 +372,7 @@ where
mix_pv_hash,
dummy_pis,
cyclic_vk,
vk_len: todo!(),
})
}
}
Expand Down Expand Up @@ -1013,6 +1015,8 @@ where
dummy_pis.push(target);
}

let user_pis_len = builder.num_public_inputs();

let cyclic_vk = builder.add_verifier_data_public_inputs();

let lhs = Self::add_agg_child(&mut builder, &block_circuit.circuit);
Expand All @@ -1021,12 +1025,12 @@ where
let lhs_public_values = lhs.public_values_vec(&mut builder);
let rhs_public_values = rhs.public_values_vec(&mut builder);

let lhs_base_pv_hash = builder.hash_n_to_hash_no_pad::<C::InnerHasher>(lhs_public_values.to_owned()).elements;
let rhs_base_pv_hash = builder.hash_n_to_hash_no_pad::<C::InnerHasher>(rhs_public_values.to_owned()).elements;

let lhs_agg_pv_hash = &lhs_public_values[..NUM_HASH_OUT_ELTS];
let rhs_agg_pv_hash = &rhs_public_values[..NUM_HASH_OUT_ELTS];

let lhs_base_pv_hash = builder.hash_n_to_hash_no_pad::<C::InnerHasher>(lhs_public_values[..user_pis_len].to_owned()).elements;
let rhs_base_pv_hash = builder.hash_n_to_hash_no_pad::<C::InnerHasher>(rhs_public_values[..user_pis_len].to_owned()).elements;

let lhs_hash : Vec<Target> = zip_eq(
lhs_agg_pv_hash,
lhs_base_pv_hash,
Expand Down Expand Up @@ -1054,9 +1058,10 @@ where
circuit,
lhs,
rhs,
mix_pv_hash,
mix_pv_hash: mix_pv_hash_output,
dummy_pis,
cyclic_vk,
vk_len: verification_key_len,
}
}

Expand Down Expand Up @@ -1678,19 +1683,35 @@ where
&self.two_to_one_block.circuit.verifier_only,
);


let verification_key_len = self.two_to_one_block.vk_len;

// // The number of PIS that will be added after padding by
// // `builder.add_verifier_data_public_inputs()`.
// let verification_key_len = block_circuit
// .circuit
// .verifier_only
// .circuit_digest
// .elements
// .len()
// + (1 << block_circuit.circuit.common.config.fri_config.cap_height)
// * (NUM_HASH_OUT_ELTS);

let user_pis_len = lhs.public_inputs.len() - verification_key_len;

let lhs_pv_hash = if lhs_is_agg {
let elements = lhs.public_inputs[..NUM_HASH_OUT_ELTS].try_into().expect("wrong length");
HashOut { elements }
} else {
C::InnerHasher::hash_no_pad(&lhs.public_inputs)
C::InnerHasher::hash_no_pad(&lhs.public_inputs[..user_pis_len])
};

let rhs_pv_hash = if rhs_is_agg {
//extract_aggregation_hash(&rhs.public_inputs)
let elements = rhs.public_inputs[..NUM_HASH_OUT_ELTS].try_into().expect("wrong length");
HashOut { elements }
} else {
C::InnerHasher::hash_no_pad(&rhs.public_inputs)
C::InnerHasher::hash_no_pad(&rhs.public_inputs[..user_pis_len])
};

let mix_pv_hash = C::InnerHasher::two_to_one(lhs_pv_hash, rhs_pv_hash);
Expand Down

0 comments on commit d7518f6

Please sign in to comment.