Skip to content

Commit

Permalink
history committer
Browse files Browse the repository at this point in the history
  • Loading branch information
rauljordan committed Sep 13, 2024
1 parent 8fb3a57 commit 3021b17
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions state-commitments/optimized/history_commitment.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,33 @@ import (

var emptyHash = common.Hash{}

type Commitment struct {
Height uint64
Merkle common.Hash
FirstLeaf common.Hash
LastLeafProof []common.Hash
FirstLeafProof []common.Hash
LastLeaf common.Hash
}

func NewCommitment(leaves []common.Hash, virtual uint64) (*Commitment, error) {
if len(leaves) == 0 {
return nil, errors.New("must commit to at least one leaf")
}
comm := NewCommitter()
root, err := comm.ComputeRoot(leaves, virtual)
if err != nil {
return nil, err
}
// TODO: Generate the inclusion proofs necessary.
return &Commitment{
Height: virtual,
Merkle: root,
FirstLeaf: leaves[0],
LastLeaf: leaves[len(leaves)-1],
}, nil
}

type HistoryCommitter struct {
lastLeafFillers []common.Hash
keccak crypto.KeccakState
Expand Down

0 comments on commit 3021b17

Please sign in to comment.