cmd

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateZKCert added in v1.8.0

func CreateZKCert[T zkcertificate.Content](
	certificateContent T,
	holderCommitment zkcertificate.HolderCommitment,
	providerKey babyjub.PrivateKey,
	expirationDate time.Time,
) (*zkcertificate.Certificate[T], error)

CreateZKCert generates a zero-knowledge certificate (ZKCert) based on the provided holder's commitment, certificate content, and the private key of the provider.

This function performs the following steps:

  1. Hashes the certificate content.
  2. Signs the certificate using the provider's private key and the hashed values.
  3. Generates a random salt within the range [1, MaxInt64].
  4. Constructs and returns the ZKCert.

Certificate standard is inferred from the certificateContent using method zkcertificate.Content.Standard.

func EncryptZKCert added in v1.8.0

EncryptZKCert encrypts a zero-knowledge certificate using the holder's commitment encryption key.

func GenerateEdDSAKeyPair added in v1.8.0

func GenerateEdDSAKeyPair(ethereumPrivateKey *ecdsa.PrivateKey) (babyjub.PrivateKey, error)

GenerateEdDSAKeyPair generates an EdDSA key pair.

The function performs the following steps:

  1. If an Ethereum private key is provided, derives the EdDSA private key from it.
  2. If no Ethereum private key is provided, generates a random EdDSA private key.

func IssueZKCert added in v1.8.0

func IssueZKCert[T zkcertificate.Content](
	ctx context.Context,
	cert zkcertificate.Certificate[T],
	ethRPC EthereumIssueClient,
	merkleProofClient merkle.EmptyLeafProver,
	registryAddress common.Address,
	providerKey *ecdsa.PrivateKey,
) (*types.Transaction, zkcertificate.IssuedCertificate[T], error)

IssueZKCert registers and issues a zero-knowledge certificate (ZKCert) on-chain.

The function performs the following steps:

  1. Verifies that the provider is authorized as a guardian.
  2. Finds an empty leaf in the Merkle tree for certificate registration.
  3. Registers the certificate and waits for the provider's turn to issue it.
  4. Constructs and sends the transaction to add the certificate on-chain.

func NewCmdCreateZKCert

func NewCmdCreateZKCert() *cobra.Command

func NewCmdEncryptZKCert

func NewCmdEncryptZKCert() *cobra.Command

func NewCmdGenerateEdDSAKeyPair

func NewCmdGenerateEdDSAKeyPair() *cobra.Command

func NewCmdIssueZKCert

func NewCmdIssueZKCert() *cobra.Command

func NewCmdPrintEdDSAPublicKey added in v1.7.0

func NewCmdPrintEdDSAPublicKey() *cobra.Command

func NewCmdRenewZKCert

func NewCmdRenewZKCert() *cobra.Command

func NewCmdRevokeZKCert

func NewCmdRevokeZKCert() *cobra.Command

func NewRootCmd

func NewRootCmd() *cobra.Command

func PrintEdDSAPublicKey added in v1.7.0

func PrintEdDSAPublicKey(privateKey babyjub.PrivateKey, w io.Writer) error

PrintEdDSAPublicKey writes the EdDSA public key which corresponds to the given private key.

func RenewZKCert added in v1.8.0

func RenewZKCert[T zkcertificate.Content](
	certificate zkcertificate.Certificate[T],
	providerKey babyjub.PrivateKey,
	expirationDate time.Time,
) (*zkcertificate.Certificate[T], error)

RenewZKCert renews an existing zero-knowledge certificate (ZKCert) by creating a new certificate with an updated expiration date.

func RevokeZKCert added in v1.8.0

func RevokeZKCert[T zkcertificate.Content](
	ctx context.Context,
	certificate zkcertificate.IssuedCertificate[T],
	client EthereumRevokeClient,
	merkleProofClient merkle.Prover,
	providerKey *ecdsa.PrivateKey,
) (*types.Transaction, error)

RevokeZKCert revokes an issued zero-knowledge certificate (ZKCert) by removing it from the blockchain registry.

The function performs the following steps:

  1. Verifies that the provider is authorized as a guardian.
  2. Retrieves the Merkle proof for the certificate to be revoked.
  3. Registers the provider for revocation and waits for its turn.
  4. Constructs and sends the transaction to revoke the certificate.

Types

type EthereumIssueClient added in v1.8.0

type EthereumIssueClient interface {
	bind.ContractBackend
	bind.DeployBackend

	ChainID(ctx context.Context) (*big.Int, error)
}

type EthereumRevokeClient added in v1.8.0

type EthereumRevokeClient interface {
	bind.ContractBackend
	bind.DeployBackend

	ChainID(ctx context.Context) (*big.Int, error)
}

type RecordRegistryAddressCaller added in v1.7.2

type RecordRegistryAddressCaller interface {
	GuardianRegistry(opts *bind.CallOpts) (common.Address, error)
}

type RecordRegistryCertificateRevoker added in v1.7.2

type RecordRegistryCertificateRevoker interface {
	RevokeZkCertificate(
		opts *bind.TransactOpts,
		leafIndex *big.Int,
		zkCertificateHash [32]byte,
		merkleProof [][32]byte,
	) (*types.Transaction, error)
}

type RecordRegistryQueue added in v1.7.2

type RecordRegistryQueue interface {
	CheckZkCertificateHashInQueue(opts *bind.CallOpts, zkCertificateHash [32]byte) (bool, error)
	RegisterToQueue(opts *bind.TransactOpts, zkCertificateHash [32]byte) (*types.Transaction, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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