Skip to content
Snippets Groups Projects
Select Git revision
  • 577066c673cc5cfff1658a38d24156e25c79b191
  • release default
  • master protected
  • feature/xx-4717/logLevel
  • XX-4626/SingleUsePackage
  • josh/DmPackage
  • xx-4437/no-registration
  • feature/project/DM
  • project/channels
  • feature/ctidh
  • Jakub/rootless-CI
  • jono/wasmDemo
  • feature/XX-4108/updateProtoc
  • feature/hotfix/unsafe_send_to_self
  • Anne/OldSessionTesting
  • hotfix/groupChat
  • josh/groupCreationScript
  • feature/XX-3797/restore
  • feature/XX-3789/DeleteIndividualRequests
  • dev
  • feature/debugSendCMIX
21 results

run.sh

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)
    }