Skip to content

feature: abstract public signals checks #1247

@lucasmenendez

Description

@lucasmenendez

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)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions