Documentation
¶
Index ¶
- Constants
- Variables
- func ProcessIDVersion(chainID uint32, contractAddr common.Address) [4]byte
- func SliceOf[F, T any](from []F, conv func(F) T) []T
- type BallotMode
- type BigInt
- func (i *BigInt) Add(x, y *BigInt) *BigInt
- func (i *BigInt) Bytes() []byte
- func (i *BigInt) Equal(j *BigInt) bool
- func (i *BigInt) GobDecode(buf []byte) error
- func (i *BigInt) GobEncode() ([]byte, error)
- func (i *BigInt) IsInField(baseField *big.Int) bool
- func (i *BigInt) LessThan(j *BigInt) bool
- func (i *BigInt) LessThanOrEqual(j *BigInt) bool
- func (i *BigInt) MarshalCBOR() ([]byte, error)
- func (i *BigInt) MarshalText() ([]byte, error)
- func (i *BigInt) MathBigInt() *big.Int
- func (i *BigInt) Mul(x, y *BigInt) *BigInt
- func (i *BigInt) SetBigInt(x *big.Int) *BigInt
- func (i *BigInt) SetBytes(buf []byte) *BigInt
- func (i *BigInt) SetInt(x int) *BigInt
- func (i *BigInt) SetUint64(x uint64) *BigInt
- func (i *BigInt) String() string
- func (i *BigInt) Sub(x, y *BigInt) *BigInt
- func (i *BigInt) ToFF(baseField *big.Int) *BigInt
- func (i *BigInt) UnmarshalCBOR(data []byte) error
- func (i *BigInt) UnmarshalJSON(data []byte) error
- func (i *BigInt) UnmarshalText(data []byte) error
- type Blob
- func (b *Blob) AsDeneb() *eth2deneb.Blob
- func (b *Blob) AsGeth() *gethkzg.Blob
- func (b *Blob) Bytes() []byte
- func (b *Blob) Clone() Blob
- func (b *Blob) ComputeBlobProof(commitment KZGCommitment) (KZGProof, error)
- func (b *Blob) ComputeCellProofs() ([]KZGProof, error)
- func (b *Blob) ComputeCommitment() (KZGCommitment, error)
- func (b *Blob) ComputeCommitmentAndCellProofs() (KZGCommitment, []KZGProof, error)
- func (b *Blob) ComputeCommitmentAndProof() (KZGCommitment, KZGProof, error)
- func (b *Blob) ComputeProof(point *big.Int) (proof KZGProof, claim *big.Int, err error)
- func (b *Blob) ToGnark() [params.BlobTxFieldElementsPerBlob]frontend.Variable
- type BlobSidecar
- type BlobTxSidecar
- type Census
- type CensusOrigin
- type CensusProof
- type CensusRoot
- type CensusRootChange
- type Choice
- type EncryptionKey
- type GenericMetadata
- type HexBytes
- func (b *HexBytes) BigInt() *BigInt
- func (b *HexBytes) Bytes() []byte
- func (b HexBytes) Equal(other HexBytes) bool
- func (b HexBytes) Hex32Bytes() HexBytes
- func (b HexBytes) LeftPad(n int) HexBytes
- func (b HexBytes) LeftTrim() HexBytes
- func (b HexBytes) MarshalJSON() ([]byte, error)
- func (b HexBytes) RightTrim() HexBytes
- func (b *HexBytes) String() string
- func (b *HexBytes) UnmarshalJSON(data []byte) error
- type KZGCommitment
- type KZGProof
- type MaxVotersChange
- type MediaMetadata
- type Metadata
- type MultilingualString
- type OrganizationInfo
- type Process
- type ProcessID
- func (p ProcessID) Address() common.Address
- func (p ProcessID) BigInt() *BigInt
- func (p ProcessID) Bytes() []byte
- func (p ProcessID) HexBytes() HexBytes
- func (p ProcessID) IsValid() bool
- func (p ProcessID) MarshalBinary() (data []byte, err error)
- func (p ProcessID) MarshalJSON() ([]byte, error)
- func (p ProcessID) MathBigInt() *big.Int
- func (p ProcessID) Nonce() uint64
- func (p ProcessID) String() string
- func (p *ProcessID) ToFF(baseField *big.Int) ProcessID
- func (p *ProcessID) UnmarshalBinary(data []byte) error
- func (p *ProcessID) UnmarshalJSON(data []byte) error
- func (p ProcessID) Version() [4]byte
- type ProcessSetup
- type ProcessSetupResponse
- type ProcessStatus
- type ProcessType
- type ProcessWithChanges
- type ProverFunc
- type ProverWithWitnessFunc
- type Question
- type SequencerProcessStats
- type Serializer
- type StateRootChange
- type StatusChange
- type TypeStats
- type Web3FilterFn
Constants ¶
const ( BlobTxSidecarVersion0 = gethtypes.BlobSidecarVersion0 BlobTxSidecarVersion1 = gethtypes.BlobSidecarVersion1 )
const ( CensusOriginUnknown CensusOrigin = iota CensusOriginMerkleTreeOffchainStaticV1 CensusOriginMerkleTreeOffchainDynamicV1 CensusOriginMerkleTreeOnchainDynamicV1 CensusOriginCSPEdDSABabyJubJubV1 CensusOriginNameUnknown = "unknown" CensusOriginNameMerkleTreeOffchainStaticV1 = "merkle_tree_offchain_static_v1" CensusOriginNameMerkleTreeOffchainDynamicV1 = "merkle_tree_offchain_dynamic_v1" CensusOriginNameMerkleTreeOnchainDynamicV1 = "merkle_tree_onchain_dynamic_v1" CensusOriginNameCSPEdDSABabyJubJubV1 = "csp_eddsa_babyjubjub_v1" // CensusRootLength defines the length in bytes of the census root. CensusRootLength = 32 )
const ( ProcessStatusReady = ProcessStatus(iota) // Process is ready to be started ProcessStatusEnded // Process has ended and waiting for results ProcessStatusCanceled // Process has been canceled ProcessStatusPaused // Process is paused ProcessStatusResults // Process has results available ProcessStatusReadyName = "ready" ProcessStatusEndedName = "ended" ProcessStatusCanceledName = "canceled" ProcessStatusPausedName = "paused" ProcessStatusResultsName = "results" // NewProcessMessageToSign is the message to sign when creating a new voting process NewProcessMessageToSign = "I am creating a new voting process for the davinci.vote protocol identified with id %s" )
const BlobLength = 131072
BlobLength is the number of bytes in a data blob.
const CellProofsPerBlob = gethkzg.CellProofsPerBlob
Each blob has CellProofsPerBlob (128) cell proofs
const ProcessIDLen = 32
ProcessIDLen is the length in bytes of a ProcessID
Variables ¶
var UseGPUProver = false
UseGPUProver indicates whether to use the GPU-accelerated prover, using Icicle.
Functions ¶
func ProcessIDVersion ¶
ProcessIDVersion computes the version for a ProcessID. It is defined as the last 4 bytes of the Keccak-256 hash of the concatenation of the chain ID (4 bytes big-endian) and the contract address (20 bytes).
Types ¶
type BallotMode ¶
type BallotMode struct {
NumFields uint8 `json:"numFields" cbor:"0,keyasint,omitempty"`
UniqueValues bool `json:"uniqueValues" cbor:"1,keyasint,omitempty"`
MaxValue *BigInt `json:"maxValue" cbor:"2,keyasint,omitempty"`
MinValue *BigInt `json:"minValue" cbor:"3,keyasint,omitempty"`
MaxValueSum *BigInt `json:"maxValueSum" cbor:"4,keyasint,omitempty"`
MinValueSum *BigInt `json:"minValueSum" cbor:"5,keyasint,omitempty"`
CostExponent uint8 `json:"costExponent" cbor:"6,keyasint,omitempty"`
CostFromWeight bool `json:"costFromWeight" cbor:"7,keyasint,omitempty"`
}
BallotMode is the struct to define the rules of a ballot
func (*BallotMode) Marshal ¶
func (b *BallotMode) Marshal() ([]byte, error)
Marshal serializes the BallotMode into a byte slice
func (*BallotMode) MarshalJSON ¶
func (b *BallotMode) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler interface
func (*BallotMode) String ¶
func (b *BallotMode) String() string
String returns a string representation of the BallotMode
func (*BallotMode) Unmarshal ¶
func (b *BallotMode) Unmarshal(data []byte) error
Unmarshal deserializes the BallotMode from a byte slice
func (*BallotMode) UnmarshalJSON ¶
func (b *BallotMode) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler interface
func (*BallotMode) Validate ¶
func (b *BallotMode) Validate() error
type BigInt ¶
BigInt is a big.Int wrapper which marshals JSON to a string representation of the big number. Note that a nil pointer value marshals as the empty string.
func BigIntConverter ¶
BigIntConverter converts a *big.Int to a *BigInt. It returns a new *BigInt with the value set to the value of the provided *big.Int. It can be used as a conversion function for SliceOf to convert a slice of *big.Int to a slice of *BigInt.
func (*BigInt) LessThanOrEqual ¶
func (*BigInt) MarshalCBOR ¶
MarshalCBOR explicitly encodes BigInt as a CBOR text string.
func (*BigInt) MarshalText ¶
MarshalText returns the decimal string representation of the big number. If the receiver is nil, we return "0".
func (*BigInt) MathBigInt ¶
MathBigInt converts b to a math/big *Int.
func (*BigInt) UnmarshalCBOR ¶
UnmarshalCBOR decodes a CBOR text string into BigInt.
func (*BigInt) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface. It supports both string and numeric JSON representations.
func (*BigInt) UnmarshalText ¶
UnmarshalText parses the text representation into the big number.
type Blob ¶
type Blob [131072]byte // 4096 * 32 bytes per field element
Blob represents a 4844 data blob.
func BlobFromDeneb ¶
BlobFromDeneb converts (without copy) a eth2deneb.Blob into a Blob.
func BlobFromGeth ¶
BlobFromGeth converts (without copy) a gethkzg.Blob into a Blob.
func MustBlobFromBytes ¶
MustBlobFromBytes creates a new Blob from raw bytes. If the input is not exactly 131072 bytes (4096 field elements * 32 bytes), panics.
func NewBlobFromBytes ¶
NewBlobFromBytes creates a new Blob from raw bytes. If the input is not exactly 131072 bytes (4096 field elements * 32 bytes), returns an error.
func (*Blob) Bytes ¶
Bytes returns a slice over the blob data. Writing to this slice will modify the underlying array.
func (*Blob) ComputeBlobProof ¶
func (b *Blob) ComputeBlobProof(commitment KZGCommitment) (KZGProof, error)
ComputeBlobProof returns the KZG proof that is used to verify the blob against the commitment.
This method does not verify that the commitment is correct with respect to blob.
func (*Blob) ComputeCellProofs ¶
ComputeCommitment creates a small commitment out of a data blob.
func (*Blob) ComputeCommitment ¶
func (b *Blob) ComputeCommitment() (KZGCommitment, error)
ComputeCommitment creates a small commitment out of a data blob.
func (*Blob) ComputeCommitmentAndCellProofs ¶
func (b *Blob) ComputeCommitmentAndCellProofs() (KZGCommitment, []KZGProof, error)
ComputeCommitmentAndCellProofs calculates the commitment and cell proofs of the passed blob, using geth kzg4844. This can be used to construct a Version 1 BlobTxSidecar.
func (*Blob) ComputeCommitmentAndProof ¶
func (b *Blob) ComputeCommitmentAndProof() (KZGCommitment, KZGProof, error)
ComputeCommitmentAndProof calculates the commitment and blob proof of the passed blob, using geth kzg4844. This can be used to construct a Version 0 BlobTxSidecar.
func (*Blob) ComputeProof ¶
ComputeProof computes the KZG proof at the given point for the polynomial represented by the blob.
If the absolute value of point doesn't fit in [32]byte, returns an error.
type BlobSidecar ¶
type BlobSidecar struct {
Index uint64
Blob *Blob
Commitment KZGCommitment
Proof KZGProof
}
BlobSidecar represents a unified blob sidecar that can be converted to/from external types.
func NewBlobSidecarFromDeneb ¶
func NewBlobSidecarFromDeneb(denebSidecar *eth2deneb.BlobSidecar) *BlobSidecar
NewBlobSidecarFromDeneb creates a new BlobSidecar from an eth2deneb.BlobSidecar.
func (*BlobSidecar) String ¶
func (bs *BlobSidecar) String() string
String returns a string representation of the BlobSidecar.
func (*BlobSidecar) ToDenebSidecar ¶
func (bs *BlobSidecar) ToDenebSidecar() *eth2deneb.BlobSidecar
ToDenebSidecar converts the BlobSidecar to an eth2deneb.BlobSidecar.
func (*BlobSidecar) VersionedBlobHash ¶
func (bs *BlobSidecar) VersionedBlobHash() common.Hash
VersionedBlobHash returns the versioned blob hash, calculated from the bs.Commitment
type BlobTxSidecar ¶
type BlobTxSidecar struct {
Version uint8
Blobs []*Blob
Commitments []KZGCommitment
Proofs []KZGProof
}
BlobTxSidecar represents a unified transaction blob sidecar.
func ComputeBlobTxSidecar ¶
func ComputeBlobTxSidecar(version byte, blobs []*Blob) (*BlobTxSidecar, error)
ComputeBlobTxSidecar calculates commitments and proofs of N passed blobs, using geth kzg4844. Returns a BlobTxSidecar with either 128*N cell proofs or N blob proofs depending on the passed version.
func NewBlobTxSidecar ¶
func NewBlobTxSidecar(version byte, blobs []*Blob, commitments []KZGCommitment, proofs []KZGProof) *BlobTxSidecar
func NewBlobTxSidecarFromGeth ¶
func NewBlobTxSidecarFromGeth(gethSidecar *gethtypes.BlobTxSidecar) *BlobTxSidecar
NewBlobTxSidecarFromGeth creates a new BlobTxSidecar from a types.BlobTxSidecar.
func (*BlobTxSidecar) AsGethSidecar ¶
func (bts *BlobTxSidecar) AsGethSidecar() *gethtypes.BlobTxSidecar
AsGethSidecar converts the BlobTxSidecar to a gethtypes.BlobTxSidecar. Returns a shallow copy: all slices are newly allocated, but their elements may share underlying memory with the original (no deep copy).
func (*BlobTxSidecar) BlobHashes ¶
func (bts *BlobTxSidecar) BlobHashes() []common.Hash
BlobHashes returns the blob hashes for the sidecar.
type Census ¶
type Census struct {
// Census origin type:
CensusOrigin CensusOrigin `json:"censusOrigin" cbor:"0,keyasint,omitempty"`
// Census root based on census origin:
// - CensusOriginMerkleTreeOffchainStaticV1: Merkle Root (fixed).
// - CensusOriginMerkleTreeOffchainDynamicV1: Merkle Root (could change
// via tx).
// - CensusOriginCSPEdDSABN254V1: MiMC7 of CSP PubKey (fixed).
// - CensusOriginMerkleTreeOnchainV1: Merkle Root (could change).
CensusRoot HexBytes `json:"censusRoot" cbor:"2,keyasint,omitempty"`
// CensusURI contains the following information depending on the CensusOrigin:
// - CensusOriginMerkleTreeOffchainStaticV1: URL where the sequencer can
// download the census snapshot used to compute the Merkle Proofs.
// - CensusOriginMerkleTreeOffchainDynamicV: URL where the sequencer can
// download the census snapshot used to compute the Merkle Proofs.
// - CensusOriginCSPEdDSABN254V1: URL where the voters can generate their
// signatures.
// - CensusOriginMerkleTreeOnchainV1: URL where the sequencer can
// download the census snapshot used to compute the Merkle Proofs.
CensusURI string `json:"censusURI" cbor:"3,keyasint,omitempty"`
// ContractAddress contains the address of the census manager contract, but
// only for the CensusOriginMerkleTreeOnchainV1 origin.
ContractAddress common.Address `json:"contractAddress,omitempty" cbor:"4,keyasint,omitempty"`
}
Census represents the census used in a voting process. It includes the origin, root, and URI of the census.
type CensusOrigin ¶
type CensusOrigin uint8
CensusOrigin represents the origin of the census used in a voting process.
func CensusOriginFromString ¶
func CensusOriginFromString(name string) CensusOrigin
CensusOriginFromString converts a string representation of a CensusOrigin to its corresponding CensusOrigin value. If the string does not match any known CensusOrigin, it returns CensusOriginUnknown.
func (CensusOrigin) BigInt ¶
func (co CensusOrigin) BigInt() *BigInt
BigInt converts the CensusOrigin to a *types.BigInt representation.
func (CensusOrigin) CurveID ¶
func (co CensusOrigin) CurveID() twistededwards.ID
CurveID returns the twistededwards.ID associated with the CensusOrigin. Only CSP origins have an associated curve, the rest return UNKNOWN.
func (CensusOrigin) IsCSP ¶
func (co CensusOrigin) IsCSP() bool
IsCSP checks if the CensusOrigin corresponds to a CSP-based census.
func (CensusOrigin) IsMerkleTree ¶
func (co CensusOrigin) IsMerkleTree() bool
IsMerkleTree checks if the CensusOrigin corresponds to a Merkle Tree census.
func (CensusOrigin) String ¶
func (co CensusOrigin) String() string
String returns a string representation of the CensusOrigin.
func (CensusOrigin) Valid ¶
func (co CensusOrigin) Valid() bool
Valid checks if the CensusOrigin is a valid value.
type CensusProof ¶
type CensusProof struct {
// Generic fields
CensusOrigin CensusOrigin `json:"censusOrigin"`
Root HexBytes `json:"root"`
Address HexBytes `json:"address"`
Weight *BigInt `json:"weight,omitempty"`
// Merkletree related fields
Siblings HexBytes `json:"siblings,omitempty"`
Value HexBytes `json:"value,omitempty"`
Index uint64 `json:"index,omitempty"`
// CSP related fields
ProcessID *ProcessID `json:"processId,omitempty"`
PublicKey HexBytes `json:"publicKey,omitempty"`
Signature HexBytes `json:"signature,omitempty"`
}
CensusProof is the struct to represent a proof of inclusion in the census merkle tree. For example, it will be provided by the user to verify that he or she can vote in the process.
func (*CensusProof) String ¶
func (cp *CensusProof) String() string
String returns a string representation of the CensusProof in JSON format. It returns an empty string if the JSON marshaling fails.
func (*CensusProof) Valid ¶
func (cp *CensusProof) Valid() bool
Valid checks that the CensusProof is well-formed
type CensusRoot ¶
type CensusRoot struct {
Root HexBytes `json:"root"`
}
CensusRoot represents the census root used in a voting process.
type CensusRootChange ¶
CensusRootChange represents a change in the census root of a voting process. It includes the new census root and the associated URI.
type Choice ¶
type Choice struct {
Title MultilingualString `json:"title" cbor:"0,keyasint,omitempty"`
Value int `json:"value" cbor:"1,keyasint,omitempty"`
Meta GenericMetadata `json:"meta" cbor:"2,keyasint,omitempty"`
}
type EncryptionKey ¶
type EncryptionKey struct {
X *BigInt `json:"x" cbor:"0,keyasint,omitempty"`
Y *BigInt `json:"y" cbor:"1,keyasint,omitempty"`
}
func EncryptionKeyFromPoint ¶
func EncryptionKeyFromPoint(publicKey ecc.Point) EncryptionKey
EncryptionKeyFromPoint returns an EncryptionKey with the X and Y coordinates of the elliptic curve element.
type GenericMetadata ¶
func (GenericMetadata) MarshalJSON ¶
func (g GenericMetadata) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler interface for GenericMetadata Returns an empty object {} instead of null when the map is nil or empty
func (*GenericMetadata) UnmarshalJSON ¶
func (g *GenericMetadata) UnmarshalJSON(data []byte) error
type HexBytes ¶
type HexBytes []byte
HexBytes is a []byte which encodes as hexadecimal in json, as opposed to the base64 default.
func HexStringToHexBytes ¶
HexStringToHexBytes converts a hex string to a HexBytes.
func HexStringToHexBytesMustUnmarshal ¶
HexStringToHexBytesMustUnmarshal converts a hex string to a HexBytes. It strips a leading '0x' or '0X' if found, for backwards compatibility. Panics if the string is not a valid hex string.
func NormalizedCensusRoot ¶
NormalizedCensusRoot function ensures that the census root is always of a fixed length. If its length is not CensusRootLength, it truncates or pads it accordingly.
func (HexBytes) Equal ¶
Equal method compares the current HexBytes with the provided one. First checks if both have the same length, and compare them byte per byte.
func (HexBytes) Hex32Bytes ¶
Hex32Bytes returns a new HexBytes padded with leading zeros to 32 bytes.
func (HexBytes) LeftPad ¶
LeftPad returns a new HexBytes padded with leading zeros to the specified length n. If the length of b is already n or greater, it returns a copy of b. Adding leading zeros does not change the value represented by the HexBytes.
func (HexBytes) LeftTrim ¶
LeftTrim returns a new HexBytes with leading zeros removed. If there are no leading zeros, it returns a copy of b.
func (HexBytes) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface for HexBytes. It encodes the byte slice as a hexadecimal string prefixed with "0x".
func (HexBytes) RightTrim ¶
RightTrim returns a new HexBytes with trailing zeros removed. If there are no trailing zeros, it returns a copy of b.
func (*HexBytes) String ¶
String returns the hexadecimal string representation of the HexBytes, prefixed with "0x".
func (*HexBytes) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface for HexBytes. It expects a JSON string containing a hexadecimal representation, optionally prefixed with "0x".
type KZGCommitment ¶
type KZGCommitment [48]byte
KZGCommitment is a serialized commitment to a polynomial.
func KZGCommitmentFromGeth ¶
func KZGCommitmentFromGeth(c gethkzg.Commitment) KZGCommitment
KZGCommitmentFromGeth converts a gethkzg.Commitment to a KZGCommitment
func (*KZGCommitment) AsGeth ¶
func (c *KZGCommitment) AsGeth() *gethkzg.Commitment
AsGeth converts (without copy) the Commitment to a gethkzg.Commitment.
func (*KZGCommitment) CalcBlobHashV1 ¶
func (c *KZGCommitment) CalcBlobHashV1(hasher hash.Hash) (vh [32]byte)
CalcBlobHashV1 calculates the 'versioned blob hash' of a commitment. The given hasher must be a sha256 hash instance, otherwise the result will be invalid!
func (KZGCommitment) String ¶
func (c KZGCommitment) String() string
String returns a string representation of the KZGCommitment.
func (KZGCommitment) ToGnarkLimbs ¶
func (c KZGCommitment) ToGnarkLimbs() [3]frontend.Variable
ToGnarkLimbs splits a 48-byte KZG commitment into 3 × 16-byte limbs.
func (KZGCommitment) ToLimbs ¶
func (c KZGCommitment) ToLimbs() [3]*big.Int
ToLimbs splits a 48-byte KZG commitment into 3 × 16-byte limbs.
type KZGProof ¶
type KZGProof [48]byte
KZGProof is a serialized commitment to the quotient polynomial.
func KZGProofFromGeth ¶
KZGProofFromGeth converts a gethkzg.Proof to a KZGProof
func (KZGProof) ToGnarkLimbs ¶
ToGnarkLimbs splits a 48-byte KZG proof into 3 × 16-byte limbs.
type MaxVotersChange ¶
type MaxVotersChange struct {
NewMaxVoters *BigInt
}
MaxVotersChange represents a change in the maximum number of voters allowed in a voting process. It includes the new maximum voters value.
type MediaMetadata ¶
type Metadata ¶
type Metadata struct {
Title MultilingualString `json:"title" cbor:"0,keyasint,omitempty"`
Description MultilingualString `json:"description" cbor:"1,keyasint,omitempty"`
Media MediaMetadata `json:"media" cbor:"2,keyasint,omitempty"`
Questions []Question `json:"questions" cbor:"3,keyasint,omitempty"`
Type ProcessType `json:"type" cbor:"4,keyasint,omitempty"`
Version string `json:"version" cbor:"5,keyasint,omitempty"`
Meta GenericMetadata `json:"meta" cbor:"6,keyasint,omitempty"`
}
type MultilingualString ¶
func (MultilingualString) MarshalJSON ¶
func (m MultilingualString) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler interface for MultilingualString Returns an empty object {} instead of null when the map is nil or empty
type OrganizationInfo ¶
type OrganizationInfo struct {
ID common.Address `json:"id,omitempty" cbor:"0,keyasint,omitempty"`
Name string `json:"name" cbor:"1,keyasint,omitempty"`
MetadataURI string `json:"metadataURI" cbor:"2,keyasint,omitempty"`
}
func (*OrganizationInfo) String ¶
func (o *OrganizationInfo) String() string
type Process ¶
type Process struct {
ID *ProcessID `json:"id,omitempty" cbor:"0,keyasint,omitempty"`
Status ProcessStatus `json:"status" cbor:"1,keyasint,omitempty"`
OrganizationId common.Address `json:"organizationId" cbor:"2,keyasint,omitempty"`
EncryptionKey *EncryptionKey `json:"encryptionKey" cbor:"3,keyasint,omitempty"`
StateRoot *BigInt `json:"stateRoot" cbor:"4,keyasint,omitempty"`
Result []*BigInt `json:"result" cbor:"5,keyasint,omitempty"`
StartTime time.Time `json:"startTime" cbor:"6,keyasint,omitempty"`
Duration time.Duration `json:"duration" cbor:"7,keyasint,omitempty"`
MetadataURI string `json:"metadataURI" cbor:"8,keyasint,omitempty"`
BallotMode *BallotMode `json:"ballotMode" cbor:"9,keyasint,omitempty"`
Census *Census `json:"census" cbor:"10,keyasint,omitempty"`
Metadata *Metadata `json:"metadata,omitempty" cbor:"11,keyasint,omitempty"`
VotersCount *BigInt `json:"votersCount" cbor:"12,keyasint,omitempty"`
OverwrittenVotesCount *BigInt `json:"overwrittenVotesCount" cbor:"13,keyasint,omitempty"`
MaxVoters *BigInt `json:"maxVoters" cbor:"14,keyasint,omitempty"`
SequencerStats SequencerProcessStats `json:"sequencerStats" cbor:"16,keyasint,omitempty"`
}
type ProcessID ¶
type ProcessID [ProcessIDLen]byte
ProcessID is the type to identify a voting process. It is composed of:
- Address (20 bytes)
- Version keccak(chainID + contractAddress) (4 bytes)
- Nonce (8 bytes, big-endian)
func BytesToProcessID ¶
func HexStringToProcessID ¶
HexStringToProcessID parses a ProcessID from a hex string. It accepts optional "0x" prefix and requires exactly 32 bytes (64 hex chars).
func NewProcessID ¶
NewProcessID builds a ProcessID using the passed params.
func (ProcessID) IsValid ¶
IsValid checks if the ProcessID is valid. A valid ProcessID must have a non-zero Address and Version
func (ProcessID) MarshalBinary ¶
MarshalBinary implements the BinaryMarshaler interface
func (ProcessID) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface
func (ProcessID) MathBigInt ¶
MathBigInt returns a *math/big.Int representation of the ProcessId.
func (*ProcessID) ToFF ¶
ToFF returns the finite field representation of the ProcessID. It uses the curve scalar field to represent the ProcessID.
func (*ProcessID) UnmarshalBinary ¶
UnmarshalBinary implements the BinaryMarshaler interface
func (*ProcessID) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface
type ProcessSetup ¶
type ProcessSetup struct {
ProcessID ProcessID `json:"processId"`
Census *Census `json:"census"`
BallotMode *BallotMode `json:"ballotMode"`
Signature HexBytes `json:"signature"`
}
ProcessSetup is the struct to create a new voting process
type ProcessSetupResponse ¶
type ProcessSetupResponse struct {
ProcessID *ProcessID `json:"processId,omitempty"`
EncryptionPubKey [2]*BigInt `json:"encryptionPubKey,omitempty"`
StateRoot HexBytes `json:"stateRoot,omitempty"`
BallotMode *BallotMode `json:"ballotMode,omitempty"`
}
ProcessSetupResponse represents the response of a voting process
type ProcessStatus ¶
type ProcessStatus uint8
func (ProcessStatus) String ¶
func (s ProcessStatus) String() string
type ProcessType ¶
type ProcessType struct {
Name string `json:"name" cbor:"0,keyasint,omitempty"`
Properties GenericMetadata `json:"properties" cbor:"1,keyasint,omitempty"`
}
type ProcessWithChanges ¶
type ProcessWithChanges struct {
ProcessID ProcessID
*StatusChange
*StateRootChange
*MaxVotersChange
*CensusRootChange
}
ProcessWithChanges encapsulates a voting process identifier along with various types of changes that may have occurred to the process, such as status changes, state root updates, maximum voters adjustments, and census root modifications. It includes optional fields for each type of change and the process ID.
type ProverFunc ¶
type ProverFunc func( curve ecc.ID, ccs constraint.ConstraintSystem, pk groth16.ProvingKey, assignment frontend.Circuit, opts ...backend.ProverOption, ) (groth16.Proof, error)
ProverFunc defines a function type that matches the signature needed for zkSNARK proving. The function is generic enough to handle all circuit types. This type is used for dependency injection, particularly in the Sequencer.
type ProverWithWitnessFunc ¶
type ProverWithWitnessFunc func( curve ecc.ID, ccs constraint.ConstraintSystem, pk groth16.ProvingKey, w witness.Witness, opts ...backend.ProverOption, ) (groth16.Proof, error)
ProverWithWitnessFunc defines a function type for proving with an already-created witness. This is primarily used in test code where witnesses are already created.
type Question ¶
type Question struct {
Title MultilingualString `json:"title" cbor:"0,keyasint,omitempty"`
Description MultilingualString `json:"description" cbor:"1,keyasint,omitempty"`
Choices []Choice `json:"choices" cbor:"2,keyasint,omitempty"`
Meta GenericMetadata `json:"meta" cbor:"3,keyasint,omitempty"`
}
type SequencerProcessStats ¶
type SequencerProcessStats struct {
StateTransitionCount int `json:"stateTransitionCount" cbor:"0,keyasint,omitempty"`
LastStateTransitionDate time.Time `json:"lastStateTransitionDate" cbor:"1,keyasint,omitempty"`
SettledStateTransitionCount int `json:"settledStateTransitionCount" cbor:"2,keyasint,omitempty"`
AggregatedVotesCount int `json:"aggregatedVotesCount" cbor:"3,keyasint,omitempty"`
VerifiedVotesCount int `json:"verifiedVotesCount" cbor:"4,keyasint,omitempty"`
PendingVotesCount int `json:"pendingVotesCount" cbor:"5,keyasint,omitempty"`
CurrentBatchSize int `json:"currentBatchSize" cbor:"6,keyasint,omitempty"`
LastBatchSize int `json:"lastBatchSize" cbor:"7,keyasint,omitempty"`
}
type Serializer ¶
type Serializer[T any] interface { Serialize() []T }
type StateRootChange ¶
type StateRootChange struct {
OldStateRoot *BigInt
NewStateRoot *BigInt
NewVotersCount *BigInt
NewOverwrittenVotesCount *BigInt
TxHash *common.Hash
}
StateRootChange represents a change in the state root of a voting process. It includes the new state root, the updated voters count, and the updated count of overwritten votes, as well as the tx hash where the data blob lives, that enables a sequencer to reconstruct that NewStateRoot.
type StatusChange ¶
type StatusChange struct {
OldStatus ProcessStatus
NewStatus ProcessStatus
}
StatusChange represents a change in the status of a voting process. It includes the old and new status values.
type Web3FilterFn ¶
type Web3FilterFn func(ctx context.Context, start, end uint64, ch chan<- *ProcessWithChanges) error
Web3FilterFn defines the signature for functions that filter process changes from the blockchain. These functions take a context, a start and end block number, and a channel to send the filtered ProcessWithChanges to. They return an error if the filtering fails.