Skip to content
Snippets Groups Projects
Unverified Commit c0bf4fc9 authored by Angelo Capossele's avatar Angelo Capossele Committed by GitHub
Browse files

:bug: Fix missing dpk (#786)

parent db0d8ac1
No related branches found
No related tags found
No related merge requests found
...@@ -38,6 +38,11 @@ func (d *DRNG) Dispatch(issuer ed25519.PublicKey, timestamp time.Time, payload * ...@@ -38,6 +38,11 @@ func (d *DRNG) Dispatch(issuer ed25519.PublicKey, timestamp time.Time, payload *
return err return err
} }
// update the dpk (if not set) from the valid beacon
if len(d.State[cbEvent.InstanceID].committee.DistributedPK) == 0 {
d.State[cbEvent.InstanceID].UpdateDPK(cbEvent.Dpk)
}
// trigger RandomnessEvent // trigger RandomnessEvent
d.Events.Randomness.Trigger(d.State[cbEvent.InstanceID]) d.Events.Randomness.Trigger(d.State[cbEvent.InstanceID])
......
...@@ -125,6 +125,14 @@ func (s *State) UpdateCommittee(c *Committee) { ...@@ -125,6 +125,14 @@ func (s *State) UpdateCommittee(c *Committee) {
s.committee = c s.committee = c
} }
// UpdateDPK updates the distributed public key of the DRNG state
func (s *State) UpdateDPK(dpk []byte) {
s.mutex.Lock()
defer s.mutex.Unlock()
s.committee.DistributedPK = make([]byte, PublicKeySize)
copy(s.committee.DistributedPK[:], dpk[:PublicKeySize])
}
// Committee returns the committee of the DRNG state // Committee returns the committee of the DRNG state
func (s *State) Committee() Committee { func (s *State) Committee() Committee {
s.mutex.RLock() s.mutex.RLock()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment