Skip to content

Conversation

@nategraf
Copy link
Collaborator

@nategraf nategraf commented Jun 1, 2025

The main goal of this PR is to refactor the morphism building API to make it more concise to build and prove relations. I also make some smaller changes to fix minor points in the rest of the repo, and add adjust the build configurations by adding a rust-toolchain.toml file and turning on opt-level=1 for tests.

@nategraf nategraf requested a review from mmaker June 1, 2025 17:56
pub sigmap: P,
}

// QUESTION: Is the morphism supposed to be written to the transcript? I don't see that here.
Copy link
Contributor

@Chausseaumoine Chausseaumoine Jun 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure why we would need to do it, we're only putting the domain_sep in the transcript (in the permanent transcript), and the commitments during a prove/verification (in the temporary clone). Do you see a case where it would be useful to do that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do, ya. It decreases the risk of soundness issues when the relation may change (e.g. with versions of the software) or depend on context that is outside this system.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To implement this: given our design for prove/verify step, where the transcript is cloned + fed commitments + destroyed, how do we put the morphism inside the transcript?

1: It is also cloned + fed commitments + destroyed => the cloned transcript for Morphism + the cloned transcript for prove/verify need to exist at the same time to work
2: It is permanently added to the transcript => no change to current workflow, but it means that successive proofs depend on former proofs for a later verifier (eg. need to add n morphisms to transcript to verify an independent n+1 morphism)
3: Other suggestion?

witness: &P::Witness,
rng: &mut (impl RngCore + CryptoRng),
) -> Result<Transcript<P>, ProofError> {
// QUESTION: Why is the self mutable? It's unclear whether the intention is to have a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It probably shouldn’t be, we followed @mmaker design to clone it at the beginning of every proof/verify to feed the Codec and throw away the clone afterwards

pub linear_combination: Vec<LinearCombination>,
pub group_elements: Vec<G>,
pub num_scalars: usize,
/// QUESTION: Why is there a count of elements seperate from group_elements.len()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No good reason, we should just derive the length from group_elements directly with len()

// QUESTION: This accesses the group_elements, but it does not attempt to tell
// whether they have been set. If I allocate a point var, and use it in the
// equations here, will the variables always be set. I think not, as a result, the
// solution here may not be valid.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check whether the fieds are non-empty before trying to evaluate them

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated this to do so 👍

pub fn allocate_elements(&mut self, n: usize) -> Vec<PointVar> {
let start = self.morphism.num_elements;
// NOTE: This uses identity as the default value for an allocated, but unassigned,
// variable.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I don’t know if there is a proper way of doing this other than this? Leave it empty maybe?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take a look at the GroupMap that exists now

@nategraf nategraf marked this pull request as ready for review June 2, 2025 15:55
@mmaker mmaker merged commit 4ec00e1 into main Jun 2, 2025
7 checks passed
@nategraf nategraf changed the title [WIP] Refactor of morphism construction for more concise definition of statements Refactor of morphism construction for more concise definition of statements Jun 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants