commitment

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateCommitmentWithoutValidation

func GenerateCommitmentWithoutValidation(policyId string, actor *coretypes.Actor, objs []*coretypes.Object) ([]byte, error)

GenerateCommitmentWithoutValidation generates a byte commitment (merkle root) of the given set of objects. It does not verify whether the given objects are registered or valid against the given policy.

func GenerateLeafValue

func GenerateLeafValue(policyId string, actor *coretypes.Actor, o *coretypes.Object) []byte

GenerateLeafValue produces a byte slice representing an individual object registration which will be commited to.

The leaf value is the concatenation of PolicyId, object resource, object id and actor Id

func ProofForObject

func ProofForObject(policyId string, actor *coretypes.Actor, idx int, objs []*coretypes.Object) (*types.RegistrationProof, error)

ProofForObject generated an opening Proof for the given objects, actor and policy id

func VerifyProof

func VerifyProof(root []byte, policyId string, actor *coretypes.Actor, opening *types.RegistrationProof) (bool, error)

VerifyProof consumes a root hash of a merkle tree, policy id, actor and an opening proof and verify whether the proof is a valid merkle tree proof.

Returns true if the proof is valid, false if it's not or an error if the opening is malformed

Types

type CommitmentRepository

type CommitmentRepository struct {
	// contains filtered or unexported fields
}

CommitmentRepository exposes an interface to manipulate RegistrationsCommitment records

func NewCommitmentRepository

func NewCommitmentRepository(kv store.KVStore) (*CommitmentRepository, error)

NewCommitmentRepository returns a CommitmentRepository from a kv

func (*CommitmentRepository) FilterByCommitment

func (r *CommitmentRepository) FilterByCommitment(ctx context.Context, commitment []byte) (iterator.Iterator[*types.RegistrationsCommitment], error)

FilterByCommitment returns all RegistrationCommitment records with the given commitment

func (*CommitmentRepository) GetById

GetById returns a RegistrationCommitment with the given id

func (*CommitmentRepository) GetNonExpiredCommitments

GetNonExpiredCommitments returns all commitments whose expiration flag is false

type CommitmentService

type CommitmentService struct {
	// contains filtered or unexported fields
}

CommitmentService abstracts registration commitment operations

func NewCommitmentService

func NewCommitmentService(engine coretypes.ACPEngineServer, repository *CommitmentRepository) *CommitmentService

func (*CommitmentService) BuildCommitment

func (s *CommitmentService) BuildCommitment(ctx sdk.Context, policyId string, actor *coretypes.Actor, objects []*coretypes.Object) ([]byte, error)

BuildCommitment produces a byte commitment for actor and objects. The commitment is guaranteed to be valid, as we verify that no object has been registered yet.

func (*CommitmentService) FlagExpiredCommitments

func (s *CommitmentService) FlagExpiredCommitments(ctx sdk.Context) ([]*types.RegistrationsCommitment, error)

FlagExpiredCommitments iterates over stored commitments, filters for expired commitments wrt the current block time, flags them as expired and returns the newly expired commitments

func (*CommitmentService) SetNewCommitment

func (s *CommitmentService) SetNewCommitment(ctx sdk.Context, policyId string, commitment []byte, actor *coretypes.Actor, params *types.Params, msgCreator string) (*types.RegistrationsCommitment, error)

SetNewCommitment sets a new RegistrationCommitment

func (*CommitmentService) ValidateOpening

func (s *CommitmentService) ValidateOpening(ctx sdk.Context, commitmentId uint64, proof *types.RegistrationProof, actor *coretypes.Actor) (*types.RegistrationsCommitment, bool, error)

ValidateOpening verifies whether the given opening proof is valid for the authenticated actor and the objects returns true if opening is valid

type RegistrationCommitmentTree

type RegistrationCommitmentTree struct {
	// contains filtered or unexported fields
}

RegistrationCommitmentTree is a helper to generate openings and roots for a set of objects

func NewObjectCommitmentTree

func NewObjectCommitmentTree(policyId string, actor *coretypes.Actor, objs []*coretypes.Object) (*RegistrationCommitmentTree, error)

NewObjectCommitmentTree returns a RegistrationCommitmentTree for the given objects

func (*RegistrationCommitmentTree) GetCommitment

func (t *RegistrationCommitmentTree) GetCommitment() []byte

GetCommitment returns the merkle tree for the tree

func (*RegistrationCommitmentTree) GetProofForIdx

func (t *RegistrationCommitmentTree) GetProofForIdx(i int) (*types.RegistrationProof, error)

GetProofForIdx returns an opening proof for the i-th object

func (*RegistrationCommitmentTree) GetProofForObj

GetProofForObject returns an opening proof for the given object If the object was not included in the tree, errors

Jump to

Keyboard shortcuts

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