Skip to content

Commit

Permalink
Clean up Circuit Builder (#741)
Browse files Browse the repository at this point in the history
@10to4 Your #740 reminded me of
some old improvements I had lying around.

Especially the use of the standard library's `join`, instead of
implementing the functionality manually.
  • Loading branch information
matthiasgoergens authored Dec 17, 2024
1 parent 6c5151e commit d7a51b2
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions ceno_zkvm/src/circuit_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,10 @@ impl NameSpace {
}

pub(crate) fn compute_path(&self, this: String) -> String {
let ns = self.get_namespaces();
if this.chars().any(|a| a == '/') {
if this.chars().contains(&'/') {
panic!("'/' is not allowed in names");
}

let mut name = String::new();

let mut needs_separation = false;
for ns in chain!(ns, once(&this)) {
if needs_separation {
name += "/";
}

name += ns;
needs_separation = true;
}

name
chain!(self.get_namespaces(), once(&this)).join("/")
}

pub fn get_namespaces(&self) -> &[String] {
Expand Down Expand Up @@ -205,14 +191,12 @@ impl<E: ExtensionField> ConstraintSystem<E> {
fixed_traces: Option<RowMajorMatrix<E::BaseField>>,
) -> ProvingKey<E, PCS> {
// transpose from row-major to column-major
let fixed_traces = fixed_traces.map(|t| t.into_mles().into_iter().collect_vec());
let fixed_traces = fixed_traces.map(RowMajorMatrix::into_mles);

let fixed_commit_wd = fixed_traces
.as_ref()
.map(|traces| PCS::batch_commit(pp, traces).unwrap());
let fixed_commit = fixed_commit_wd
.as_ref()
.map(|commit_wd| PCS::get_pure_commitment(commit_wd));
let fixed_commit = fixed_commit_wd.as_ref().map(PCS::get_pure_commitment);

ProvingKey {
fixed_traces,
Expand Down

0 comments on commit d7a51b2

Please sign in to comment.