Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions merkletree/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ Initiate the history hash chain (the persistent authenticated dictionary)
signKey := crypto.GenerateKey()

// init STR history chain with maximum length is len
// using DefaultPolicies as current policy
pad := NewPAD(NewPolicies(epochDeadline), signKey, len)
pad := NewPAD(NewPolicies(epochDeadline, vrfPrivKey), signKey, len)
```

Update tree in each epoch
Expand All @@ -26,7 +25,7 @@ pad.Update(nil)

Look-up

`LookUp(key)` and `LookUpInEpoch(key, epoch)` return a `MerkleNode` instance and an `AuthenticationPath` for proofs of inclusion/absence.
`LookUp(key)` and `LookUpInEpoch(key, epoch)` return an `AuthenticationPath` for proofs of inclusion/absence.
A proof of absence also includes an empty leaf node in the returned auth path.

### TODO
Expand Down
12 changes: 6 additions & 6 deletions merkletree/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ type Policies interface {
vrfPrivate() *[vrf.SecretKeySize]byte
}

type DefaultPolicies struct {
type ConiksPolicies struct {
vrfPrivateKey *[vrf.SecretKeySize]byte
epochDeadline TimeStamp
}

var _ Policies = (*DefaultPolicies)(nil)
var _ Policies = (*ConiksPolicies)(nil)

func NewPolicies(epDeadline TimeStamp, vrfPrivKey *[vrf.SecretKeySize]byte) Policies {
return &DefaultPolicies{
return &ConiksPolicies{
epochDeadline: epDeadline,
vrfPrivateKey: vrfPrivKey,
}
}

// Serialize encodes the policy to a byte array with the following format:
// [lib version, cryptographic algorithm in use, epoch deadline]
func (p *DefaultPolicies) Serialize() []byte {
func (p *ConiksPolicies) Serialize() []byte {
var bs []byte
bs = append(bs, []byte(Version)...) // lib Version
bs = append(bs, []byte(crypto.HashID)...) // cryptographic algorithms in use
Expand All @@ -39,10 +39,10 @@ func (p *DefaultPolicies) Serialize() []byte {
return bs
}

func (p *DefaultPolicies) vrfPrivate() *[vrf.SecretKeySize]byte {
func (p *ConiksPolicies) vrfPrivate() *[vrf.SecretKeySize]byte {
return p.vrfPrivateKey
}

func (p *DefaultPolicies) EpochDeadline() TimeStamp {
func (p *ConiksPolicies) EpochDeadline() TimeStamp {
return p.epochDeadline
}