Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: abstract public signals checks #1247

Open
lucasmenendez opened this issue Feb 8, 2024 · 0 comments
Open

feature: abstract public signals checks #1247

lucasmenendez opened this issue Feb 8, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@lucasmenendez
Copy link
Contributor

lucasmenendez commented Feb 8, 2024

As of #1246, the crypto/zk/prover/pubsignals package contains some functions to get and set some attributes from/to zk circuit public signals. This is very helpful because the transformations required on this data (such as split, join or hash operations) are transparent to the rest of the code.

However, other parts of the code need to compare the result of this getter with information coming from the vochain. And that code has to transform the vochain data in the same way as the publis signals in order to be compared correctly.

To prevent this, the crypto/zk/prover/pubsignals package must include new helpers that take the vochain information as is and compare it with the public signals data, including all the necessary transformations and avoiding this logic in any part of the code that compares the two data.

For example, in the file vochain/transaction/proofs/zkproof/zkproof.go, to compare the process ID, it must be hashed before be compared, this kind of logic must be abstracted:

// verify the process id
proofProcessID, err := proof.ElectionID()
if err != nil {
	return false, nil, fmt.Errorf("failed on parsing process id from public inputs provided: %w", err)
}
hashedPid := sha256.Sum256(process.ProcessId)
if !bytes.Equal(hashedPid[:], proofProcessID) {
	return false, nil, fmt.Errorf("process id mismatch %x != %x", process.ProcessId, proofProcessID)
}

It could be refactored to a helper:

// verify the process id
if !proof.CmpElectionID(process.ProcessId) {
	return false, nil, fmt.Errorf("process id mismatch %x != %x", process.ProcessId, proofProcessID)
}
@lucasmenendez lucasmenendez added the enhancement New feature or request label Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant