Skip to content
Snippets Groups Projects
Select Git revision
  • cb6cbedf70c34555cc5f7c6e28b252ce92f2fbaa
  • release default protected
  • 11-22-implement-kv-interface-defined-in-collectiveversionedkvgo
  • hotfix/TestHostPool_UpdateNdf_AddFilter
  • XX-4719/announcementChannels
  • xx-4717/logLevel
  • jonah/noob-channel
  • master protected
  • XX-4707/tagDiskJson
  • xx-4698/notification-retry
  • hotfix/notifylockup
  • syncNodes
  • hotfix/localCB
  • XX-4677/NewChanManagerMobile
  • XX-4689/DmSync
  • duplicatePrefix
  • XX-4601/HavenInvites
  • finalizedUICallbacks
  • XX-4673/AdminKeySync
  • debugNotifID
  • anne/test
  • v4.7.5
  • v4.7.4
  • v4.7.3
  • v4.7.2
  • v4.7.1
  • v4.6.3
  • v4.6.1
  • v4.5.0
  • v4.4.4
  • v4.3.11
  • v4.3.8
  • v4.3.7
  • v4.3.6
  • v4.3.5
  • v4.2.0
  • v4.3.0
  • v4.3.4
  • v4.3.3
  • v4.3.2
  • v4.3.1
41 results

restlikeSingle.go

Blame
  • IdentityUse.go 1.72 KiB
    package reception
    
    import (
    	"github.com/pkg/errors"
    	"gitlab.com/elixxir/crypto/hash"
    	"gitlab.com/elixxir/primitives/knownRounds"
    	"gitlab.com/xx_network/crypto/randomness"
    	"gitlab.com/xx_network/primitives/id"
    	"io"
    	"math/big"
    	"time"
    )
    
    type IdentityUse struct{
    	Identity
    
    	//randomly generated time to poll between
    	StartRequest time.Time	//timestamp to request the start of bloom filters
    	EndRequest time.Time	//timestamp to request the End of bloom filters
    
    	// denotes if the identity is fake, in which case we do not process
    	// messages
    	Fake bool
    
    	//rounds data
    	KR KnownRounds
    }
    
    // setSamplingPeriod add the Request mask as a random buffer around the sampling
    // time to obfuscate it
    func (iu IdentityUse)setSamplingPeriod(rng io.Reader)(IdentityUse, error){
    
    	//generate the seed
    	seed := make([]byte,32)
    	if _, err := rng.Read(seed);err!=nil{
    		return IdentityUse{}, errors.WithMessage(err, "Failed to " +
    			"choose id due to rng failure")
    	}
    
    	h, err := hash.NewCMixHash()
    	if err!=nil{
    		return IdentityUse{}, err
    	}
    
    	//calculate the period offset
    	periodOffset :=
    		randomness.RandInInterval(big.NewInt(iu.RequestMask.Nanoseconds()),
    			seed,h).Int64()
    	iu.StartRequest = iu.StartValid.Add(-time.Duration(periodOffset))
    	iu.EndRequest = iu.EndValid.Add(iu.RequestMask -
    		time.Duration(periodOffset))
    	return iu, nil
    }
    
    type KnownRounds interface{
    	Checked(rid id.Round) bool
    	Check(rid id.Round)
    	Forward(rid id.Round)
    	RangeUnchecked(newestRid id.Round, roundCheck func(id id.Round) bool)
    	RangeUncheckedMasked(mask *knownRounds.KnownRounds,
    		roundCheck knownRounds.RoundCheckFunc, maxChecked int)
    	RangeUncheckedMaskedRange(mask *knownRounds.KnownRounds,
    		roundCheck knownRounds.RoundCheckFunc, start, end id.Round, maxChecked int)
    }