types

package
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2026 License: AGPL-3.0 Imports: 25 Imported by: 5

Documentation

Index

Constants

View Source
const (
	BlobTxSidecarVersion0 = gethtypes.BlobSidecarVersion0
	BlobTxSidecarVersion1 = gethtypes.BlobSidecarVersion1
)
View Source
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
)
View Source
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"
)
View Source
const BlobLength = 131072

BlobLength is the number of bytes in a data blob.

View Source
const CellProofsPerBlob = gethkzg.CellProofsPerBlob

Each blob has CellProofsPerBlob (128) cell proofs

View Source
const ProcessIDLen = 31

ProcessIDLen is the length in bytes of a ProcessID

Variables

This section is empty.

Functions

func ProcessIDVersion

func ProcessIDVersion(chainID uint32, contractAddr common.Address) [4]byte

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

func SliceOf

func SliceOf[F, T any](from []F, conv func(F) T) []T

SliceOf converts a slice of type F to a slice of type T using the provided conversion function. It returns a new slice of type T with the converted values.

Types

type BallotIndex added in v0.0.2

type BallotIndex uint64

func BigIntToBallotIndex added in v0.0.2

func BigIntToBallotIndex(x *big.Int) (BallotIndex, error)

func CalculateBallotIndex added in v0.0.2

func CalculateBallotIndex(voterIndex VoterIndex) BallotIndex

CalculateBallotIndex returns a BallotIndex on the lower half of the 64 bit space, between BallotMin and BallotMax.

BallotIndex = BallotMin + voterIndex

func HexStringToBallotIndex added in v0.0.2

func HexStringToBallotIndex(s string) (BallotIndex, error)

func (BallotIndex) BigInt added in v0.0.2

func (b BallotIndex) BigInt() *big.Int

func (BallotIndex) Bytes added in v0.0.2

func (b BallotIndex) Bytes() []byte

func (BallotIndex) IsInField added in v0.0.2

func (b BallotIndex) IsInField(field *big.Int) bool

func (BallotIndex) MarshalJSON added in v0.0.2

func (b BallotIndex) MarshalJSON() ([]byte, error)

func (BallotIndex) StateKey added in v0.0.2

func (b BallotIndex) StateKey() StateKey

func (BallotIndex) String added in v0.0.2

func (b BallotIndex) String() string

func (BallotIndex) ToGnark added in v0.0.2

func (b BallotIndex) ToGnark() uint64

func (BallotIndex) Uint64 added in v0.0.2

func (b BallotIndex) Uint64() uint64

func (*BallotIndex) UnmarshalJSON added in v0.0.2

func (b *BallotIndex) UnmarshalJSON(data []byte) error

func (BallotIndex) Valid added in v0.0.2

func (b BallotIndex) Valid() bool

type BigInt

type BigInt big.Int

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

func BigIntConverter(from *big.Int) *BigInt

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 NewInt

func NewInt(x int) *BigInt

NewInt creates a new BigInt from the given integer value.

func (*BigInt) Add

func (i *BigInt) Add(x, y *BigInt) *BigInt

Add sum x+y

func (*BigInt) Bytes

func (i *BigInt) Bytes() []byte

Bytes returns the bytes representation of the big number

func (*BigInt) Cmp added in v0.0.2

func (x *BigInt) Cmp(y *BigInt) int

Cmp compares x and y

func (*BigInt) Equal

func (i *BigInt) Equal(j *BigInt) bool

Equal helps us with go-cmp.

func (*BigInt) GobDecode

func (i *BigInt) GobDecode(buf []byte) error

func (*BigInt) GobEncode

func (i *BigInt) GobEncode() ([]byte, error)

func (*BigInt) HexBytes added in v0.0.2

func (i *BigInt) HexBytes() HexBytes

HexBytes returns the bytes representation of the big number as a HexBytes

func (*BigInt) IsInField

func (i *BigInt) IsInField(field *big.Int) bool

func (*BigInt) LessThan

func (i *BigInt) LessThan(j *BigInt) bool

func (*BigInt) LessThanOrEqual

func (i *BigInt) LessThanOrEqual(j *BigInt) bool

func (*BigInt) MarshalCBOR

func (i *BigInt) MarshalCBOR() ([]byte, error)

MarshalCBOR explicitly encodes BigInt as a CBOR text string.

func (*BigInt) MarshalText

func (i *BigInt) MarshalText() ([]byte, error)

MarshalText returns the decimal string representation of the big number. If the receiver is nil, we return "0".

func (*BigInt) MathBigInt

func (i *BigInt) MathBigInt() *big.Int

MathBigInt converts b to a math/big *Int.

func (*BigInt) Mul

func (i *BigInt) Mul(x, y *BigInt) *BigInt

Mul multiplies x*y

func (*BigInt) SetBigInt

func (i *BigInt) SetBigInt(x *big.Int) *BigInt

SetBigInt sets the value of x to the big number.

func (*BigInt) SetBytes

func (i *BigInt) SetBytes(buf []byte) *BigInt

SetBytes interprets buf as big-endian unsigned integer

func (*BigInt) SetInt

func (i *BigInt) SetInt(x int) *BigInt

func (*BigInt) SetUint64

func (i *BigInt) SetUint64(x uint64) *BigInt

SetUint64 sets the value of x to the big number

func (*BigInt) String

func (i *BigInt) String() string

String returns the string representation of the big number

func (*BigInt) Sub

func (i *BigInt) Sub(x, y *BigInt) *BigInt

Sub subs x-y

func (*BigInt) ToFF

func (i *BigInt) ToFF(field *big.Int) *BigInt

func (*BigInt) UnmarshalCBOR

func (i *BigInt) UnmarshalCBOR(data []byte) error

UnmarshalCBOR decodes a CBOR text string into BigInt.

func (*BigInt) UnmarshalJSON

func (i *BigInt) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface. It supports both string and numeric JSON representations.

func (*BigInt) UnmarshalText

func (i *BigInt) UnmarshalText(data []byte) error

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

func BlobFromDeneb(denebBlob *eth2deneb.Blob) *Blob

BlobFromDeneb converts (without copy) a eth2deneb.Blob into a Blob.

func BlobFromGeth

func BlobFromGeth(gethBlob *gethkzg.Blob) *Blob

BlobFromGeth converts (without copy) a gethkzg.Blob into a Blob.

func MustBlobFromBytes

func MustBlobFromBytes(data []byte) *Blob

MustBlobFromBytes creates a new Blob from raw bytes. If the input is not exactly 131072 bytes (4096 field elements * 32 bytes), panics.

func NewBlobFromBytes

func NewBlobFromBytes(data []byte) (*Blob, error)

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

func (b *Blob) AsDeneb() *eth2deneb.Blob

AsDeneb converts (without copy) the blob to an eth2deneb.Blob.

func (*Blob) AsGeth

func (b *Blob) AsGeth() *gethkzg.Blob

AsGeth converts (without copy) the blob to a gethkzg.Blob.

func (*Blob) Bytes

func (b *Blob) Bytes() []byte

Bytes returns a slice over the blob data. Writing to this slice will modify the underlying array.

func (*Blob) Clone

func (b *Blob) Clone() Blob

Clone returns a copy of the Blob

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

func (b *Blob) ComputeCellProofs() ([]KZGProof, error)

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

func (b *Blob) ComputeProof(point *big.Int) (proof KZGProof, claim *big.Int, err error)

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.

func (*Blob) ToGnark

ToGnark splits the blob into 4096 big.Int and returns them as a slice of frontend.Variable

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 CSPIndexFn added in v0.0.2

type CSPIndexFn func(processID ProcessID, address common.Address, weight *BigInt) VoterIndex

CSPIndexFn is a function that returns the index of a given process ID, address and weight. It is used during the CensusProof generation process to calculate deterministic indexes for CSP proofs.

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.

func (*Census) Clone added in v0.0.4

func (c *Census) Clone() *Census

Clone returns a copy 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"`
	// VoterIndex is a unique census participant index, used to derive the ballot index.
	VoterIndex VoterIndex `json:"voterIndex"`
	// Merkletree related fields
	Siblings HexBytes `json:"siblings,omitempty"`
	Value    HexBytes `json:"value,omitempty"`
	PathBits uint64   `json:"pathBits,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

type CensusRootChange struct {
	NewCensusRoot HexBytes
	NewCensusURI  string
}

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.

func (EncryptionKey) BigInts added in v0.0.2

func (k EncryptionKey) BigInts() []*big.Int

type GenericMetadata

type GenericMetadata map[string]any

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

func HexStringToHexBytes(hexString string) (HexBytes, error)

HexStringToHexBytes converts a hex string to a HexBytes.

func HexStringToHexBytesMustUnmarshal

func HexStringToHexBytesMustUnmarshal(hexString string) HexBytes

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

func NormalizedCensusRoot(original HexBytes) HexBytes

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

func (b HexBytes) BigInt() *BigInt

BigInt converts the HexBytes to a BigInt.

func (*HexBytes) Bytes

func (b *HexBytes) Bytes() []byte

Bytes returns the underlying byte slice of the HexBytes.

func (HexBytes) Equal

func (b HexBytes) Equal(other HexBytes) bool

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) Hex added in v0.0.2

func (b HexBytes) Hex() string

Hex returns the hexadecimal string representation of the HexBytes.

func (HexBytes) Hex32Bytes

func (b HexBytes) Hex32Bytes() HexBytes

Hex32Bytes returns a new HexBytes padded with leading zeros to 32 bytes.

func (HexBytes) LeftPad

func (b HexBytes) LeftPad(n int) HexBytes

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

func (b HexBytes) LeftTrim() HexBytes

LeftTrim returns a new HexBytes with leading zeros removed. If there are no leading zeros, it returns a copy of b.

func (HexBytes) MarshalJSON

func (b HexBytes) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for HexBytes. It encodes the byte slice as a hexadecimal string prefixed with "0x".

func (HexBytes) RightTrim

func (b HexBytes) RightTrim() HexBytes

RightTrim returns a new HexBytes with trailing zeros removed. If there are no trailing zeros, it returns a copy of b.

func (HexBytes) String

func (b HexBytes) String() string

String returns the hexadecimal string representation of the HexBytes, prefixed with "0x".

func (*HexBytes) UnmarshalJSON

func (b *HexBytes) UnmarshalJSON(data []byte) error

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

func KZGProofFromGeth(p gethkzg.Proof) KZGProof

KZGProofFromGeth converts a gethkzg.Proof to a KZGProof

func (*KZGProof) AsGeth

func (p *KZGProof) AsGeth() *gethkzg.Proof

AsGeth converts (without copy) the KZGProof to a gethkzg.Proof.

func (KZGProof) String

func (p KZGProof) String() string

String returns a string representation of the KZGProof.

func (KZGProof) ToGnarkLimbs

func (p KZGProof) ToGnarkLimbs() [3]frontend.Variable

ToGnarkLimbs splits a 48-byte KZG proof into 3 × 16-byte limbs.

func (KZGProof) ToLimbs

func (p KZGProof) ToLimbs() [3]*big.Int

ToLimbs 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 MediaMetadata struct {
	Header string `json:"header" cbor:"0,keyasint,omitempty"`
}

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"`
}

func (*Metadata) String

func (m *Metadata) String() string

type MultilingualString

type MultilingualString map[string]string

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 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            spec.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"`
}

func (*Process) String

func (p *Process) String() string

type ProcessEncryptionKeysResponse added in v0.0.2

type ProcessEncryptionKeysResponse struct {
	EncryptionPubKey [2]*BigInt `json:"encryptionPubKey,omitempty"`
}

ProcessEncryptionKeysResponse represents the response for a request for encryption keys for a process

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 (7 bytes, big-endian)

func BigIntToProcessID

func BigIntToProcessID(bi *big.Int) (ProcessID, error)

func BytesToProcessID

func BytesToProcessID(data []byte) (ProcessID, error)

func HexStringToProcessID

func HexStringToProcessID(s string) (ProcessID, error)

HexStringToProcessID parses a ProcessID from a hex string. It accepts optional "0x" prefix and requires exactly 31 bytes (62 hex chars).

func NewProcessID

func NewProcessID(addr common.Address, version [4]byte, nonce uint64) ProcessID

NewProcessID builds a ProcessID using the passed params.

func (ProcessID) Address

func (p ProcessID) Address() common.Address

func (ProcessID) BigInt

func (p ProcessID) BigInt() *BigInt

BigInt returns a types.BigInt representation of the ProcessId.

func (ProcessID) Bytes

func (p ProcessID) Bytes() []byte

Bytes returns a slice view of the underlying array.

func (ProcessID) HexBytes

func (p ProcessID) HexBytes() HexBytes

HexBytes returns a HexBytes view of the ProcessID

func (ProcessID) IsValid

func (p ProcessID) IsValid() bool

IsValid checks if the ProcessID is valid. A valid ProcessID must have a non-zero Address and Version

func (ProcessID) MarshalBinary

func (p ProcessID) MarshalBinary() (data []byte, err error)

MarshalBinary implements the BinaryMarshaler interface

func (ProcessID) MarshalJSON

func (p ProcessID) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface

func (ProcessID) MathBigInt

func (p ProcessID) MathBigInt() *big.Int

MathBigInt returns a *math/big.Int representation of the ProcessId.

func (ProcessID) Nonce

func (p ProcessID) Nonce() uint64

func (ProcessID) String

func (p ProcessID) String() string

String returns a human readable representation of process ID

func (*ProcessID) ToFF

func (p *ProcessID) ToFF(field *big.Int) ProcessID

ToFF returns the finite field representation of the ProcessID. It uses the curve scalar field to represent the ProcessID.

func (*ProcessID) UnmarshalBinary

func (p *ProcessID) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the BinaryMarshaler interface

func (*ProcessID) UnmarshalJSON

func (p *ProcessID) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface

func (ProcessID) Version

func (p ProcessID) Version() [4]byte

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 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 StateKey added in v0.0.2

type StateKey uint64

func (StateKey) BigInt added in v0.0.2

func (k StateKey) BigInt() *big.Int

func (StateKey) Bytes added in v0.0.2

func (k StateKey) Bytes() []byte

func (StateKey) IsInField added in v0.0.2

func (k StateKey) IsInField(field *big.Int) bool

func (StateKey) MarshalJSON added in v0.0.2

func (k StateKey) MarshalJSON() ([]byte, error)

func (StateKey) String added in v0.0.2

func (k StateKey) String() string

func (StateKey) ToGnark added in v0.0.2

func (k StateKey) ToGnark() uint64

func (StateKey) Uint64 added in v0.0.2

func (k StateKey) Uint64() uint64

func (*StateKey) UnmarshalJSON added in v0.0.2

func (k *StateKey) UnmarshalJSON(data []byte) error

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 TypeStats

type TypeStats int

TypeStats are used to identify the type of stats in the Process

const (
	TypeStatsStateTransitions TypeStats = iota
	TypeStatsSettledStateTransitions
	TypeStatsAggregatedVotes
	TypeStatsVerifiedVotes
	TypeStatsPendingVotes
	TypeStatsCurrentBatchSize
	TypeStatsLastBatchSize
	TypeStatsLastTransitionDate
)

type VoteID added in v0.0.2

type VoteID uint64

func BigIntToVoteID added in v0.0.2

func BigIntToVoteID(x *big.Int) (VoteID, error)

func HexStringToVoteID added in v0.0.2

func HexStringToVoteID(s string) (VoteID, error)

func (VoteID) BigInt added in v0.0.2

func (v VoteID) BigInt() *big.Int

func (VoteID) Bytes added in v0.0.2

func (v VoteID) Bytes() []byte

func (VoteID) IsInField added in v0.0.2

func (v VoteID) IsInField(field *big.Int) bool

func (VoteID) MarshalJSON added in v0.0.2

func (v VoteID) MarshalJSON() ([]byte, error)

func (VoteID) StateKey added in v0.0.2

func (v VoteID) StateKey() StateKey

func (VoteID) String added in v0.0.2

func (v VoteID) String() string

func (VoteID) ToGnark added in v0.0.2

func (v VoteID) ToGnark() uint64

func (VoteID) Uint64 added in v0.0.2

func (v VoteID) Uint64() uint64

func (*VoteID) UnmarshalJSON added in v0.0.2

func (v *VoteID) UnmarshalJSON(data []byte) error

func (VoteID) Valid added in v0.0.2

func (v VoteID) Valid() bool

type VoterIndex added in v0.0.7

type VoterIndex uint64

VoterIndex is a unique census participant index.

func (VoterIndex) BigInt added in v0.0.7

func (v VoterIndex) BigInt() *BigInt

BigInt returns the voter index as a *BigInt.

func (VoterIndex) MarshalJSON added in v0.0.7

func (v VoterIndex) MarshalJSON() ([]byte, error)

MarshalJSON encodes the voter index as a decimal string.

func (VoterIndex) Uint64 added in v0.0.7

func (v VoterIndex) Uint64() uint64

Uint64 returns the voter index as a uint64.

func (*VoterIndex) UnmarshalJSON added in v0.0.7

func (v *VoterIndex) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes the voter index from a decimal string.

func (VoterIndex) Valid added in v0.0.7

func (v VoterIndex) Valid() bool

Valid checks that the VoterIndex is within the allowed range.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL