Documentation
¶
Overview ¶
csp package provides the basic methods to create and verify certificates of voters eligibility of a Credential Service Providers (CSP). This package includes the definition of the CSP interface and a general functions to create a new CSP based on the given origin of the census and verify the census proofs generated by the CSP.
The CSP interface defines methods to set a seed, retrieve census origin and root, generate and verify census proofs. The package currently supports the EdDSA BLS12-377 origin for census proofs.
- The `New` function creates a new CSP based on the provided origin and seed.
- The `VerifyCensusProof` function verifies a given CensusProof using the appropriate CSP based on its origin.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func VerifyCensusProof ¶
func VerifyCensusProof(proof *types.CensusProof) error
VerifyCensusProof verifies the given CensusProof using the appropriate CSP. It checks the origin of the proof and uses the corresponding CSP to verify it. If the origin is not supported, it returns an error.
Types ¶
type CSP ¶
type CSP interface {
SetSeed(seed []byte) error
CensusOrigin() types.CensusOrigin
CensusRoot() *types.CensusRoot
GenerateProof(processID types.ProcessID, address common.Address, weight *types.BigInt) (*types.CensusProof, error)
VerifyProof(proof *types.CensusProof) error
}
CSP defines the interface for a Credential Service Providers (CSP). It provides methods to set a seed, retrieve census origin and root, and generate and verify census proofs. The CSP is responsible for handling cryptographic operations related to census proofs, which are used to verify the integrity and authenticity of census data in an external system.
func New ¶
func New(origin types.CensusOrigin, seed []byte) (CSP, error)
New creates a new CredentialServiceProviders (CSP) based on the given origin. If a seed is provided, it initializes the CSP with that seed. It returns an error if the CSP cannot be created for the given origin or if the seed cannot be set.
type CSPProof ¶
CSPProof struct represents a proof generated by the CredentialServiceProviders to be used in the circuits. It includes the signature, public key, process ID and address as variables. The IsValid method checks if the signature is valid or not using the gnark API.
func CensusProofToCSPProof ¶
func CensusProofToCSPProof(curveID ecc_twedwards.ID, censusProof *types.CensusProof) (*CSPProof, error)
CensusProofToCSPProof converts a types.CensusProof to a CSPProof to be used in Gnark circuits. It unmarshals the public key and signature from the CensusProof and converts them to gnark circuit types.
func (*CSPProof) IsValidEmulated ¶
func (proof *CSPProof) IsValidEmulated( api frontend.API, curveID ecc_twedwards.ID, censusRoot, processID, address, weight emulated.Element[sw_bn254.ScalarField], ) frontend.Variable
IsValid checks if the signature is valid or not. It returns 1 as a frontend variable if the signature is valid, and 0 if it is not. It recomputes the message hash with the process ID and address and verifies the signature against the public key and the message hash.