diff --git a/network/follow.go b/network/follow.go index 3d5d8734b83c5892aae387e55e9e4ab6dba23e38..b813bb0fb3607fb4c1ac14f4f9370ab2c16888bf 100644 --- a/network/follow.go +++ b/network/follow.go @@ -104,16 +104,16 @@ func (m *manager) follow(report interfaces.ClientErrorReport, rng csprng.Source, }, LastUpdate: uint64(m.Instance.GetLastUpdateID()), ReceptionID: identity.EphId[:], - StartTimestamp: identity.StartRequest.UnixNano(), - EndTimestamp: identity.EndRequest.UnixNano(), + StartTimestamp: identity.StartValid.UnixNano(), + EndTimestamp: identity.EndValid.UnixNano(), ClientVersion: []byte(version.String()), FastPolling: m.param.FastPolling, } result, err := m.GetSender().SendToAny(func(host *connect.Host) (interface{}, error) { jww.DEBUG.Printf("Executing poll for %v(%s) range: %s-%s(%s) from %s", - identity.EphId.Int64(), identity.Source, identity.StartRequest, - identity.EndRequest, identity.EndRequest.Sub(identity.StartRequest), host.GetId()) + identity.EphId.Int64(), identity.Source, identity.StartValid, + identity.EndValid, identity.StartValid.Sub(identity.EndValid), host.GetId()) return comms.SendPoll(host, &pollReq) }, stop) diff --git a/single/transmission.go b/single/transmission.go index c896eb7e954e55fddc7b99513635461dc755de2f..a6ceed465f53aeca901521d02499a823c9312d8e 100644 --- a/single/transmission.go +++ b/single/transmission.go @@ -95,7 +95,6 @@ func (m *Manager) transmitSingleUse(partner contact2.Contact, payload []byte, ExtraChecks: 10, StartValid: timeStart.Add(-2 * timeout), EndValid: timeStart.Add(2 * timeout), - RequestMask: 48*time.Hour - timeout, Ephemeral: true, }) if err != nil { diff --git a/storage/reception/IdentityUse.go b/storage/reception/IdentityUse.go index 08f1a070aadc0ac5271156516e860371c0ca7daa..92d1ed8c95ab33dfad5c5ff2fa9ec9be2d7e3a63 100644 --- a/storage/reception/IdentityUse.go +++ b/storage/reception/IdentityUse.go @@ -2,24 +2,14 @@ package reception import ( "fmt" - "github.com/pkg/errors" "gitlab.com/elixxir/client/storage/rounds" - "gitlab.com/elixxir/crypto/hash" - "gitlab.com/xx_network/crypto/randomness" - "io" - "math/big" "strconv" "strings" - "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 @@ -28,36 +18,12 @@ type IdentityUse struct { CR *rounds.CheckedRounds } -// 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 -} - func (iu IdentityUse) GoString() string { str := make([]string, 0, 7) str = append(str, "Identity:"+iu.Identity.GoString()) - str = append(str, "StartRequest:"+iu.StartRequest.String()) - str = append(str, "EndRequest:"+iu.EndRequest.String()) + str = append(str, "StartValid:"+iu.StartValid.String()) + str = append(str, "EndValid:"+iu.EndValid.String()) str = append(str, "Fake:"+strconv.FormatBool(iu.Fake)) str = append(str, "UR:"+fmt.Sprintf("%+v", iu.UR)) str = append(str, "ER:"+fmt.Sprintf("%+v", iu.ER)) diff --git a/storage/reception/fake.go b/storage/reception/fake.go index 3e6ba00fc711c097b7b765027962e60dc81d98bb..1e4e0a31c01b8d5b4df90cc84864937824b9a5bf 100644 --- a/storage/reception/fake.go +++ b/storage/reception/fake.go @@ -40,7 +40,6 @@ func generateFakeIdentity(rng io.Reader, addressSize uint8, ExtraChecks: 0, StartValid: start, EndValid: end, - RequestMask: 24 * time.Hour, Ephemeral: true, }, Fake: true, diff --git a/storage/reception/fake_test.go b/storage/reception/fake_test.go index 0cb52480ac8eb3b713f9334eefa1dad9b4351dc3..3e9ab209cd7279aeb97ade25a2227a82b1c42940 100644 --- a/storage/reception/fake_test.go +++ b/storage/reception/fake_test.go @@ -25,9 +25,8 @@ func Test_generateFakeIdentity(t *testing.T) { "\"End\":" + string(end) + ",\"ExtraChecks\":0," + "\"StartValid\":" + string(startValid) + "," + "\"EndValid\":" + string(endValid) + "," + - "\"RequestMask\":86400000000000,\"Ephemeral\":true," + - "\"StartRequest\":\"0001-01-01T00:00:00Z\"," + - "\"EndRequest\":\"0001-01-01T00:00:00Z\",\"Fake\":true,\"UR\":null,\"ER\":null,\"CR\":null}" + "\"Ephemeral\":true," + + "\"Fake\":true,\"UR\":null,\"ER\":null,\"CR\":null}" timestamp := time.Date(2009, 11, 17, 20, 34, 58, 651387237, time.UTC) diff --git a/storage/reception/identity.go b/storage/reception/identity.go index 5d0721e5c0830edbb01b6e95ea8a6f63ad0bf638..4ae3f9564e3bec5d2ad6441cdc76fa9fbe2e6433 100644 --- a/storage/reception/identity.go +++ b/storage/reception/identity.go @@ -27,10 +27,8 @@ type Identity struct { // ID exits active // Polling parameters - StartValid time.Time // Timestamp when the ephID begins being valid - EndValid time.Time // Timestamp when the ephID stops being valid - RequestMask time.Duration // Amount of extra time requested for the poll in - // order to mask the exact valid time for the ID + StartValid time.Time // Timestamp when the ephID begins being valid + EndValid time.Time // Timestamp when the ephID stops being valid // Makes the identity not store on disk Ephemeral bool @@ -92,7 +90,6 @@ func (i Identity) GoString() string { str = append(str, "ExtraChecks:"+strconv.FormatUint(uint64(i.ExtraChecks), 10)) str = append(str, "StartValid:"+i.StartValid.String()) str = append(str, "EndValid:"+i.EndValid.String()) - str = append(str, "RequestMask:"+i.RequestMask.String()) str = append(str, "Ephemeral:"+strconv.FormatBool(i.Ephemeral)) return "{" + strings.Join(str, ", ") + "}" @@ -106,6 +103,5 @@ func (i Identity) Equal(b Identity) bool { i.ExtraChecks == b.ExtraChecks && i.StartValid.Equal(b.StartValid) && i.EndValid.Equal(b.EndValid) && - i.RequestMask == b.RequestMask && i.Ephemeral == b.Ephemeral } diff --git a/storage/reception/identityUse_test.go b/storage/reception/identityUse_test.go deleted file mode 100644 index e54d73e723a4daa8365f34e446c60916a43ca3dd..0000000000000000000000000000000000000000 --- a/storage/reception/identityUse_test.go +++ /dev/null @@ -1,67 +0,0 @@ -package reception - -import ( - "math/rand" - "testing" - "time" -) - -func TestIdentityUse_SetSamplingPeriod(t *testing.T) { - rng := rand.New(rand.NewSource(42)) - - const numTests = 1000 - - for i := 0; i < numTests; i++ { - // Generate an identity use - start := randate() - end := start.Add(time.Duration(rand.Uint64() % uint64(92*time.Hour))) - mask := time.Duration(rand.Uint64() % uint64(92*time.Hour)) - iu := IdentityUse{ - Identity: Identity{ - StartValid: start, - EndValid: end, - RequestMask: mask, - }, - } - - // Generate the sampling period - var err error - iu, err = iu.setSamplingPeriod(rng) - if err != nil { - t.Errorf("Errored in generatign sampling "+ - "period on interation %v: %+v", i, err) - } - - // Test that the range between the periods is correct - resultRange := iu.EndRequest.Sub(iu.StartRequest) - expectedRange := iu.EndValid.Sub(iu.StartValid) + iu.RequestMask - - if resultRange != expectedRange { - t.Errorf("The generated sampling period is of the wrong "+ - "size: Expecterd: %s, Received: %s", expectedRange, resultRange) - } - - // Test the sampling range does not exceed a reasonable lower bound - lowerBound := iu.StartValid.Add(-iu.RequestMask) - if !iu.StartRequest.After(lowerBound) { - t.Errorf("Start request exceeds the reasonable lower "+ - "bound: \n\t Bound: %s\n\t Start: %s", lowerBound, iu.StartValid) - } - - // Test the sampling range does not exceed a reasonable upper bound - upperBound := iu.EndValid.Add(iu.RequestMask - time.Millisecond) - if iu.EndRequest.After(upperBound) { - t.Errorf("End request exceeds the reasonable upper bound") - } - } - -} - -func randate() time.Time { - min := time.Date(1970, 1, 0, 0, 0, 0, 0, time.UTC).Unix() - max := time.Date(2070, 1, 0, 0, 0, 0, 0, time.UTC).Unix() - delta := max - min - - sec := rand.Int63n(delta) + min - return time.Unix(sec, 0) -} diff --git a/storage/reception/identity_test.go b/storage/reception/identity_test.go index 1fada0d707c848b5d2ea9f66398b4c1cc2c5a0c7..0993a0e2af2d37caef6841d8d8b2574faef418b2 100644 --- a/storage/reception/identity_test.go +++ b/storage/reception/identity_test.go @@ -21,7 +21,6 @@ func TestIdentity_EncodeDecode(t *testing.T) { ExtraChecks: 12, StartValid: netTime.Now().Round(0), EndValid: netTime.Now().Round(0), - RequestMask: 2 * time.Hour, Ephemeral: false, } @@ -51,7 +50,6 @@ func TestIdentity_Delete(t *testing.T) { ExtraChecks: 12, StartValid: netTime.Now().Round(0), EndValid: netTime.Now().Round(0), - RequestMask: 2 * time.Hour, Ephemeral: false, } diff --git a/storage/reception/store.go b/storage/reception/store.go index b6bdf41f7db520e5e9d88880a1246ced9dc2b3b0..7a22c05f4ea7c2609ad0c835a69c31983346eefe 100644 --- a/storage/reception/store.go +++ b/storage/reception/store.go @@ -165,12 +165,6 @@ func (s *Store) GetIdentity(rng io.Reader, addressSize uint8) (IdentityUse, erro } } - // Calculate the sampling period - identity, err = identity.setSamplingPeriod(rng) - if err != nil { - jww.FATAL.Panicf("Failed to calculate the sampling period: %+v", err) - } - return identity, nil }