Renamed BroadcastTime/SentTime to CreationTime for every instance in which it is a better term to use.

This commit is contained in:
Simon Sarasova 2024-06-11 04:59:06 +00:00
parent edecfa4b16
commit 657e5a6c85
No known key found for this signature in database
GPG key ID: EEDA4103C9C36944
51 changed files with 487 additions and 494 deletions

View file

@ -6,6 +6,7 @@ Small and insignificant changes may not be included in this log.
## Unversioned Changes
* Renamed BroadcastTime/SentTime to CreationTime for every instance in which it is a better term to use. - *Simon Sarasova*
* Added "User Has Disease" information to the View Profile - Monogenic Diseases page. - *Simon Sarasova*
* Created the calculatedAttributes_test package. - *Simon Sarasova*
* Improved the creation process of genetic analyses in various ways. A sample of offspring polygenic disease risk scores are now created and viewable by users. - *Simon Sarasova*

View file

@ -9,4 +9,4 @@ Many other people have written code for modules which are imported by Seekia. Th
Name | Date Of First Commit | Number Of Commits
--- | --- | ---
Simon Sarasova | June 13, 2023 | 253
Simon Sarasova | June 13, 2023 | 254

View file

@ -159,13 +159,13 @@ Use descriptive variable names. This may make lines and variable names seem exce
#### Bad:
```Go
passed := now - profBTime
passed := now - profCTime
```
#### Good:
```Go
timePassed := currentTime - profileBroadcastTime
timePassed := currentTime - profileCreationTime
```
### 3. Use Parentheses around if statements

View file

@ -147,7 +147,7 @@ For example, when downloaing sensitive content such as a user's messages, a new
Each request contains information about a requestor, which could be used to link a requestor to a Seekia user and/or understand their behavior.
A simple example is a host, who requests profiles within a specific range, and broadcasts that range on their public host profile. If that host is the only host using that range, any download requests made for that range will be trivially linkable to that host. This is why requests must be broken up by type, sent to different hosts, and crafted in such a way that hosts learn as little as possible about the requestor.
A simple example is a host, who requests profiles within a specific range, and shares that range on their public host profile. If that host is the only host using that range, any download requests made for that range will be trivially linkable to that host. This is why requests must be broken up by type, sent to different hosts, and crafted in such a way that hosts learn as little as possible about the requestor.
Imagine the example of a user who wants to check for new profiles for 100 downloaded mate profile authors. If they send those 100 authors in a single request, that host now knows that requestor has 100 mate profiles created by those authors downloaded. After offering a list of profiles, hosts will also be able to tell which profiles the user has already downloaded by seeing which profiles the user skips downloading.
@ -350,7 +350,7 @@ Moderator identity scores do not rely on the account server. Moderators use cryp
All communication between the database, the interface servers, hosts, and clients must be encrypted with Nacl and Kyber.
Another use of the servers could be timestamping of messages. The servers could be a source of truth for when a message was sent. If the sender-alleged sent time conflicts with the account credit server by more than 1 minute, a warning could be shown. Otherwise, sent times could be relied upon.
Another use of the servers could be timestamping of messages. The servers could be a source of truth for when a message was sent. If the sender-alleged message creation time conflicts with the account credit server by more than 1 minute, a warning could be shown. Otherwise, message creation times could be relied upon.
Hosts get their hosted message/profile/report funded statuses from the account credit servers. Mate/Moderator users get the message funded statuses from the credit servers, and the profile funded statuses from hosts. This is done to reduce the load on the account credit interface servers, and to enable the network to maintain more functionality if the account credit servers go offline.
@ -703,7 +703,7 @@ Users who want to use multiple devices simultaneously could instead remotely acc
All conversations are initiated to a user public inboxes.
Responses that are sent within the message sent time's current or next secret inbox epoch will be sent to user secret inboxes.
Responses that are sent within the message creation time's current or next secret inbox epoch will be sent to user secret inboxes.
If a secret inbox received a new message immediately after Bob's public inbox receives one, an observer could guess that that message was a response from Bob. This becomes much more difficult to guess as more users join Seekia.
@ -911,7 +911,7 @@ Full profile reviews still exist because moderators sometimes have to ban profil
### Undoing Reviews
There is a third type of verdict called a **None** verdict. These verdicts are used to undo previous verdicts. A review with a newer BroadcastTime is created for the same reviewedHash, and the old review is eventually discarded. The old review may be kept on the network if the review was used as a reason for banning the moderator in any identity ban reviews.
There is a third type of verdict called a **None** verdict. These verdicts are used to undo previous verdicts. A review with a newer CreationTime is created for the same reviewedHash, and the old review is eventually discarded. The old review may be kept on the network if the review was used as a reason for banning the moderator in any identity ban reviews.
Attribute reviews add complexity to how a profile's reviews are undone. If a moderator bans an attribute, and later approves the full profile, then the attribute review is disregarded. If a moderator approves a full profile, and later bans an attribute from that profile, the full profile approval is disregarded.

View file

@ -175,14 +175,6 @@ When the mode is disabled, we only delete profiles that do not fulfill our crite
We need to create jobs to check for this condition and prune profiles which do not fulfill our desires.
### Rename BroadcastTime to CreationTime
Profiles, reviews, reports, and parameters currently have a BroadcastTime attribute.
This really should be called CreationTime.
Broadcasting is the process of uploading content to the network, which is typically done multiple times.
### Suspicious Hosts
The app should maintain a list of Malicious hosts and Suspicious hosts.

View file

@ -76,9 +76,9 @@ The Value String section describes the map entry values encoded as String, which
* Description: Minimum number of admins needed to sign the parameters file
* Value Bytes: `int`
* Value String: `int` encoded as String
* **(ParametersType)_MinimumBroadcastTime**
* **(ParametersType)_MinimumCreationTime**
* Description:
* The minimum broadcast time required for the parametersType.
* The minimum creation time required for the parametersType.
* This is useful if old parameters become the newest valid parameters again, after admins are changed.
* This allows for any maliciously authored parameters to be rejected, by setting this time after they were authored.
* Value Bytes: `int64`
@ -120,13 +120,13 @@ The Value String section describes the map entry values encoded as String, which
* **MateInactivityExpirationTime**
* Description:
* Number of seconds until a Mate profile is dropped from the network
* The profile's BroadcastTime must be younger than this time.
* The profile's CreationTime must be younger than this time.
* Value Bytes: `int`
* Value String: `int` encoded as String
* **HostInactivityExpirationTime**
* Description:
* Number of seconds until a Host profile is dropped from the network
* The profile's BroadcastTime must be younger than this time.
* The profile's CreationTime must be younger than this time.
* Value Bytes: `int`
* Value String: `int` encoded as String
@ -404,11 +404,11 @@ Whenever a string value is described for the bytes value, we are encoding the st
* Is Required: Yes
* Mandatory Attributes: All other required attributes
* Is Canonical: Always
* **BroadcastTime**
* **CreationTime**
* Attribute Identifier: TODO (see profileFormat.go)
* Profile Types: Mate/Host/Moderator
* Description: Time that profile was broadcast
* Value Bytes: Integer number of seconds after unix origin time that profile was broadcasted
* Description: Time that profile was created
* Value Bytes: Integer number of seconds after unix origin time that profile was created
* Value String: Int64 encoded as string
* Is Required: Yes
* Mandatory Attributes: All other required attributes
@ -1326,9 +1326,9 @@ The string representation is used to read the review into a `map[string]string`.
* Value Bytes: `[32]byte`
* Value string: `[32]byte` encoded in Hex
* Is Required: Yes
* **BroadcastTime**
* **CreationTime**
* Field Identifier: TODO (see readReviews.go)
* Description: Unix Broadcast Time (Number of seconds after unix origin time that the review was broadcast)
* Description: Unix Creation Time (Number of seconds after unix origin time that the review was created)
* Value Bytes: `int64`
* Value String: `int64` encoded as String
* Is Required: Yes
@ -1426,9 +1426,9 @@ The string representation is used to read the report into a `map[string]string`.
* Value Bytes: `byte`
* Value String: `byte` encoded as String
* Is Required: Yes
* **BroadcastTime**
* **CreationTime**
* Field Identifier: TODO (see readReports.go)
* Description: Unix Broadcast time of report (number of seconds after unix origin time representing broadcast time of report)
* Description: Unix creation time of report (number of seconds after unix origin time representing creation time of report)
* Value Bytes: `int64`
* Value String: `int64` encoded as String
* Is Required: Yes
@ -1810,7 +1810,7 @@ The `RecipientHost`, `RequestType`, `RequestIdentifier`, and `NetworkType` field
* *Nothing other than the standard fields.*
* Response:
* ParametersInfo: `map[string]int64`
* {ParametersType -> Parameters Broadcast Time} for each stored parameters (Empty if none exist)
* {ParametersType -> Parameters creation time} for each stored parameters (Empty if none exist)
* **GetParameters**
* Description:
* Used to retrieve parameters from a host
@ -1846,7 +1846,7 @@ The `RecipientHost`, `RequestType`, `RequestIdentifier`, and `NetworkType` field
* ProfileInfoStruct:
* ProfileHash: Profile hash `[28]byte`
* ProfileAuthor: Profile author identity hash `[16]byte`
* ProfileBroadcastTime: Profile Broadcast Time `int64`
* ProfileCreationTime: Profile Creation Time `int64`
* **GetProfiles**
* Description:

View file

@ -243,7 +243,7 @@ func setBroadcastPage(window fyne.Window, profileType string, previousPage func(
// We will determine how long this current profile has until it is expired
// The user has to broadcast a profile again to reset this countdown
myIdentityExists, myProfileExists, _, myProfileAttributeExists, myProfileBroadcastTime, err := myBroadcasts.GetAnyAttributeFromMyBroadcastProfile(myIdentityHash, appNetworkType, "BroadcastTime")
myIdentityExists, myProfileExists, _, myProfileAttributeExists, myProfileCreationTime, err := myBroadcasts.GetAnyAttributeFromMyBroadcastProfile(myIdentityHash, appNetworkType, "CreationTime")
if (err != nil) { return err }
if (myIdentityExists == false) {
return errors.New("My identity not found after being found already.")
@ -252,19 +252,19 @@ func setBroadcastPage(window fyne.Window, profileType string, previousPage func(
return errors.New("My broadcast profile not found after myProfileStatus has already been determined to be active.")
}
if (myProfileAttributeExists == false){
return errors.New("My Broadcast profile malformed: Missing BroadcastTime")
return errors.New("My Broadcast profile malformed: Missing CreationTime")
}
myProfileBroadcastTimeInt64, err := helpers.ConvertBroadcastTimeStringToInt64(myProfileBroadcastTime)
myProfileCreationTimeInt64, err := helpers.ConvertCreationTimeStringToInt64(myProfileCreationTime)
if (err != nil){
return errors.New("My Broadcast profile malformed: Contains invalid broadcastTime: " + myProfileBroadcastTime)
return errors.New("My Broadcast profile malformed: Contains invalid creationTime: " + myProfileCreationTime)
}
_, mateProfileMaximumExistenceDuration, err := getParameters.GetMateProfileMaximumExistenceDuration(appNetworkType)
if (err != nil) { return err }
currentTime := time.Now().Unix()
profileExistenceTime := currentTime - myProfileBroadcastTimeInt64
profileExistenceTime := currentTime - myProfileCreationTimeInt64
if (profileExistenceTime >= mateProfileMaximumExistenceDuration){
@ -486,18 +486,18 @@ func setBroadcastMyProfilePage(window fyne.Window, profileType string, previousP
getLastUpdatedTimeAgo := func()(string, error){
exists, lastBroadcastTimeString, err := readProfiles.GetFormattedProfileAttributeFromRawProfileMap(existingBroadcastProfileRawMap, "BroadcastTime")
exists, lastCreationTimeString, err := readProfiles.GetFormattedProfileAttributeFromRawProfileMap(existingBroadcastProfileRawMap, "CreationTime")
if (err != nil){ return "", err }
if (exists == false){
return "", errors.New("My broadcast profile missing BroadcastTime")
return "", errors.New("My broadcast profile missing CreationTime")
}
lastBroadcastTimeInt64, err := helpers.ConvertStringToInt64(lastBroadcastTimeString)
lastCreationTimeInt64, err := helpers.ConvertStringToInt64(lastCreationTimeString)
if (err != nil){
return "", errors.New("My broadcast profile contains invalid BroadcastTime: " + lastBroadcastTimeString)
return "", errors.New("My broadcast profile contains invalid CreationTime: " + lastCreationTimeString)
}
lastUpdatedTimeAgo, err := helpers.ConvertUnixTimeToTimeAgoTranslated(lastBroadcastTimeInt64, true)
lastUpdatedTimeAgo, err := helpers.ConvertUnixTimeToTimeAgoTranslated(lastCreationTimeInt64, true)
if (err != nil){ return "", err }
return lastUpdatedTimeAgo, nil
@ -542,7 +542,7 @@ func setBroadcastMyProfilePage(window fyne.Window, profileType string, previousP
attributeName, err := profileFormat.GetAttributeNameFromAttributeIdentifier(attributeIdentifier)
if (err != nil) { return 0, err }
if (attributeName == "BroadcastTime" || attributeName == "ChatKeysLatestUpdateTime" || attributeName == "NaclKey" || attributeName == "KyberKey"){
if (attributeName == "CreationTime" || attributeName == "ChatKeysLatestUpdateTime" || attributeName == "NaclKey" || attributeName == "KyberKey"){
continue
}
@ -759,7 +759,7 @@ func setViewNewProfileChangesPage(window fyne.Window, myProfileType string, prev
for _, attributeName := range allAttributeNamesList{
if (attributeName == "BroadcastTime" || attributeName == "Disabled" || attributeName == "ChatKeysLatestUpdateTime" || attributeName == "NaclKey" || attributeName == "KyberKey"){
if (attributeName == "CreationTime" || attributeName == "Disabled" || attributeName == "ChatKeysLatestUpdateTime" || attributeName == "NaclKey" || attributeName == "KyberKey"){
continue
}

View file

@ -1742,7 +1742,7 @@ func setViewAConversationPage(window fyne.Window, theirIdentityHash [16]byte, re
for _, messageObject := range messagesToDisplayList{
messageStatus := messageObject.MessageStatus
messageTimeSent := messageObject.TimeSent
messageCreationTime := messageObject.CreationTime
messageCommunication := messageObject.Communication
iAmSender := messageObject.IAmSender
@ -1980,7 +1980,7 @@ func setViewAConversationPage(window fyne.Window, theirIdentityHash [16]byte, re
messageContentBox, err := getMessageContentBox()
if (err != nil) { return nil, err }
timeSentAgoText, err := helpers.ConvertUnixTimeToTimeFromNowTranslated(messageTimeSent, false)
timeSentAgoText, err := helpers.ConvertUnixTimeToTimeFromNowTranslated(messageCreationTime, false)
if (err != nil) { return nil, err }
timeSentAgoLabel := getItalicLabel("Sent " + timeSentAgoText)
@ -1991,7 +1991,7 @@ func setViewAConversationPage(window fyne.Window, theirIdentityHash [16]byte, re
messageHash := messageObject.MessageHash
viewMessageDetailsButton := widget.NewButtonWithIcon("", theme.InfoIcon(), func(){
setViewMessageDetailsButton(window, messageHash, messageTimeSent, currentPage)
setViewMessageDetailsButton(window, messageHash, messageCreationTime, currentPage)
})
return viewMessageDetailsButton, nil
}
@ -2187,9 +2187,9 @@ func setViewAConversationPage(window fyne.Window, theirIdentityHash [16]byte, re
}
func setViewMessageDetailsButton(window fyne.Window, messageHash [26]byte, messageTimeSent int64, previousPage func()){
func setViewMessageDetailsButton(window fyne.Window, messageHash [26]byte, messageCreationTime int64, previousPage func()){
currentPage := func(){setViewMessageDetailsButton(window, messageHash, messageTimeSent, previousPage)}
currentPage := func(){setViewMessageDetailsButton(window, messageHash, messageCreationTime, previousPage)}
title := getPageTitleCentered("View Message Details")
@ -2214,21 +2214,21 @@ func setViewMessageDetailsButton(window fyne.Window, messageHash [26]byte, messa
messageHashRow := container.NewHBox(layout.NewSpacer(), messageHashLabel, messageHashText, viewMessageHashButton, layout.NewSpacer())
timeSentLabel := widget.NewLabel("Time Sent:")
timeCreatedLabel := widget.NewLabel("Time Created:")
messageSentTimeString := helpers.ConvertUnixTimeToTranslatedTime(messageTimeSent)
messageCreationTimeString := helpers.ConvertUnixTimeToTranslatedTime(messageCreationTime)
messageSentTimeLabel := getBoldLabel(messageSentTimeString)
messageCreationTimeLabel := getBoldLabel(messageCreationTimeString)
sentTimeWarningButton := widget.NewButtonWithIcon("", theme.WarningIcon(), func(){
title := translate("Sent Time Warning")
dialogMessageA := getLabelCentered("Sent times are not verified.")
creationTimeWarningButton := widget.NewButtonWithIcon("", theme.WarningIcon(), func(){
title := translate("Creation Time Warning")
dialogMessageA := getLabelCentered("Creation times are not verified.")
dialogMessageB := getLabelCentered("They can be faked by the message author.")
dialogContent := container.NewVBox(dialogMessageA, dialogMessageB)
dialog.ShowCustom(title, translate("Close"), dialogContent, window)
})
messageSentTimeRow := container.NewHBox(layout.NewSpacer(), timeSentLabel, messageSentTimeLabel, sentTimeWarningButton, layout.NewSpacer())
messageCreationTimeRow := container.NewHBox(layout.NewSpacer(), timeCreatedLabel, messageCreationTimeLabel, creationTimeWarningButton, layout.NewSpacer())
reportMessageButton := getWidgetCentered(widget.NewButtonWithIcon("Report Message", theme.WarningIcon(), func(){
//TODO
@ -2245,7 +2245,7 @@ func setViewMessageDetailsButton(window fyne.Window, messageHash [26]byte, messa
//TODO: Show other information: Message size, message moderation status, and when message will expire from network
page := container.NewVBox(title, backButton, widget.NewSeparator(), subtitle, widget.NewSeparator(), messageHashRow, widget.NewSeparator(), messageSentTimeRow, widget.NewSeparator(), reportMessageButton)
page := container.NewVBox(title, backButton, widget.NewSeparator(), subtitle, widget.NewSeparator(), messageHashRow, widget.NewSeparator(), messageCreationTimeRow, widget.NewSeparator(), reportMessageButton)
setPageContent(page, window)
}

View file

@ -3768,7 +3768,7 @@ func setViewReviewDetailsPage(window fyne.Window, reviewHash [29]byte, previousP
getPageContent := func()(*fyne.Container, error){
ableToRead, currentReviewHash, _, reviewNetworkType, reviewerIdentityHash, reviewBroadcastTime, reviewType, reviewedHash, reviewVerdict, reviewMap, err := readReviews.ReadReviewAndHash(false, reviewBytes)
ableToRead, currentReviewHash, _, reviewNetworkType, reviewerIdentityHash, reviewCreationTime, reviewType, reviewedHash, reviewVerdict, reviewMap, err := readReviews.ReadReviewAndHash(false, reviewBytes)
if (err != nil) { return nil, err }
if (ableToRead == false){
return nil, errors.New("Database corrupt: Contains invalid review.")
@ -3841,18 +3841,18 @@ func setViewReviewDetailsPage(window fyne.Window, reviewHash [29]byte, previousP
})
reviewedHashRow := container.NewHBox(layout.NewSpacer(), reviewedHashTitle, reviewedHashLabel, viewReviewedHashButton, layout.NewSpacer())
broadcastTimeTranslated, err := helpers.ConvertUnixTimeToTimeFromNowTranslated(reviewBroadcastTime, true)
creationTimeTranslated, err := helpers.ConvertUnixTimeToTimeFromNowTranslated(reviewCreationTime, true)
if (err != nil ){ return nil, err }
broadcastTimeTitle := widget.NewLabel("Broadcast Time:")
broadcastTimeLabel := getBoldLabel(broadcastTimeTranslated)
broadcastTimeWarningButton := widget.NewButtonWithIcon("", theme.WarningIcon(), func(){
title := translate("Broadcast Time Warning")
dialogMessage := "Broadcast times are not verified. They can be faked by the reviewer."
creationTimeTitle := widget.NewLabel("Creation Time:")
creationTimeLabel := getBoldLabel(creationTimeTranslated)
creationTimeWarningButton := widget.NewButtonWithIcon("", theme.WarningIcon(), func(){
title := translate("Creation Time Warning")
dialogMessage := "Creation times are not verified. They can be faked by the reviewer."
dialogContent := container.NewVBox(widget.NewLabel(dialogMessage))
dialog.ShowCustom(title, translate("Close"), dialogContent, window)
})
broadcastTimeRow := container.NewHBox(layout.NewSpacer(), broadcastTimeTitle, broadcastTimeLabel, broadcastTimeWarningButton, layout.NewSpacer())
creationTimeRow := container.NewHBox(layout.NewSpacer(), creationTimeTitle, creationTimeLabel, creationTimeWarningButton, layout.NewSpacer())
verdictTitle := widget.NewLabel("Verdict:")
verdictLabel := getBoldLabel(reviewVerdict)
@ -3885,7 +3885,7 @@ func setViewReviewDetailsPage(window fyne.Window, reviewHash [29]byte, previousP
reasonRow, err := getReviewReasonRow()
if (err != nil) { return nil, err }
pageContent := container.NewVBox(reviewNetworkTypeRow, widget.NewSeparator(), reviewerIdentityRow, widget.NewSeparator(), reviewHashRow, widget.NewSeparator(), reviewTypeRow, widget.NewSeparator(), reviewedHashRow, widget.NewSeparator(), broadcastTimeRow, widget.NewSeparator(), verdictRow, widget.NewSeparator(), reasonRow, widget.NewSeparator())
pageContent := container.NewVBox(reviewNetworkTypeRow, widget.NewSeparator(), reviewerIdentityRow, widget.NewSeparator(), reviewHashRow, widget.NewSeparator(), reviewTypeRow, widget.NewSeparator(), reviewedHashRow, widget.NewSeparator(), creationTimeRow, widget.NewSeparator(), verdictRow, widget.NewSeparator(), reasonRow, widget.NewSeparator())
if (reviewType == "Identity"){
_, exists := reviewMap["ErrantMessages"]
@ -4566,13 +4566,13 @@ func setViewMyReviewsPage(window fyne.Window, reviewType string, previousPage fu
viewingReviewsLabelWithNavRow := getViewingReviewsLabelWithNavRow()
reviewedHashLabel := getItalicLabelCentered("Reviewed Hash")
broadcastTimeLabel := getItalicLabelCentered("Broadcast Time")
creationTimeLabel := getItalicLabelCentered("Creation Time")
verdictLabel := getItalicLabelCentered("Verdict")
reasonLabel := getItalicLabelCentered("Reason")
emptyLabel := widget.NewLabel("")
reviewedHashColumn := container.NewVBox(reviewedHashLabel, widget.NewSeparator())
broadcastTimeColumn := container.NewVBox(broadcastTimeLabel, widget.NewSeparator())
creationTimeColumn := container.NewVBox(creationTimeLabel, widget.NewSeparator())
verdictColumn := container.NewVBox(verdictLabel, widget.NewSeparator())
reasonColumn := container.NewVBox(reasonLabel, widget.NewSeparator())
viewReviewButtonsColumn := container.NewVBox(emptyLabel, widget.NewSeparator())
@ -4581,7 +4581,7 @@ func setViewMyReviewsPage(window fyne.Window, reviewType string, previousPage fu
for index, reviewBytes := range viewIndexOnwardsReviewsList{
ableToRead, reviewHash, _, reviewNetworkType, reviewerIdentityHash, reviewBroadcastTime, currentReviewType, reviewedHash, reviewVerdict, reviewMap, err := readReviews.ReadReviewAndHash(false, reviewBytes)
ableToRead, reviewHash, _, reviewNetworkType, reviewerIdentityHash, reviewCreationTime, currentReviewType, reviewedHash, reviewVerdict, reviewMap, err := readReviews.ReadReviewAndHash(false, reviewBytes)
if (err != nil) { return nil, err }
if (ableToRead == false){
return nil, errors.New("GetMyNewestReviewsListSorted returning invalid review")
@ -4603,10 +4603,10 @@ func setViewMyReviewsPage(window fyne.Window, reviewType string, previousPage fu
if (err != nil) { return nil, err }
reviewedHashLabel := getBoldLabel(reviewedHashTrimmed)
broadcastTimeString, err := helpers.ConvertUnixTimeToTimeFromNowTranslated(reviewBroadcastTime, false)
creationTimeString, err := helpers.ConvertUnixTimeToTimeFromNowTranslated(reviewCreationTime, false)
if (err != nil ){ return nil, err }
broadcastTimeLabel := getBoldLabelCentered(broadcastTimeString)
creationTimeLabel := getBoldLabelCentered(creationTimeString)
verdictLabel := getBoldLabelCentered(reviewVerdict)
@ -4641,13 +4641,13 @@ func setViewMyReviewsPage(window fyne.Window, reviewType string, previousPage fu
})
reviewedHashColumn.Add(reviewedHashLabel)
broadcastTimeColumn.Add(broadcastTimeLabel)
creationTimeColumn.Add(creationTimeLabel)
verdictColumn.Add(verdictLabel)
reasonColumn.Add(reasonCell)
viewReviewButtonsColumn.Add(viewReviewButton)
reviewedHashColumn.Add(widget.NewSeparator())
broadcastTimeColumn.Add(widget.NewSeparator())
creationTimeColumn.Add(widget.NewSeparator())
verdictColumn.Add(widget.NewSeparator())
reasonColumn.Add(widget.NewSeparator())
viewReviewButtonsColumn.Add(widget.NewSeparator())
@ -4657,7 +4657,7 @@ func setViewMyReviewsPage(window fyne.Window, reviewType string, previousPage fu
}
}
reviewsGrid := container.NewHBox(layout.NewSpacer(), reviewedHashColumn, broadcastTimeColumn, verdictColumn, reasonColumn, viewReviewButtonsColumn, layout.NewSpacer())
reviewsGrid := container.NewHBox(layout.NewSpacer(), reviewedHashColumn, creationTimeColumn, verdictColumn, reasonColumn, viewReviewButtonsColumn, layout.NewSpacer())
resultsContainer := container.NewVBox(viewingReviewsLabelWithNavRow, widget.NewSeparator(), reviewsGrid)

View file

@ -1065,27 +1065,27 @@ func setViewUserProfilePage_ProfileDetails(window fyne.Window, profileHash [28]b
profileHashRow := container.NewHBox(layout.NewSpacer(), profileHashLabel, profileHashTrimmedLabel, viewProfileHashButton, layout.NewSpacer())
exists, _, profileBroadcastTimeString, err := getAnyUserProfileAttributeFunction("BroadcastTime")
exists, _, profileCreationTimeString, err := getAnyUserProfileAttributeFunction("CreationTime")
if (err != nil){ return nil, err }
if (exists == false){
return nil, errors.New("setViewUserProfilePage_ProfileDetails called with profile missing BroadcastTime")
return nil, errors.New("setViewUserProfilePage_ProfileDetails called with profile missing CreationTime")
}
profileBroadcastTime, err := helpers.ConvertBroadcastTimeStringToInt64(profileBroadcastTimeString)
profileCreationTime, err := helpers.ConvertCreationTimeStringToInt64(profileCreationTimeString)
if (err != nil){
return nil, errors.New("setViewUserProfilePage_ProfileDetails called with profile with invalid BroadcastTime: " + profileBroadcastTimeString)
return nil, errors.New("setViewUserProfilePage_ProfileDetails called with profile with invalid CreationTime: " + profileCreationTimeString)
}
broadcastTimeLabel := widget.NewLabel("Creation Time:")
creationTimeLabel := widget.NewLabel("Creation Time:")
broadcastTimeString := helpers.ConvertUnixTimeToTranslatedTime(profileBroadcastTime)
creationTimeString := helpers.ConvertUnixTimeToTranslatedTime(profileCreationTime)
broadcastTimeAgoString, err := helpers.ConvertUnixTimeToTimeFromNowTranslated(profileBroadcastTime, true)
creationTimeAgoString, err := helpers.ConvertUnixTimeToTimeFromNowTranslated(profileCreationTime, true)
if (err != nil) { return nil, err }
broadcastTimeText := getBoldLabel(broadcastTimeString + " (" + broadcastTimeAgoString + ")")
creationTimeText := getBoldLabel(creationTimeString + " (" + creationTimeAgoString + ")")
broadcastTimeWarningButton := widget.NewButtonWithIcon("", theme.WarningIcon(), func(){
creationTimeWarningButton := widget.NewButtonWithIcon("", theme.WarningIcon(), func(){
title := translate("Creation Time Warning")
dialogMessageA := getLabelCentered("Profile creation times are not verified.")
dialogMessageB := getLabelCentered("They can be faked by the profile author.")
@ -1093,7 +1093,7 @@ func setViewUserProfilePage_ProfileDetails(window fyne.Window, profileHash [28]b
dialog.ShowCustom(title, translate("Close"), dialogContent, window)
})
broadcastTimeRow := container.NewHBox(layout.NewSpacer(), broadcastTimeLabel, broadcastTimeText, broadcastTimeWarningButton, layout.NewSpacer())
creationTimeRow := container.NewHBox(layout.NewSpacer(), creationTimeLabel, creationTimeText, creationTimeWarningButton, layout.NewSpacer())
exists, profileVersion, profileType, err := getAnyUserProfileAttributeFunction("ProfileType")
if (err != nil) { return nil, err }
@ -1115,7 +1115,7 @@ func setViewUserProfilePage_ProfileDetails(window fyne.Window, profileHash [28]b
//TODO: Save raw profile button (will save it as a txt file)
pageContent := container.NewVBox(profileHashRow, widget.NewSeparator(), broadcastTimeRow, widget.NewSeparator(), profileTypeRow, widget.NewSeparator(), profileVersionRow)
pageContent := container.NewVBox(profileHashRow, widget.NewSeparator(), creationTimeRow, widget.NewSeparator(), profileTypeRow, widget.NewSeparator(), profileVersionRow)
return pageContent, nil
}

View file

@ -18,7 +18,7 @@ package contentMetadata
// -Profile version
// -Profile network type
// -Profile identity Hash
// -Profile broadcast time
// -Profile creation time
// -Profile is disabled status
// -Profile is canonical status
// -Profile attribute hashes map
@ -43,7 +43,7 @@ import "errors"
// -int: Profile Version
// -byte: Profile network type (1 == Mainnet, 2 == Testnet1)
// -[16]byte: Profile author identity Hash
// -int64: Profile broadcast time
// -int64: Profile creation time
// -bool: Profile is disabled
// -bool: Profile is canonical
// -map[int][27]byte: Map of Attribute identifier -> Attribute hash
@ -58,7 +58,7 @@ func GetProfileMetadata(profileHash [28]byte)(bool, int, byte, [16]byte, int64,
ProfileVersion int
NetworkType byte
IdentityHash [16]byte
BroadcastTime int64
CreationTime int64
IsDisabled bool
IsCanonical bool
AttributeHashesMap map[int][27]byte
@ -74,17 +74,17 @@ func GetProfileMetadata(profileHash [28]byte)(bool, int, byte, [16]byte, int64,
profileVersion := profileMetadataObject.ProfileVersion
profileNetworkType := profileMetadataObject.NetworkType
profileIdentityHash := profileMetadataObject.IdentityHash
profileBroadcastTime := profileMetadataObject.BroadcastTime
profileCreationTime := profileMetadataObject.CreationTime
profileIsDisabled := profileMetadataObject.IsDisabled
profileIsCanonical := profileMetadataObject.IsCanonical
attributeHashesMap := profileMetadataObject.AttributeHashesMap
if (profileIsDisabled == true){
emptyMap := make(map[int][27]byte)
return true, profileVersion, profileNetworkType, profileIdentityHash, profileBroadcastTime, true, true, emptyMap, nil
return true, profileVersion, profileNetworkType, profileIdentityHash, profileCreationTime, true, true, emptyMap, nil
}
return true, profileVersion, profileNetworkType, profileIdentityHash, profileBroadcastTime, false, profileIsCanonical, attributeHashesMap, nil
return true, profileVersion, profileNetworkType, profileIdentityHash, profileCreationTime, false, profileIsCanonical, attributeHashesMap, nil
}
profileType, _, err := readProfiles.ReadProfileHashMetadata(profileHash)
@ -96,7 +96,7 @@ func GetProfileMetadata(profileHash [28]byte)(bool, int, byte, [16]byte, int64,
return false, 0, 0, [16]byte{}, 0, false, false, nil, nil
}
ableToRead, profileHash_Retrieved, profileVersion, profileNetworkType, profileIdentityHash, profileBroadcastTime, profileIsDisabled, rawProfileMap, err := readProfiles.ReadProfileAndHash(false, profileBytes)
ableToRead, profileHash_Retrieved, profileVersion, profileNetworkType, profileIdentityHash, profileCreationTime, profileIsDisabled, rawProfileMap, err := readProfiles.ReadProfileAndHash(false, profileBytes)
if (err != nil) { return false, 0, 0, [16]byte{}, 0, false, false, nil, err }
if (ableToRead == false){
return false, 0, 0, [16]byte{}, 0, false, false, nil, errors.New("Database corrupt: Contains invalid profile: " + err.Error())
@ -117,7 +117,7 @@ func GetProfileMetadata(profileHash [28]byte)(bool, int, byte, [16]byte, int64,
identityHashEncoded, err := encoding.EncodeMessagePackBytes(profileIdentityHash)
if (err != nil){ return false, 0, 0, [16]byte{}, 0, false, false, nil, err }
broadcastTimeEncoded, err := encoding.EncodeMessagePackBytes(profileBroadcastTime)
creationTimeEncoded, err := encoding.EncodeMessagePackBytes(profileCreationTime)
if (err != nil){ return false, 0, 0, [16]byte{}, 0, false, false, nil, err }
isDisabledEncoded, err := encoding.EncodeMessagePackBytes(profileIsDisabled)
@ -129,7 +129,7 @@ func GetProfileMetadata(profileHash [28]byte)(bool, int, byte, [16]byte, int64,
attributeHashesMapEncoded, err := encoding.EncodeMessagePackBytes(profileAttributeHashesMap)
if (err != nil){ return false, 0, 0, [16]byte{}, 0, false, false, nil, err }
profileMetadataSlice := []messagepack.RawMessage{profileVersionEncoded, profileNetworkTypeEncoded, identityHashEncoded, broadcastTimeEncoded, isDisabledEncoded, isCanonicalEncoded, attributeHashesMapEncoded}
profileMetadataSlice := []messagepack.RawMessage{profileVersionEncoded, profileNetworkTypeEncoded, identityHashEncoded, creationTimeEncoded, isDisabledEncoded, isCanonicalEncoded, attributeHashesMapEncoded}
profileMetadataBytes, err := encoding.EncodeMessagePackBytes(profileMetadataSlice)
if (err != nil) { return false, 0, 0, [16]byte{}, 0, false, false, nil, err }
@ -137,7 +137,7 @@ func GetProfileMetadata(profileHash [28]byte)(bool, int, byte, [16]byte, int64,
err = badgerDatabase.AddProfileMetadata(profileHash, profileMetadataBytes)
if (err != nil) { return false, 0, 0, [16]byte{}, 0, false, false, nil, err }
return true, profileVersion, profileNetworkType, profileIdentityHash, profileBroadcastTime, profileIsDisabled, profileIsCanonical, profileAttributeHashesMap, nil
return true, profileVersion, profileNetworkType, profileIdentityHash, profileCreationTime, profileIsDisabled, profileIsCanonical, profileAttributeHashesMap, nil
}
//Outputs:

View file

@ -1824,7 +1824,7 @@ func GetFakeMessage(networkType byte, textOrImage string)([]byte, [26]byte, [32]
senderIdentityHash, err := identity.ConvertIdentityKeyToIdentityHash(senderIdentityPublicKey, identityType)
if (err != nil) { return nil, [26]byte{}, [32]byte{}, err }
messageSentTime := time.Now().Unix()
messageCreationTime := time.Now().Unix()
senderCurrentSecretInboxSeed, err := inbox.GetNewRandomSecretInboxSeed()
if (err != nil) { return nil, [26]byte{}, [32]byte{}, err }
@ -1880,7 +1880,7 @@ func GetFakeMessage(networkType byte, textOrImage string)([]byte, [26]byte, [32]
recipientInbox, err := inbox.GetPublicInboxFromIdentityHash(recipientIdentityHash)
if (err != nil) { return nil, [26]byte{}, [32]byte{}, err }
newMessage, _, err := createMessages.CreateChatMessage(networkType, senderIdentityHash, senderIdentityPublicKey, senderIdentityPrivateKey, messageSentTime, senderCurrentSecretInboxSeed, senderNextSecretInboxSeed, senderDeviceIdentifier, senderChatKeysLatestUpdateTime, messageCommunication, recipientIdentityHash, recipientInbox, recipientNaclPublicKey, recipientKyberPublicKey, doubleSealedKeysSealerKey)
newMessage, _, err := createMessages.CreateChatMessage(networkType, senderIdentityHash, senderIdentityPublicKey, senderIdentityPrivateKey, messageCreationTime, senderCurrentSecretInboxSeed, senderNextSecretInboxSeed, senderDeviceIdentifier, senderChatKeysLatestUpdateTime, messageCommunication, recipientIdentityHash, recipientInbox, recipientNaclPublicKey, recipientKyberPublicKey, doubleSealedKeysSealerKey)
if (err != nil) { return nil, [26]byte{}, [32]byte{}, err }
ableToRead, messageHash, _, _, messageCipherKey, _, _, _, _, _, _, _, _, err := readMessages.ReadChatMessage(newMessage, doubleSealedKeysSealerKey, recipientChatDecryptionKeySetsList)
@ -1907,7 +1907,7 @@ func getFakeMessageSentToMe(identityType string, senderIdentityPublicKey [32]byt
senderIdentityHash, err := identity.ConvertIdentityKeyToIdentityHash(senderIdentityPublicKey, identityType)
if (err != nil) { return nil, err }
messageSentTime := time.Now().Unix()
messageCreationTime := time.Now().Unix()
senderLatestChatKeysUpdateTime := time.Now().Unix()
@ -1963,7 +1963,7 @@ func getFakeMessageSentToMe(identityType string, senderIdentityPublicKey [32]byt
return nil, errors.New("My identity not found after being found already.")
}
newMessage, _, err := createMessages.CreateChatMessage(networkType, senderIdentityHash, senderIdentityPublicKey, senderIdentityPrivateKey, messageSentTime, senderCurrentSecretInboxSeed, senderNextSecretInboxSeed, senderDeviceIdentifier, senderLatestChatKeysUpdateTime, messageCommunication, myIdentityHash, myInbox, myNaclKey, myKyberKey, myInboxDoubleSealedKeysSealerKey)
newMessage, _, err := createMessages.CreateChatMessage(networkType, senderIdentityHash, senderIdentityPublicKey, senderIdentityPrivateKey, messageCreationTime, senderCurrentSecretInboxSeed, senderNextSecretInboxSeed, senderDeviceIdentifier, senderLatestChatKeysUpdateTime, messageCommunication, myIdentityHash, myInbox, myNaclKey, myKyberKey, myInboxDoubleSealedKeysSealerKey)
if (err != nil) { return nil, err }
return newMessage, nil

View file

@ -382,24 +382,24 @@ func ConvertStringToInt64(input string) (int64, error) {
return result, nil
}
func ConvertBroadcastTimeStringToInt64(input string)(int64, error){
func ConvertCreationTimeStringToInt64(input string)(int64, error){
inputInt64, err := ConvertStringToInt64(input)
if (err != nil) {
return 0, errors.New("ConvertBroadcastTimeStringToInt64 called with invalid input: " + input)
return 0, errors.New("ConvertCreationTimeStringToInt64 called with invalid input: " + input)
}
isValid := VerifyBroadcastTime(inputInt64)
isValid := VerifyCreationTime(inputInt64)
if (isValid == false){
return 0, errors.New("ConvertBroadcastTimeStringToInt64 called with invalid input. Too early: " + input)
return 0, errors.New("ConvertCreationTimeStringToInt64 called with invalid input. Too early: " + input)
}
return inputInt64, nil
}
func VerifyBroadcastTime(input int64)bool{
func VerifyCreationTime(input int64)bool{
if (input < 1680000000){
if (input < 1717000000){
return false
}

View file

@ -33,7 +33,7 @@ func CreateChatMessage(
senderIdentityHash [16]byte,
senderIdentityPublicKey [32]byte,
senderIdentityPrivateKey [64]byte,
messageSentTime int64,
messageCreationTime int64,
senderCurrentSecretInboxSeed [22]byte,
senderNextSecretInboxSeed [22]byte,
senderDeviceIdentifier [11]byte,
@ -118,11 +118,11 @@ func CreateChatMessage(
// We create the inner message
timeIsValid := helpers.VerifyBroadcastTime(messageSentTime)
timeIsValid := helpers.VerifyCreationTime(messageCreationTime)
if (timeIsValid == false){
return nil, [26]byte{}, errors.New("CreateChatMessage called with invalid messageSentTime.")
return nil, [26]byte{}, errors.New("CreateChatMessage called with invalid messageCreationTime.")
}
timeIsValid = helpers.VerifyBroadcastTime(senderLatestChatKeysUpdateTime)
timeIsValid = helpers.VerifyCreationTime(senderLatestChatKeysUpdateTime)
if (timeIsValid == false){
return nil, [26]byte{}, errors.New("CreateChatMessage called with invalid senderLatestChatKeysUpdateTime")
}
@ -147,7 +147,7 @@ func CreateChatMessage(
recipientIdentityHashEncoded, err := encoding.EncodeMessagePackBytes(recipientIdentityHash)
if (err != nil) { return nil, [26]byte{}, err }
sentTimeEncoded, err := encoding.EncodeMessagePackBytes(messageSentTime)
creationTimeEncoded, err := encoding.EncodeMessagePackBytes(messageCreationTime)
if (err != nil) { return nil, [26]byte{}, err }
senderCurrentSecretInboxSeedEncoded, err := encoding.EncodeMessagePackBytes(senderCurrentSecretInboxSeed)
@ -162,7 +162,7 @@ func CreateChatMessage(
senderLatestChatKeysUpdateTimeEncoded, err := encoding.EncodeMessagePackBytes(senderLatestChatKeysUpdateTime)
if (err != nil) { return nil, [26]byte{}, err }
messageBasaldataSlice := []messagepack.RawMessage{recipientIdentityHashEncoded, sentTimeEncoded, senderCurrentSecretInboxSeedEncoded, senderNextSecretInboxSeedEncoded, senderDeviceIdentifierEncoded, senderLatestChatKeysUpdateTimeEncoded}
messageBasaldataSlice := []messagepack.RawMessage{recipientIdentityHashEncoded, creationTimeEncoded, senderCurrentSecretInboxSeedEncoded, senderNextSecretInboxSeedEncoded, senderDeviceIdentifierEncoded, senderLatestChatKeysUpdateTimeEncoded}
messageBasaldataEncoded, err := encoding.EncodeMessagePackBytes(messageBasaldataSlice)
if (err != nil) { return nil, [26]byte{}, err }

View file

@ -55,7 +55,7 @@ func TestReadMessagePublicData(t *testing.T){
t.Fatalf("GetNewRandomPublicKyberKey failed: " + err.Error())
}
messageSentTime := time.Now().Unix()
messageCreationTime := time.Now().Unix()
senderCurrentSecretInboxSeed, err := inbox.GetNewRandomSecretInboxSeed()
if (err != nil) {
@ -79,7 +79,7 @@ func TestReadMessagePublicData(t *testing.T){
t.Fatalf("GetNewRandom32ByteArray failed: " + err.Error())
}
finalMessage, messageHash, err := createMessages.CreateChatMessage(messageNetworkType, senderIdentityHash, senderIdentityPublicKey, senderIdentityPrivateKey, messageSentTime, senderCurrentSecretInboxSeed, senderNextSecretInboxSeed, senderDeviceIdentifier, senderLatestChatKeysUpdateTime, testCommunication, recipientIdentityHash, recipientInbox, recipientNaclKey, recipientKyberKey, doubleSealedKeysSealerKey)
finalMessage, messageHash, err := createMessages.CreateChatMessage(messageNetworkType, senderIdentityHash, senderIdentityPublicKey, senderIdentityPrivateKey, messageCreationTime, senderCurrentSecretInboxSeed, senderNextSecretInboxSeed, senderDeviceIdentifier, senderLatestChatKeysUpdateTime, testCommunication, recipientIdentityHash, recipientInbox, recipientNaclKey, recipientKyberKey, doubleSealedKeysSealerKey)
if (err != nil) {
t.Fatalf("Failed to create chat message: " + err.Error())
}
@ -150,7 +150,7 @@ func TestEncryptDecryptMessage(t *testing.T) {
t.Fatalf("Failed to derive Kyber keys: " + err.Error())
}
messageSentTime := time.Now().Unix()
messageCreationTime := time.Now().Unix()
senderCurrentSecretInboxSeed, err := inbox.GetNewRandomSecretInboxSeed()
if (err != nil) {
@ -174,7 +174,7 @@ func TestEncryptDecryptMessage(t *testing.T) {
t.Fatalf("GetNewRandom32ByteArray failed: " + err.Error())
}
finalMessage, messageHash, err := createMessages.CreateChatMessage(messageNetworkType, senderIdentityHash, senderIdentityPublicKey, senderIdentityPrivateKey, messageSentTime, senderCurrentSecretInboxSeed, senderNextSecretInboxSeed, senderDeviceIdentifier, senderLatestChatKeysUpdateTime, testCommunication, recipientIdentityHash, recipientInbox, recipientNaclPublicKey, recipientKyberPublicKey, doubleSealedKeysSealerKey,)
finalMessage, messageHash, err := createMessages.CreateChatMessage(messageNetworkType, senderIdentityHash, senderIdentityPublicKey, senderIdentityPrivateKey, messageCreationTime, senderCurrentSecretInboxSeed, senderNextSecretInboxSeed, senderDeviceIdentifier, senderLatestChatKeysUpdateTime, testCommunication, recipientIdentityHash, recipientInbox, recipientNaclPublicKey, recipientKyberPublicKey, doubleSealedKeysSealerKey,)
if (err != nil) {
t.Fatalf("Failed to create chat message: " + err.Error())
}
@ -187,7 +187,7 @@ func TestEncryptDecryptMessage(t *testing.T) {
}
newRecipientChatDecryptionKeySetsList := []readMessages.ChatKeySet{newChatKeySet}
ableToRead, messageHash_Received, messageVersion, messageNetworkType_Received, messageCipherKey, senderIdentityHash_Received, recipientIdentityHash_Received, messageSentTime_Received, communication_Received, senderCurrentSecretInboxSeed_Received, senderNextSecretInboxSeed_Received, senderDeviceIdentifier_Received, senderLatestChatKeysUpdateTime_Received, err := readMessages.ReadChatMessage(finalMessage, doubleSealedKeysSealerKey, newRecipientChatDecryptionKeySetsList)
ableToRead, messageHash_Received, messageVersion, messageNetworkType_Received, messageCipherKey, senderIdentityHash_Received, recipientIdentityHash_Received, messageCreationTime_Received, communication_Received, senderCurrentSecretInboxSeed_Received, senderNextSecretInboxSeed_Received, senderDeviceIdentifier_Received, senderLatestChatKeysUpdateTime_Received, err := readMessages.ReadChatMessage(finalMessage, doubleSealedKeysSealerKey, newRecipientChatDecryptionKeySetsList)
if (err != nil) {
t.Fatalf("Failed to read chat message: " + err.Error())
}
@ -209,8 +209,8 @@ func TestEncryptDecryptMessage(t *testing.T) {
if (recipientIdentityHash != recipientIdentityHash_Received){
t.Fatalf("Recipient identity hash does not match.")
}
if (messageSentTime != messageSentTime_Received){
t.Fatalf("Message sent time is incorrect.")
if (messageCreationTime != messageCreationTime_Received){
t.Fatalf("Message creation time is incorrect.")
}
if (testCommunication != communication_Received){

View file

@ -537,20 +537,20 @@ func StartUpdatingMyConversations(identityType string, networkType byte) error{
return errors.New("myChatMessagesMapList returning messageMap with different NetworkType")
}
messageSentTimeString, exists := messageMap["TimeSent"]
messageCreationTimeString, exists := messageMap["CreationTime"]
if (exists == false){
return errors.New("Malformed message map: Missing TimeSent.")
return errors.New("Malformed message map: Missing CreationTime.")
}
currentMessageSentTimeInt64, err := helpers.ConvertStringToInt64(messageSentTimeString)
currentMessageCreationTimeInt64, err := helpers.ConvertStringToInt64(messageCreationTimeString)
if (err != nil) {
return errors.New("Malformed message map: Contains invalid TimeSent: " + messageSentTimeString)
return errors.New("Malformed message map: Contains invalid CreationTime: " + messageCreationTimeString)
}
existingMostRecentMessageSentTime, exists := conversationsMap[messageTheirIdentityHash]
if (exists == false || currentMessageSentTimeInt64 > existingMostRecentMessageSentTime){
existingMostRecentMessageCreationTime, exists := conversationsMap[messageTheirIdentityHash]
if (exists == false || currentMessageCreationTimeInt64 > existingMostRecentMessageCreationTime){
conversationsMap[messageTheirIdentityHash] = currentMessageSentTimeInt64
conversationsMap[messageTheirIdentityHash] = currentMessageCreationTimeInt64
}
}
@ -590,13 +590,13 @@ func StartUpdatingMyConversations(identityType string, networkType byte) error{
return errors.New("conversationsMap contains invalid theirIdentityHash: " + theirIdentityHashHex)
}
mostRecentMessageSentTimeString := helpers.ConvertInt64ToString(conversationMostRecentMessageTime)
mostRecentMessageCreationTimeString := helpers.ConvertInt64ToString(conversationMostRecentMessageTime)
newConversationMap := map[string]string{
"MyIdentityHash": myIdentityHashString,
"TheirIdentityHash": theirIdentityHashString,
"NetworkType": networkTypeString,
"MostRecentMessageTime": mostRecentMessageSentTimeString,
"MostRecentMessageTime": mostRecentMessageCreationTimeString,
}
newConversationsMapList = append(newConversationsMapList, newConversationMap)

View file

@ -357,7 +357,7 @@ func GetUpdatedMyChatMessagesMapList(myIdentityType string, networkType byte, up
continue
}
ableToRead, _, _, _, messageCipherKey, senderIdentityHash, recipientIdentityHash, messageSentTimeUnix, messageCommunication, senderCurrentSecretInboxSeed, senderNextSecretInboxSeed, senderDeviceIdentifier, senderLatestChatKeysUpdateTime, err := readMessages.ReadChatMessage(messageBytes, inboxDoubleSealedKeysSealerKey, myChatDecryptionKeySetsList)
ableToRead, _, _, _, messageCipherKey, senderIdentityHash, recipientIdentityHash, messageCreationTimeUnix, messageCommunication, senderCurrentSecretInboxSeed, senderNextSecretInboxSeed, senderDeviceIdentifier, senderLatestChatKeysUpdateTime, err := readMessages.ReadChatMessage(messageBytes, inboxDoubleSealedKeysSealerKey, myChatDecryptionKeySetsList)
if (err != nil) { return err }
if (ableToRead == false) {
// Either keys are lost/deleted or sender is forming malicious messages
@ -417,10 +417,10 @@ func GetUpdatedMyChatMessagesMapList(myIdentityType string, networkType byte, up
}
}
err = peerChatKeys.SavePeerMessageLatestChatKeysUpdateTime(senderIdentityHash, networkType, senderLatestChatKeysUpdateTime, messageSentTimeUnix)
err = peerChatKeys.SavePeerMessageLatestChatKeysUpdateTime(senderIdentityHash, networkType, senderLatestChatKeysUpdateTime, messageCreationTimeUnix)
if (err != nil) { return err }
parametersExist, err = peerSecretInboxes.AddPeerConversationSecretInboxSeeds(myIdentityHash, senderIdentityHash, messageNetworkType, messageSentTimeUnix, senderCurrentSecretInboxSeed, senderNextSecretInboxSeed)
parametersExist, err = peerSecretInboxes.AddPeerConversationSecretInboxSeeds(myIdentityHash, senderIdentityHash, messageNetworkType, messageCreationTimeUnix, senderCurrentSecretInboxSeed, senderNextSecretInboxSeed)
if (err != nil) { return err }
if (parametersExist == false){
// This means we cannot add the sender's secret inboxes to our storage
@ -433,7 +433,7 @@ func GetUpdatedMyChatMessagesMapList(myIdentityType string, networkType byte, up
err = myCipherKeys.SaveMessageCipherKey(messageHash, messageCipherKey)
if (err != nil) { return err }
err = peerDevices.AddPeerDeviceIdentifierFromMessage(senderIdentityHash, messageNetworkType, senderDeviceIdentifier, messageSentTimeUnix)
err = peerDevices.AddPeerDeviceIdentifierFromMessage(senderIdentityHash, messageNetworkType, senderDeviceIdentifier, messageCreationTimeUnix)
if (err != nil) { return err }
//TODO: Verify communication. For example, verify that image is valid, greet/reject is valid, etc.
@ -443,7 +443,7 @@ func GetUpdatedMyChatMessagesMapList(myIdentityType string, networkType byte, up
// We add message to the MyChatMessages map list
messageContentMap, err := getNewMessageMap("Sent", messageHash, [20]byte{}, myIdentityHash, senderIdentityHash, messageNetworkType, false, messageSentTimeUnix, messageCommunication)
messageContentMap, err := getNewMessageMap("Sent", messageHash, [20]byte{}, myIdentityHash, senderIdentityHash, messageNetworkType, false, messageCreationTimeUnix, messageCommunication)
if (err != nil) { return err }
newMyChatMessagesMapList = append(newMyChatMessagesMapList, messageContentMap)
@ -749,8 +749,8 @@ type ConversationMessage struct{
MessageHash [26]byte
MessageIdentifier [20]byte
// Unix time of message sent time
TimeSent int64
// Unix time of message creation time
CreationTime int64
// True if I am message sender, false if not.
IAmSender bool
@ -767,8 +767,8 @@ type ConversationMessage struct{
//Outputs:
// -bool: My identity found
// -bool: Conversation found (any messages found = true, no messages found = false)
// -[]ConversationMessage: Messages list (sorted by time sent)
// -int64: Conversation latest message sent Unix message time
// -[]ConversationMessage: Messages list (sorted by creation time)
// -int64: Conversation latest message creation time
// -bool: I have contacted them
// -bool: I have rejected them (if myIdentityType == Mate)
// -int64: Time of my most recent greet/rejection to them
@ -813,7 +813,7 @@ func GetMyConversationInfoAndSortedMessagesList(myIdentityHash [16]byte, theirId
conversationMessagesList := make([]ConversationMessage, 0)
lastMessageSentTimeUnix := int64(0)
lastMessageCreationTimeUnix := int64(0)
for _, messageMap := range myChatMessagesList {
@ -855,9 +855,9 @@ func GetMyConversationInfoAndSortedMessagesList(myIdentityHash [16]byte, theirId
return false, false, nil, 0, false, false, 0, false, false, 0, errors.New("Malformed message map: Missing IAmSender.")
}
timeSentUnixString, exists := messageMap["TimeSent"]
creationTimeUnixString, exists := messageMap["CreationTime"]
if (exists == false) {
return false, false, nil, 0, false, false, 0, false, false, 0, errors.New("Malformed message map: Missing TimeSent.")
return false, false, nil, 0, false, false, 0, false, false, 0, errors.New("Malformed message map: Missing CreationTime.")
}
communicationString, exists := messageMap["Communication"]
@ -870,13 +870,13 @@ func GetMyConversationInfoAndSortedMessagesList(myIdentityHash [16]byte, theirId
return false, false, nil, 0, false, false, 0, false, false, 0, errors.New("Malformed message map: Contains invalid IAmSender: " + iAmSenderString)
}
timeSentUnix, err := helpers.ConvertStringToInt64(timeSentUnixString)
creationTimeUnix, err := helpers.ConvertStringToInt64(creationTimeUnixString)
if (err != nil) {
return false, false, nil, 0, false, false, 0, false, false, 0, errors.New("Malformed message map: Contains invalid TimeSent: " + timeSentUnixString)
return false, false, nil, 0, false, false, 0, false, false, 0, errors.New("Malformed message map: Contains invalid CreationTime: " + creationTimeUnixString)
}
if (lastMessageSentTimeUnix < timeSentUnix){
lastMessageSentTimeUnix = timeSentUnix
if (lastMessageCreationTimeUnix < creationTimeUnix){
lastMessageCreationTimeUnix = creationTimeUnix
}
newMessageObject := ConversationMessage{}
@ -921,7 +921,7 @@ func GetMyConversationInfoAndSortedMessagesList(myIdentityHash [16]byte, theirId
newMessageObject.MessageIdentifier = messageIdentifierArray
}
newMessageObject.TimeSent = timeSentUnix
newMessageObject.CreationTime = creationTimeUnix
newMessageObject.IAmSender = iAmSender
newMessageObject.Communication = communicationString
@ -934,38 +934,38 @@ func GetMyConversationInfoAndSortedMessagesList(myIdentityHash [16]byte, theirId
// Now we sort messages oldest to newest
compareMessagesFunction := func(messageA ConversationMessage, messageB ConversationMessage)int {
compareMessagesFunction := func(message1 ConversationMessage, message2 ConversationMessage)int {
aTimeSent := messageA.TimeSent
bTimeSent := messageB.TimeSent
message1CreationTime := message1.CreationTime
message2CreationTime := message2.CreationTime
if (aTimeSent == bTimeSent){
if (message1CreationTime == message2CreationTime){
// We sort messages so they always appear in the same order
aIAmSender := messageA.IAmSender
bIAmSender := messageB.IAmSender
message1IAmSender := message1.IAmSender
message2IAmSender := message2.IAmSender
if (aIAmSender == bIAmSender){
if (message1IAmSender == message2IAmSender){
aCommunication := messageA.Communication
bCommunication := messageB.Communication
message1Communication := message1.Communication
message2Communication := message2.Communication
if (aCommunication == bCommunication){
if (message1Communication == message2Communication){
return 0
}
if (aCommunication < bCommunication){
if (message1Communication < message2Communication){
return -1
}
return 1
}
if (aIAmSender == false){
if (message1IAmSender == false){
return -1
}
return 1
}
if (aTimeSent < bTimeSent){
if (message1CreationTime < message2CreationTime){
return -1
}
@ -1001,39 +1001,39 @@ func GetMyConversationInfoAndSortedMessagesList(myIdentityHash [16]byte, theirId
theyHaveContactedMe = true
}
messageTimeSent := currentMessageObject.TimeSent
messageCreationTime := currentMessageObject.CreationTime
messageCommunication := currentMessageObject.Communication
if (messageCommunication == ">!>Greet"){
if (iAmSender == true){
iHaveRejectedThem = false
timeOfMyMostRecentGreetOrReject = messageTimeSent
timeOfMyMostRecentGreetOrReject = messageCreationTime
} else {
theyHaveRejectedMe = false
timeOfTheirMostRecentGreetOrReject = messageTimeSent
timeOfTheirMostRecentGreetOrReject = messageCreationTime
}
} else if (messageCommunication == ">!>Reject"){
if (iAmSender == true){
iHaveRejectedThem = true
timeOfMyMostRecentGreetOrReject = messageTimeSent
timeOfMyMostRecentGreetOrReject = messageCreationTime
} else {
theyHaveRejectedMe = true
timeOfTheirMostRecentGreetOrReject = messageTimeSent
timeOfTheirMostRecentGreetOrReject = messageCreationTime
}
} else {
if (iAmSender == true){
if (iHaveRejectedThem == false){
timeOfMyMostRecentGreetOrReject = messageTimeSent
timeOfMyMostRecentGreetOrReject = messageCreationTime
}
} else{
if (theyHaveRejectedMe == false){
timeOfTheirMostRecentGreetOrReject = messageTimeSent
timeOfTheirMostRecentGreetOrReject = messageCreationTime
}
}
}
}
return true, true, conversationMessagesList, lastMessageSentTimeUnix, iHaveContactedThem, iHaveRejectedThem, timeOfMyMostRecentGreetOrReject, theyHaveContactedMe, theyHaveRejectedMe, timeOfTheirMostRecentGreetOrReject, nil
return true, true, conversationMessagesList, lastMessageCreationTimeUnix, iHaveContactedThem, iHaveRejectedThem, timeOfMyMostRecentGreetOrReject, theyHaveContactedMe, theyHaveRejectedMe, timeOfTheirMostRecentGreetOrReject, nil
}
@ -1188,7 +1188,7 @@ func AddMyNewMessageToMyChatMessages(
myIdentityHash [16]byte,
theirIdentityHash [16]byte,
messageNetworkType byte,
timeSentUnix int64,
messageCreationTime int64,
communication string)error{
identityIsMine, myIdentityType, err := myIdentity.CheckIfIdentityHashIsMine(myIdentityHash)
@ -1201,7 +1201,7 @@ func AddMyNewMessageToMyChatMessages(
return errors.New("AddMyNewMessageToMyChatMessages called with host identity.")
}
newMessageMap, err := getNewMessageMap(messageStatus, messageHash, messageIdentifier, myIdentityHash, theirIdentityHash, messageNetworkType, true, timeSentUnix, communication)
newMessageMap, err := getNewMessageMap(messageStatus, messageHash, messageIdentifier, myIdentityHash, theirIdentityHash, messageNetworkType, true, messageCreationTime, communication)
if (err != nil) { return err }
updatingChatMessagesMutex.Lock()
@ -1277,7 +1277,7 @@ func AddMyNewMessageToMyChatMessages(
// MessageHash should be empty ("") if messageStatus == "Queued" or "Failed"
// messageIdentifier should be empty if messageStatus == "Sent"
func getNewMessageMap(messageStatus string, messageHash [26]byte, messageIdentifier [20]byte, myIdentityHash [16]byte, theirIdentityHash [16]byte, messageNetworkType byte, iAmSender bool, timeSentUnix int64, communication string)(map[string]string, error){
func getNewMessageMap(messageStatus string, messageHash [26]byte, messageIdentifier [20]byte, myIdentityHash [16]byte, theirIdentityHash [16]byte, messageNetworkType byte, iAmSender bool, messageCreationTime int64, communication string)(map[string]string, error){
if (messageStatus != "Sent" && messageStatus != "Queued" && messageStatus != "Failed"){
return nil, errors.New("getNewMessageMap called with invalid messageStatus: " + messageStatus)
@ -1312,8 +1312,8 @@ func getNewMessageMap(messageStatus string, messageHash [26]byte, messageIdentif
iAmSenderString := helpers.ConvertBoolToYesOrNoString(iAmSender)
if (timeSentUnix > time.Now().Unix() + 10){
return nil, errors.New("getNewMessageMap called with invalid time sent unix: is in the future.")
if (messageCreationTime > time.Now().Unix() + 10){
return nil, errors.New("getNewMessageMap called with invalid creationTime: is in the future.")
}
isAllowed := allowedText.VerifyStringIsAllowed(communication)
@ -1321,7 +1321,7 @@ func getNewMessageMap(messageStatus string, messageHash [26]byte, messageIdentif
return nil, errors.New("getNewMessageMap called with communication containing unallowed text.")
}
timeSentUnixString := helpers.ConvertInt64ToString(timeSentUnix)
messageCreationTimeString := helpers.ConvertInt64ToString(messageCreationTime)
messageContentMap := map[string]string{
"MessageStatus": messageStatus,
@ -1329,7 +1329,7 @@ func getNewMessageMap(messageStatus string, messageHash [26]byte, messageIdentif
"TheirIdentityHash": theirIdentityHashString,
"NetworkType": messageNetworkTypeString,
"IAmSender": iAmSenderString,
"TimeSent": timeSentUnixString,
"CreationTime": messageCreationTimeString,
"Communication": communication,
}

View file

@ -95,7 +95,7 @@ func AddMessageToMyMessageQueue(myIdentityHash [16]byte, recipientIdentityHash [
messageIdentifier := [20]byte(messageIdentifierBytes)
messageIdentifierString := encoding.EncodeBytesToHexString(messageIdentifierBytes)
// TimeAdded will be used as the messageSentTime when we send the message
// TimeAdded will be used as the messageCreationTime when we send the message
currentTime := time.Now().Unix()
currentTimeString := helpers.ConvertInt64ToString(currentTime)
@ -249,7 +249,7 @@ func AttemptToSendMessagesInQueue(identityType string, networkType byte, maximum
return errors.New("MessageQueue mapList malformed: Item missing TimeAdded")
}
messageTimeAddedInt64, err := helpers.ConvertBroadcastTimeStringToInt64(messageTimeAdded)
messageTimeAddedInt64, err := helpers.ConvertCreationTimeStringToInt64(messageTimeAdded)
if (err != nil) {
return errors.New("MessageQueue mapList malformed: Item contains invalid TimeAdded: " + messageTimeAdded)
}

View file

@ -262,7 +262,7 @@ func GetMySecretInboxInfo(secretInbox [10]byte)(bool, [16]byte, [16]byte, byte,
// -bool: My next epoch secret inbox seed exists
// -[22]byte: My next epoch secret inbox seed
// -error
func GetMySecretInboxSeedsForMessage(myIdentityHash [16]byte, recipientIdentityHash [16]byte, networkType byte, messageSentTimeUnix int64)(bool, bool, [22]byte, bool, [22]byte, error){
func GetMySecretInboxSeedsForMessage(myIdentityHash [16]byte, recipientIdentityHash [16]byte, networkType byte, messageCreationTimeUnix int64)(bool, bool, [22]byte, bool, [22]byte, error){
isValid, err := identity.VerifyIdentityHash(myIdentityHash, false, "")
if (err != nil){ return false, false, [22]byte{}, false, [22]byte{}, err }
@ -277,7 +277,7 @@ func GetMySecretInboxSeedsForMessage(myIdentityHash [16]byte, recipientIdentityH
return false, false, [22]byte{}, false, [22]byte{}, errors.New("GetMySecretInboxSeedsForMessage called with invalid networkType: " + networkTypeString)
}
parametersExist, currentEpochStartTime, currentEpochEndTime, nextEpochStartTime, nextEpochEndTime, err := secretInboxEpoch.GetSecretInboxEpochStartAndEndTimes(networkType, messageSentTimeUnix)
parametersExist, currentEpochStartTime, currentEpochEndTime, nextEpochStartTime, nextEpochEndTime, err := secretInboxEpoch.GetSecretInboxEpochStartAndEndTimes(networkType, messageCreationTimeUnix)
if (err != nil) { return false, false, [22]byte{}, false, [22]byte{}, err }
if (parametersExist == false){
return false, false, [22]byte{}, false, [22]byte{}, nil
@ -377,7 +377,7 @@ func GetMySecretInboxSeedsForMessage(myIdentityHash [16]byte, recipientIdentityH
//Outputs:
// -bool: Parameters exist
// -error
func AddMySecretInboxSeeds(myIdentityHash [16]byte, theirIdentityHash [16]byte, networkType byte, messageSentTime int64, currentSecretInboxSeed [22]byte, nextSecretInboxSeed [22]byte)(bool, error){
func AddMySecretInboxSeeds(myIdentityHash [16]byte, theirIdentityHash [16]byte, networkType byte, messageCreationTime int64, currentSecretInboxSeed [22]byte, nextSecretInboxSeed [22]byte)(bool, error){
isValid, err := identity.VerifyIdentityHash(myIdentityHash, false, "")
if (err != nil) { return false, err }
@ -401,7 +401,7 @@ func AddMySecretInboxSeeds(myIdentityHash [16]byte, theirIdentityHash [16]byte,
updatingMySecretInboxesMapListMutex.Lock()
defer updatingMySecretInboxesMapListMutex.Unlock()
parametersExist, currentSecretInboxStartTime, currentSecretInboxEndTime, nextSecretInboxStartTime, nextSecretInboxEndTime, err := secretInboxEpoch.GetSecretInboxEpochStartAndEndTimes(networkType, messageSentTime)
parametersExist, currentSecretInboxStartTime, currentSecretInboxEndTime, nextSecretInboxStartTime, nextSecretInboxEndTime, err := secretInboxEpoch.GetSecretInboxEpochStartAndEndTimes(networkType, messageCreationTime)
if (err != nil) { return false, err }
if (parametersExist == false){
return false, nil

View file

@ -90,8 +90,8 @@ func CheckIfUsersChatKeysAreMissing(userIdentityHash [16]byte, networkType byte)
// This function saves a user's chat key latest update time from a message
// It is used to keep track of when peer updates their key set, so the app knows to retrieve new chat keys
// This information could be wrong, if newer keys have been broadcast since the user sent their message
func SavePeerMessageLatestChatKeysUpdateTime(peerIdentityHash [16]byte, networkType byte, theirLatestChatKeysUpdateTime int64, theirMessageSentTime int64)error{
// This information could be wrong, if newer keys have been shared since the user sent their message
func SavePeerMessageLatestChatKeysUpdateTime(peerIdentityHash [16]byte, networkType byte, theirLatestChatKeysUpdateTime int64, theirMessageCreationTime int64)error{
updatingPeerChatKeysLatestUpdateTimeMutex.Lock()
defer updatingPeerChatKeysLatestUpdateTimeMutex.Unlock()
@ -108,27 +108,27 @@ func SavePeerMessageLatestChatKeysUpdateTime(peerIdentityHash [16]byte, networkT
return errors.New("SavePeerMessageLatestChatKeysUpdateTime called with invalid networkType: " + networkTypeString)
}
existingLatestUpdateTimeExists, existingLatestUpdateTime, existingLatestUpdateTimeSentTime, err := getSavedPeerMessageLatestChatKeysUpdateTime(peerIdentityHash, networkType)
existingLatestUpdateTimeExists, existingLatestUpdateTime, existingLatestUpdateTimeCreationTime, err := getSavedPeerMessageLatestChatKeysUpdateTime(peerIdentityHash, networkType)
if (err != nil){ return err }
if (existingLatestUpdateTimeExists == true){
if (existingLatestUpdateTimeSentTime > theirMessageSentTime){
// We already have a latest update time was sent at later time
if (existingLatestUpdateTimeCreationTime > theirMessageCreationTime){
// We already have a latest update time which was sent at later time
// Nothing to do
return nil
}
// We have a latest update time that was sent earler
// We see if the newer sent latest update time is actually newer
// We have a latest update time that was created earler
// We see if the newer created latest update time is actually newer
if (existingLatestUpdateTime > theirLatestChatKeysUpdateTime){
// They are sending a latestUpdateTime that is older than one they have previously sent
// The user has probably moved to a different device, and then moved back to their previous device
// This should not happen
// To avoid this happening we should make sure there is an option in the GUI to reinitialize the application as if it is a new device
// This will require broadcasting a new LatestChatKeysUpdateTime in our profile
// This will require sharing a new LatestChatKeysUpdateTime in our profile
//
// We will delete our stored chatKeys and update our datastore latestChatKeysUpdateTime
// This will allow their older chat keys to be used if and when they broadcast a profile from their device.
// This will allow their older chat keys to be used if and when they created a profile from their device.
networkTypeString := helpers.ConvertByteToString(networkType)
@ -143,12 +143,12 @@ func SavePeerMessageLatestChatKeysUpdateTime(peerIdentityHash [16]byte, networkT
}
theirLatestChatKeysUpdateTimeString := helpers.ConvertInt64ToString(theirLatestChatKeysUpdateTime)
theirMessageSentTimeString := helpers.ConvertInt64ToString(theirMessageSentTime)
theirMessageCreationTimeString := helpers.ConvertInt64ToString(theirMessageCreationTime)
networkTypeString := helpers.ConvertByteToString(networkType)
newMapKey := peerIdentityHashString + "@" + networkTypeString
newMapValue := theirLatestChatKeysUpdateTimeString + "$" + theirMessageSentTimeString
newMapValue := theirLatestChatKeysUpdateTimeString + "$" + theirMessageCreationTimeString
err = peerChatKeysLatestUpdateTimeMapDatastore.SetMapEntry(newMapKey, newMapValue)
if (err != nil) { return err }
@ -161,7 +161,7 @@ func SavePeerMessageLatestChatKeysUpdateTime(peerIdentityHash [16]byte, networkT
//Outputs:
// -bool: Latest update time info exists
// -int64: Latest Update Time
// -int64: Latest update time broadcasted time (the time when the user shared this latestUpdateTime)
// -int64: Latest update time creation time (the time when the user shared this latestUpdateTime)
// -error
func getSavedPeerMessageLatestChatKeysUpdateTime(peerIdentityHash [16]byte, networkType byte)(bool, int64, int64, error){
@ -187,7 +187,7 @@ func getSavedPeerMessageLatestChatKeysUpdateTime(peerIdentityHash [16]byte, netw
return false, 0, 0, nil
}
latestUpdateTime, latestUpdateTimeBroadcastTime, delimiterFound := strings.Cut(mapValue, "$")
latestUpdateTime, latestUpdateTimeCreationTime, delimiterFound := strings.Cut(mapValue, "$")
if (delimiterFound == false){
return false, 0, 0, errors.New("peerChatKeysLatestUpdateTimeMapDatastore entry is malformed: Map value missing $: " + mapValue)
}
@ -197,12 +197,12 @@ func getSavedPeerMessageLatestChatKeysUpdateTime(peerIdentityHash [16]byte, netw
return false, 0, 0, errors.New("peerChatKeysLatestUpdateTimeMapDatastore entry value is malformed: Invalid latestUpdateTime: " + latestUpdateTime)
}
latestUpdateTimeBroadcastTimeInt64, err := helpers.ConvertStringToInt64(latestUpdateTimeBroadcastTime)
latestUpdateTimeCreationTimeInt64, err := helpers.ConvertStringToInt64(latestUpdateTimeCreationTime)
if (err != nil){
return false, 0, 0, errors.New("peerChatKeysLatestUpdateTimeMapDatastore entry value is malformed: Invalid latestUpdateTimeBroadcastTime: " + latestUpdateTimeBroadcastTime)
return false, 0, 0, errors.New("peerChatKeysLatestUpdateTimeMapDatastore entry value is malformed: Invalid latestUpdateTimeCreationTime: " + latestUpdateTimeCreationTime)
}
return true, latestUpdateTimeInt64, latestUpdateTimeBroadcastTimeInt64, nil
return true, latestUpdateTimeInt64, latestUpdateTimeCreationTimeInt64, nil
}
@ -240,7 +240,7 @@ func GetPeerNewestActiveChatKeys(peerIdentityHash [16]byte, networkType byte)(bo
// -bool: Any keys found
// -[32]byte: User Nacl key
// -[1568]byte: User Kyber key
// -int64: Time keys were broadcast
// -int64: Time keys were created
// -error
getPeerNewestKnownChatKeys := func()(bool, bool, [32]byte, [1568]byte, int64, error){
@ -253,13 +253,13 @@ func GetPeerNewestActiveChatKeys(peerIdentityHash [16]byte, networkType byte)(bo
//Outputs:
// -bool: Profile found
// -bool: Profile is disabled
// -int64: Profile broadcast time
// -int64: Profile creation time
// -[32]byte: Peer Nacl key
// -[1568]byte: Peer Kyber key
// -error
getPeerChatKeysMapFromDatabase := func()(bool, bool, int64, [32]byte, [1568]byte, error){
profileExists, _, _, _, profileBroadcastTime, rawProfileMap, err := profileStorage.GetNewestUserProfile(peerIdentityHash, networkType)
profileExists, _, _, _, profileCreationTime, rawProfileMap, err := profileStorage.GetNewestUserProfile(peerIdentityHash, networkType)
if (err != nil) { return false, false, 0, [32]byte{}, [1568]byte{}, err }
if (profileExists == false) {
return false, false, 0, [32]byte{}, [1568]byte{}, nil
@ -268,7 +268,7 @@ func GetPeerNewestActiveChatKeys(peerIdentityHash [16]byte, networkType byte)(bo
profileIsDisabled, _, err := readProfiles.GetFormattedProfileAttributeFromRawProfileMap(rawProfileMap, "Disabled")
if (err != nil) { return false, false, 0, [32]byte{}, [1568]byte{}, err }
if (profileIsDisabled == true){
return true, true, profileBroadcastTime, [32]byte{}, [1568]byte{}, nil
return true, true, profileCreationTime, [32]byte{}, [1568]byte{}, nil
}
exists, peerNaclKey, err := readProfiles.GetFormattedProfileAttributeFromRawProfileMap(rawProfileMap, "NaclKey")
@ -305,13 +305,13 @@ func GetPeerNewestActiveChatKeys(peerIdentityHash [16]byte, networkType byte)(bo
peerKyberKeyArray := [1568]byte(peerKyberKeyBytes)
return true, false, profileBroadcastTime, peerNaclKeyArray, peerKyberKeyArray, nil
return true, false, profileCreationTime, peerNaclKeyArray, peerKyberKeyArray, nil
}
//Outputs:
// -bool: Peer stored keys found
// -bool: Peer is disabled
// -int64: Broadcast time of these keys/disabled status
// -int64: Creation time of these keys/disabled status
// -[32]byte: Peer Nacl Key
// -[1568]byte: Peer Kyber key
// -error
@ -336,19 +336,19 @@ func GetPeerNewestActiveChatKeys(peerIdentityHash [16]byte, networkType byte)(bo
peerChatKeysMap := retrievedMapListItems[0]
keysBroadcastTime, exists := peerChatKeysMap["BroadcastedTime"]
keysCreationTime, exists := peerChatKeysMap["CreationTime"]
if (exists == false) {
return false, false, 0, [32]byte{}, [1568]byte{}, errors.New("Malformed peer chat keys maplist: Item missing BroadcastedTime")
return false, false, 0, [32]byte{}, [1568]byte{}, errors.New("Malformed peer chat keys maplist: Item missing CreationTime")
}
keysBroadcastTimeInt64, err := helpers.ConvertBroadcastTimeStringToInt64(keysBroadcastTime)
keysCreationTimeInt64, err := helpers.ConvertCreationTimeStringToInt64(keysCreationTime)
if (err != nil) {
return false, false, 0, [32]byte{}, [1568]byte{}, errors.New("Malformed peer chat keys maplist: Item contains invalid BroadcastedTime: " + keysBroadcastTime)
return false, false, 0, [32]byte{}, [1568]byte{}, errors.New("Malformed peer chat keys maplist: Item contains invalid CreationTime: " + keysCreationTime)
}
peerIsDisabled, exists := peerChatKeysMap["PeerIsDisabled"]
if (exists == true && peerIsDisabled == "Yes"){
return true, true, keysBroadcastTimeInt64, [32]byte{}, [1568]byte{}, nil
return true, true, keysCreationTimeInt64, [32]byte{}, [1568]byte{}, nil
}
peerNaclKey, exists := peerChatKeysMap["NaclKey"]
@ -383,13 +383,13 @@ func GetPeerNewestActiveChatKeys(peerIdentityHash [16]byte, networkType byte)(bo
peerKyberKeyArray := [1568]byte(peerKyberKeyBytes)
return true, false, keysBroadcastTimeInt64, peerNaclKeyArray, peerKyberKeyArray, nil
return true, false, keysCreationTimeInt64, peerNaclKeyArray, peerKyberKeyArray, nil
}
databaseUserProfileExists, databaseProfileIsDisabled, databaseUserProfileBroadcastTime, databaseUserNaclKey, databaseUserKyberKey, err := getPeerChatKeysMapFromDatabase()
databaseUserProfileExists, databaseProfileIsDisabled, databaseUserProfileCreationTime, databaseUserNaclKey, databaseUserKyberKey, err := getPeerChatKeysMapFromDatabase()
if (err != nil) { return false, false, [32]byte{}, [1568]byte{}, 0, err }
storageUserChatKeysInfoExists, storageProfileIsDisabled, storageUserProfileBroadcastTime, storageUserNaclKey, storageUserKyberKey, err := getPeerChatKeysMapListFromMyMapListStorage()
storageUserChatKeysInfoExists, storageProfileIsDisabled, storageUserProfileCreationTime, storageUserNaclKey, storageUserKyberKey, err := getPeerChatKeysMapListFromMyMapListStorage()
if (err != nil) { return false, false, [32]byte{}, [1568]byte{}, 0, err }
if (databaseUserProfileExists == false){
@ -402,7 +402,7 @@ func GetPeerNewestActiveChatKeys(peerIdentityHash [16]byte, networkType byte)(bo
return true, false, [32]byte{}, [1568]byte{}, 0, nil
}
return false, true, storageUserNaclKey, storageUserKyberKey, storageUserProfileBroadcastTime, nil
return false, true, storageUserNaclKey, storageUserKyberKey, storageUserProfileCreationTime, nil
}
// Database chat keys exist
@ -411,7 +411,7 @@ func GetPeerNewestActiveChatKeys(peerIdentityHash [16]byte, networkType byte)(bo
// Both the database profile and the datastore info exist
// We see which contains newer information
if (databaseUserProfileBroadcastTime <= storageUserProfileBroadcastTime){
if (databaseUserProfileCreationTime <= storageUserProfileCreationTime){
// myMapList storage is up to date, or even more recent than the stored profile
// The latter would occur if a newer profile was deleted at some point, and an older profile was downloaded
// We return the myMapList stored data
@ -419,13 +419,13 @@ func GetPeerNewestActiveChatKeys(peerIdentityHash [16]byte, networkType byte)(bo
if (storageProfileIsDisabled == true){
return true, false, [32]byte{}, [1568]byte{}, 0, nil
}
return false, true, storageUserNaclKey, storageUserKyberKey, storageUserProfileBroadcastTime, nil
return false, true, storageUserNaclKey, storageUserKyberKey, storageUserProfileCreationTime, nil
}
}
// MyMapList chat keys entry is either missing or out of date.
// Update them with database profile keys, and return the database profile chat keys
// Note that just because the broadcasted profile is newer does not mean the chat keys are any different.
// Note that just because the created profile is newer does not mean the chat keys are any different.
networkTypeString := helpers.ConvertByteToString(networkType)
@ -437,12 +437,12 @@ func GetPeerNewestActiveChatKeys(peerIdentityHash [16]byte, networkType byte)(bo
err = peerChatKeysMapListDatastore.DeleteMapListItems(deleteLookupMap)
if (err != nil) { return false, false, [32]byte{}, [1568]byte{}, 0, err }
broadcastedTimeString := helpers.ConvertInt64ToString(databaseUserProfileBroadcastTime)
creationTimeString := helpers.ConvertInt64ToString(databaseUserProfileCreationTime)
newChatKeysMap := map[string]string{
"PeerIdentityHash": peerIdentityHashString,
"NetworkType": networkTypeString,
"BroadcastedTime": broadcastedTimeString,
"CreationTime": creationTimeString,
}
if (databaseProfileIsDisabled == true){
@ -463,10 +463,10 @@ func GetPeerNewestActiveChatKeys(peerIdentityHash [16]byte, networkType byte)(bo
return true, false, [32]byte{}, [1568]byte{}, 0, nil
}
return false, true, databaseUserNaclKey, databaseUserKyberKey, databaseUserProfileBroadcastTime, nil
return false, true, databaseUserNaclKey, databaseUserKyberKey, databaseUserProfileCreationTime, nil
}
peerProfileIsDisabled, peerChatKeysExist, peerNewestKnownNaclKey, peerNewestKnownKyberKey, peerNewestKnownKeysBroadcastTime, err := getPeerNewestKnownChatKeys()
peerProfileIsDisabled, peerChatKeysExist, peerNewestKnownNaclKey, peerNewestKnownKyberKey, peerNewestKnownKeysCreationTime, err := getPeerNewestKnownChatKeys()
if (err != nil) { return false, false, [32]byte{}, [1568]byte{}, err }
if (peerProfileIsDisabled == true){
return true, false, [32]byte{}, [1568]byte{}, nil
@ -475,13 +475,13 @@ func GetPeerNewestActiveChatKeys(peerIdentityHash [16]byte, networkType byte)(bo
return false, false, [32]byte{}, [1568]byte{}, nil
}
// We check to see if user has updated their device since they sent/broadcast these keys
// We check to see if user has updated their device since they created these keys
deviceInfoFound, _, deviceFirstSeenTime, err := peerDevices.GetPeerNewestDeviceInfo(peerIdentityHash, networkType)
if (err != nil) { return false, false, [32]byte{}, [1568]byte{}, err }
if (deviceInfoFound == true){
if (deviceFirstSeenTime > peerNewestKnownKeysBroadcastTime){
// User has changed their device since they sent/broadcast these keys
if (deviceFirstSeenTime > peerNewestKnownKeysCreationTime){
// User has changed their device since they created these keys
// We do not have access to the user's chat keys
return false, false, [32]byte{}, [1568]byte{}, nil
}
@ -498,7 +498,7 @@ func GetPeerNewestActiveChatKeys(peerIdentityHash [16]byte, networkType byte)(bo
keysExpirationTime := newestUpdateTime - dayUnix
if (peerNewestKnownKeysBroadcastTime < keysExpirationTime){
if (peerNewestKnownKeysCreationTime < keysExpirationTime){
return false, false, [32]byte{}, [1568]byte{}, nil
}
}

View file

@ -61,7 +61,7 @@ func GetPeerNewestDeviceInfo(peerIdentityHash [16]byte, networkType byte)(bool,
return false, [11]byte{}, 0, errors.New("GetPeerNewestDeviceInfo called with invalid networkType: " + networkTypeString)
}
// We use this lock because we are comparing the map time with the newest stored profile broadcast time
// We use this lock because we are comparing the map time with the newest stored profile creation time
// If we added a newer time from a message during this process, without a lock, we could overwrite the newer time from the message
updatingPeerDevicesMapMutex.Lock()
defer updatingPeerDevicesMapMutex.Unlock()
@ -70,11 +70,11 @@ func GetPeerNewestDeviceInfo(peerIdentityHash [16]byte, networkType byte)(bool,
// -bool: Peer profile found
// -string: Peer profile device identifier (encoded Hex)
// -[11]byte: Peer profile device identifier
// -int64: Broadcast time of profile
// -int64: Creation time of profile
// -error
getPeerDeviceIdentifierFromNewestProfile := func()(bool, string, [11]byte, int64, error){
profileExists, _, _, _, profileBroadcastTime, rawProfileMap, err := profileStorage.GetNewestUserProfile(peerIdentityHash, networkType)
profileExists, _, _, _, profileCreationTime, rawProfileMap, err := profileStorage.GetNewestUserProfile(peerIdentityHash, networkType)
if (err != nil) { return false, "", [11]byte{}, 0, err }
if (profileExists == false){
return false, "", [11]byte{}, 0, nil
@ -97,10 +97,10 @@ func GetPeerNewestDeviceInfo(peerIdentityHash [16]byte, networkType byte)(bool,
deviceIdentifierArray := [11]byte(deviceIdentifierBytes)
return true, deviceIdentifierHex, deviceIdentifierArray, profileBroadcastTime, nil
return true, deviceIdentifierHex, deviceIdentifierArray, profileCreationTime, nil
}
peerProfileFound, peerProfileDeviceIdentifierHex, peerProfileDeviceIdentifier, peerProfileBroadcastTime, err := getPeerDeviceIdentifierFromNewestProfile()
peerProfileFound, peerProfileDeviceIdentifierHex, peerProfileDeviceIdentifier, peerProfileCreationTime, err := getPeerDeviceIdentifierFromNewestProfile()
if (err != nil) { return false, [11]byte{}, 0, err }
peerIdentityHashString, _, err := identity.EncodeIdentityHashBytesToString(peerIdentityHash)
@ -123,14 +123,14 @@ func GetPeerNewestDeviceInfo(peerIdentityHash [16]byte, networkType byte)(bool,
// peerProfileFound == true
peerProfileBroadcastTimeString := helpers.ConvertInt64ToString(peerProfileBroadcastTime)
peerProfileCreationTimeString := helpers.ConvertInt64ToString(peerProfileCreationTime)
newMapValue := peerProfileDeviceIdentifierHex + "$" + peerProfileBroadcastTimeString
newMapValue := peerProfileDeviceIdentifierHex + "$" + peerProfileCreationTimeString
err := peerDevicesMapDatastore.SetMapEntry(peerDevicesMapDatastoreKey, newMapValue)
if (err != nil) { return false, [11]byte{}, 0, err }
return true, peerProfileDeviceIdentifier, peerProfileBroadcastTime, nil
return true, peerProfileDeviceIdentifier, peerProfileCreationTime, nil
}
// mapEntryExists == true
@ -151,7 +151,7 @@ func GetPeerNewestDeviceInfo(peerIdentityHash [16]byte, networkType byte)(bool,
mapDeviceIdentifierArray := [11]byte(mapDeviceIdentifierBytes)
mapDeviceFirstSeenTime, err := helpers.ConvertBroadcastTimeStringToInt64(mapDeviceFirstSeenTimeString)
mapDeviceFirstSeenTime, err := helpers.ConvertCreationTimeStringToInt64(mapDeviceFirstSeenTimeString)
if (err != nil){
return false, [11]byte{}, 0, errors.New("peerDevicesMapDatastore is malformed: Invalid device first seen time: " + mapDeviceFirstSeenTimeString)
}
@ -167,7 +167,7 @@ func GetPeerNewestDeviceInfo(peerIdentityHash [16]byte, networkType byte)(bool,
if (peerProfileDeviceIdentifierHex == mapDeviceIdentifier){
if (mapDeviceFirstSeenTime <= peerProfileBroadcastTime){
if (mapDeviceFirstSeenTime <= peerProfileCreationTime){
// Map device first seen time is earlier than or equal to the profile
// Nothing to update
return true, mapDeviceIdentifierArray, mapDeviceFirstSeenTime, nil
@ -177,25 +177,25 @@ func GetPeerNewestDeviceInfo(peerIdentityHash [16]byte, networkType byte)(bool,
// We will update the map with the profile time
} else {
if (mapDeviceFirstSeenTime >= peerProfileBroadcastTime){
if (mapDeviceFirstSeenTime >= peerProfileCreationTime){
// Map device first seen time is newer than or equal to the profile
// Nothing to update
return true, mapDeviceIdentifierArray, mapDeviceFirstSeenTime, nil
}
}
peerProfileBroadcastTimeString := helpers.ConvertInt64ToString(peerProfileBroadcastTime)
peerProfileCreationTimeString := helpers.ConvertInt64ToString(peerProfileCreationTime)
newMapValue := peerProfileDeviceIdentifierHex + "$" + peerProfileBroadcastTimeString
newMapValue := peerProfileDeviceIdentifierHex + "$" + peerProfileCreationTimeString
err = peerDevicesMapDatastore.SetMapEntry(peerDevicesMapDatastoreKey, newMapValue)
if (err != nil) { return false, [11]byte{}, 0, err }
return true, peerProfileDeviceIdentifier, peerProfileBroadcastTime, nil
return true, peerProfileDeviceIdentifier, peerProfileCreationTime, nil
}
func AddPeerDeviceIdentifierFromMessage(peerIdentityHash [16]byte, networkType byte, deviceIdentifierBytes [11]byte, messageTimeSentUnix int64)error{
func AddPeerDeviceIdentifierFromMessage(peerIdentityHash [16]byte, networkType byte, deviceIdentifierBytes [11]byte, messageCreationTimeUnix int64)error{
peerIdentityHashString, identityType, err := identity.EncodeIdentityHashBytesToString(peerIdentityHash)
if (err != nil) {
@ -220,10 +220,10 @@ func AddPeerDeviceIdentifierFromMessage(peerIdentityHash [16]byte, networkType b
latestAllowedTime := currentTime + dayUnix
if (messageTimeSentUnix > latestAllowedTime){
if (messageCreationTimeUnix > latestAllowedTime){
// Either sender's or our own computer clock must be inaccurate
// We don't want to add the device identifier because it could prevent us from ever being able to contact the user
// For example, if the user's message sent time is accidentally 1 year in the future, we would not be able to contact them for 1 year
// For example, if the user's message creation time is accidentally 1 year in the future, we would not be able to contact them for 1 year
// We would mistakenly reject all of their new profile chat keys as being out of date
return nil
}
@ -247,14 +247,14 @@ func AddPeerDeviceIdentifierFromMessage(peerIdentityHash [16]byte, networkType b
return errors.New("peerDevicesMapDatastore is malformed: Invalid value: " + mapValue)
}
mapDeviceFirstSeenTime, err := helpers.ConvertBroadcastTimeStringToInt64(mapDeviceFirstSeenTimeString)
mapDeviceFirstSeenTime, err := helpers.ConvertCreationTimeStringToInt64(mapDeviceFirstSeenTimeString)
if (err != nil){
return errors.New("peerDevicesMapDatastore is malformed: Invalid device first seen time: " + mapDeviceFirstSeenTimeString)
}
if (mapDeviceIdentifier == deviceIdentifier){
if (mapDeviceFirstSeenTime <= messageTimeSentUnix){
if (mapDeviceFirstSeenTime <= messageCreationTimeUnix){
// Our map device first seen time is earlier than or equal to the message
// Nothing to do
return nil
@ -262,7 +262,7 @@ func AddPeerDeviceIdentifierFromMessage(peerIdentityHash [16]byte, networkType b
// We will update our map device first seen time to be earlier
} else {
if (mapDeviceFirstSeenTime >= messageTimeSentUnix){
if (mapDeviceFirstSeenTime >= messageCreationTimeUnix){
// Our map device first seen time is newer than or equal to the input message.
// Nothing to do
return nil
@ -270,9 +270,9 @@ func AddPeerDeviceIdentifierFromMessage(peerIdentityHash [16]byte, networkType b
}
}
messageTimeSentUnixString := helpers.ConvertInt64ToString(messageTimeSentUnix)
messageCreationTimeUnixString := helpers.ConvertInt64ToString(messageCreationTimeUnix)
newMapValue := deviceIdentifier + "$" + messageTimeSentUnixString
newMapValue := deviceIdentifier + "$" + messageCreationTimeUnixString
err = peerDevicesMapDatastore.SetMapEntry(peerDevicesMapDatastoreKey, newMapValue)
if (err != nil) { return err }

View file

@ -43,7 +43,7 @@ func InitializePeerSecretInboxesDatastore()error{
//Outputs:
// -bool: Parameters exist
// -error
func AddPeerConversationSecretInboxSeeds(myIdentityHash [16]byte, peerIdentityHash [16]byte, networkType byte, messageSentTime int64, peerCurrentSecretInboxSeed [22]byte, peerNextSecretInboxSeed [22]byte)(bool, error){
func AddPeerConversationSecretInboxSeeds(myIdentityHash [16]byte, peerIdentityHash [16]byte, networkType byte, messageCreationTime int64, peerCurrentSecretInboxSeed [22]byte, peerNextSecretInboxSeed [22]byte)(bool, error){
myIdentityHashString, myIdentityType, err := identity.EncodeIdentityHashBytesToString(myIdentityHash)
if (err != nil){
@ -66,7 +66,7 @@ func AddPeerConversationSecretInboxSeeds(myIdentityHash [16]byte, peerIdentityHa
return false, errors.New("AddPeerConversationSecretInboxSeeds called with invalid networkType: " + networkTypeString)
}
parametersExist, currentSecretInboxStartTime, currentSecretInboxEndTime, nextSecretInboxStartTime, nextSecretInboxEndTime, err := secretInboxEpoch.GetSecretInboxEpochStartAndEndTimes(networkType, messageSentTime)
parametersExist, currentSecretInboxStartTime, currentSecretInboxEndTime, nextSecretInboxStartTime, nextSecretInboxEndTime, err := secretInboxEpoch.GetSecretInboxEpochStartAndEndTimes(networkType, messageCreationTime)
if (err != nil) { return false, err }
if (parametersExist == false){
return false, nil
@ -129,7 +129,7 @@ func AddPeerConversationSecretInboxSeeds(myIdentityHash [16]byte, peerIdentityHa
mostRecentSentTime, exists := inboxMap["MostRecentSentTime"]
if (exists == false){
return errors.New("Malformed peerSecretInboxesMapList: Item missing MostRecentSentTime")
return errors.New("Malformed peerSecretInboxesMapList: Item missing MostRecentCreationTime")
}
mostRecentSentTimeInt64, err := helpers.ConvertStringToInt64(mostRecentSentTime)
@ -137,9 +137,9 @@ func AddPeerConversationSecretInboxSeeds(myIdentityHash [16]byte, peerIdentityHa
return errors.New("Malformed peerSecretInboxesMapList: Item contains invalid MostRecentSentTime: " + mostRecentSentTime)
}
if (mostRecentSentTimeInt64 < messageSentTime){
messageSentTimeString := helpers.ConvertInt64ToString(messageSentTime)
inboxMap["MostRecentSentTime"] = messageSentTimeString
if (mostRecentSentTimeInt64 < messageCreationTime){
messageCreationTimeString := helpers.ConvertInt64ToString(messageCreationTime)
inboxMap["MostRecentSentTime"] = messageCreationTimeString
}
existingInboxStartTimeString, exists := inboxMap["InboxStartTime"]
@ -184,7 +184,7 @@ func AddPeerConversationSecretInboxSeeds(myIdentityHash [16]byte, peerIdentityHa
// This is only reached if the inbox map does not exist.
networkTypeString := helpers.ConvertByteToString(networkType)
messageSentTimeString := helpers.ConvertInt64ToString(messageSentTime)
messageCreationTimeString := helpers.ConvertInt64ToString(messageCreationTime)
inboxStartTimeString := helpers.ConvertInt64ToString(inboxStartTime)
inboxEndTimeString := helpers.ConvertInt64ToString(inboxEndTime)
@ -193,7 +193,7 @@ func AddPeerConversationSecretInboxSeeds(myIdentityHash [16]byte, peerIdentityHa
"TheirIdentityHash": peerIdentityHashString,
"NetworkType": networkTypeString,
"SecretInboxSeed": secretInboxSeedHex,
"MostRecentSentTime": messageSentTimeString,
"MostRecentSentTime": messageCreationTimeString,
"InboxStartTime": inboxStartTimeString,
"InboxEndTime": inboxEndTimeString,
}
@ -338,7 +338,7 @@ func GetPeerConversationCurrentSecretInbox(myIdentityHash [16]byte, peerIdentity
if (err != nil) { return false, [10]byte{}, [32]byte{}, err }
if (deviceInfoFound == true && newestDeviceFirstSeenTime > newestSecretInboxMostRecentSentTime){
// The peer has changed their device after they sent us this secret inbox
// The peer has changed their device after they created a message containing this secret inbox
// We assume this inbox was not carried over to the new device, and we say that no secret inbox exists
return false, [10]byte{}, [32]byte{}, nil

View file

@ -247,7 +247,7 @@ func ReadChatMessagePublicData(verifyData bool, inputMessage []byte)(bool, int,
}
// This struct defines a chat key set which is used to decrypt a chat message
// Each user may have multiple key sets, if they have broadcast newer keys more recently.
// Each user may have multiple key sets, if they have shared newer keys more recently.
// They keep their old keys so they can decrypt messages sent to their older keys.
type ChatKeySet struct{
@ -270,7 +270,7 @@ type ChatKeySet struct{
// -[32]byte: Message Cipher Key
// -[16]byte: Sender Identity Hash
// -[16]byte: Recipient Identity Hash
// -int64: Message sent time (unix)
// -int64: Message creation time (unix)
// -string: Communication
// -[22]byte: Sender Current secret inbox seed
// -[22]byte: Sender Next secret inbox seed
@ -309,7 +309,7 @@ func ReadChatMessage(inputMessage []byte, doubleSealedKeysDecryptionKey [32]byte
getBasaldataDecryptionKey := func()(bool, [32]byte, error){
// This cycles through all chat decryption keys the user has
// They broadcast new keys on their profile, and delete old keys after a certain time period
// They share new keys on their profile, and delete old keys after a certain time period
for _, keySetObject := range recipientDecryptionKeySetsList{
@ -391,7 +391,7 @@ func ReadChatMessage(inputMessage []byte, doubleSealedKeysDecryptionKey [32]byte
}
recipientIdentityHashEncoded := basaldataSlice[0]
messageSentTimeUnixEncoded := basaldataSlice[1]
messageCreationTimeUnixEncoded := basaldataSlice[1]
senderCurrentSecretInboxSeedEncoded := basaldataSlice[2]
senderNextSecretInboxSeedEncoded := basaldataSlice[3]
senderDeviceIdentifierEncoded := basaldataSlice[4]
@ -403,9 +403,9 @@ func ReadChatMessage(inputMessage []byte, doubleSealedKeysDecryptionKey [32]byte
return false, [26]byte{}, 0, 0, [32]byte{}, [16]byte{}, [16]byte{}, 0, "", [22]byte{}, [22]byte{}, [11]byte{}, 0, nil
}
messageSentTimeUnix, err := encoding.DecodeRawMessagePackToInt64(messageSentTimeUnixEncoded)
messageCreationTimeUnix, err := encoding.DecodeRawMessagePackToInt64(messageCreationTimeUnixEncoded)
if (err != nil) {
// Malformed message basaldata: Invalid SentTime
// Malformed message basaldata: Invalid CreationTime
return false, [26]byte{}, 0, 0, [32]byte{}, [16]byte{}, [16]byte{}, 0, "", [22]byte{}, [22]byte{}, [11]byte{}, 0, nil
}
@ -444,13 +444,13 @@ func ReadChatMessage(inputMessage []byte, doubleSealedKeysDecryptionKey [32]byte
return false, [26]byte{}, 0, 0, [32]byte{}, [16]byte{}, [16]byte{}, 0, "", [22]byte{}, [22]byte{}, [11]byte{}, 0, nil
}
isValid := helpers.VerifyBroadcastTime(messageSentTimeUnix)
isValid := helpers.VerifyCreationTime(messageCreationTimeUnix)
if (isValid == false){
// Malformed message basaldata: Contains invalid unixSentTime
// Malformed message basaldata: Contains invalid messageCreationTime
return false, [26]byte{}, 0, 0, [32]byte{}, [16]byte{}, [16]byte{}, 0, "", [22]byte{}, [22]byte{}, [11]byte{}, 0, nil
}
return true, messageHash, messageVersion, messageNetworkType, messageCipherKeyArray, senderIdentityHash, recipientIdentityHash, messageSentTimeUnix, messageCommunication, senderCurrentSecretInboxSeed, senderNextSecretInboxSeed, senderDeviceIdentifier, senderLatestChatKeysUpdateTime, nil
return true, messageHash, messageVersion, messageNetworkType, messageCipherKeyArray, senderIdentityHash, recipientIdentityHash, messageCreationTimeUnix, messageCommunication, senderCurrentSecretInboxSeed, senderNextSecretInboxSeed, senderDeviceIdentifier, senderLatestChatKeysUpdateTime, nil
}
// This is used by moderators to decrypt a chat message

View file

@ -29,7 +29,7 @@ import "errors"
const secretInboxEpochOriginTime int64 = 1670000000
// This function returns the epoch start and end times at the time of the provided messageSentTime
// This function returns the epoch start and end times at the time of the provided messageCreationTime
//Outputs:
// -bool: Parameters exist
// -int64: Current epoch start time
@ -37,7 +37,7 @@ const secretInboxEpochOriginTime int64 = 1670000000
// -int64: Next epoch start time
// -int64: Next epoch start time
// -error
func GetSecretInboxEpochStartAndEndTimes(networkType byte, messageSentTime int64)(bool, int64, int64, int64, int64, error){
func GetSecretInboxEpochStartAndEndTimes(networkType byte, messageCreationTime int64)(bool, int64, int64, int64, int64, error){
isValid := helpers.VerifyNetworkType(networkType)
if (isValid == false){
@ -45,19 +45,19 @@ func GetSecretInboxEpochStartAndEndTimes(networkType byte, messageSentTime int64
return false, 0, 0, 0, 0, errors.New("GetSecretInboxEpochStartAndEndTimes called with invalid networkType: " + networkTypeString)
}
if (messageSentTime < secretInboxEpochOriginTime){
return false, 0, 0, 0, 0, errors.New("GetSecretInboxEpochStartAndEndTimes called with invalid messageSentTime.")
if (messageCreationTime < secretInboxEpochOriginTime){
return false, 0, 0, 0, 0, errors.New("GetSecretInboxEpochStartAndEndTimes called with invalid messageCreationTime.")
}
parametersExist, epochDuration, err := getParameters.GetSecretInboxEpochDuration(networkType, messageSentTime)
parametersExist, epochDuration, err := getParameters.GetSecretInboxEpochDuration(networkType, messageCreationTime)
if (err != nil) { return false, 0, 0, 0, 0, err }
if (parametersExist == false){
return false, 0, 0, 0, 0, nil
}
remainder := (messageSentTime - secretInboxEpochOriginTime) % (epochDuration + 1)
remainder := (messageCreationTime - secretInboxEpochOriginTime) % (epochDuration + 1)
currentEpochStartTime := messageSentTime - remainder
currentEpochStartTime := messageCreationTime - remainder
currentEpochEndTime := currentEpochStartTime + epochDuration
nextEpochStartTime := currentEpochEndTime + 1

View file

@ -5,7 +5,7 @@ package createReports
// We encode each attribute as an integer in MessagePack:
// ReportVersion = 1
// BroadcastTime = 3
// CreationTime = 3
// ReportedHash = 4
// Reason = 5
// MessageCipherKey = 6
@ -39,7 +39,7 @@ func CreateReport(reportMap map[string]string)([]byte, error){
return nil, errors.New("CreateReport called with reportMap containing invalid NetworkType: " + reportNetworkTypeString)
}
broadcastTime := time.Now().Unix()
creationTime := time.Now().Unix()
reportedHashString, exists := reportMap["ReportedHash"]
if (exists == false){
@ -57,7 +57,7 @@ func CreateReport(reportMap map[string]string)([]byte, error){
reportNetworkTypeEncoded, err := encoding.EncodeMessagePackBytes(reportNetworkType)
if (err != nil){ return nil, err }
broadcastTimeEncoded, err := encoding.EncodeMessagePackBytes(broadcastTime)
creationTimeEncoded, err := encoding.EncodeMessagePackBytes(creationTime)
if (err != nil){ return nil, err }
reportedHashEncoded, err := encoding.EncodeMessagePackBytes(reportedHash)
@ -66,7 +66,7 @@ func CreateReport(reportMap map[string]string)([]byte, error){
reportContentMap := map[int]messagepack.RawMessage{
1: reportVersionEncoded,
2: reportNetworkTypeEncoded,
3: broadcastTimeEncoded,
3: creationTimeEncoded,
4: reportedHashEncoded,
}

View file

@ -8,7 +8,7 @@ package createReviews
// ReviewVersion = 1
// NetworkType = 2
// IdentityKey = 3
// BroadcastTime = 4
// CreationTime = 4
// ReviewedHash = 5
// Verdict = 6
// Reason = 7
@ -44,7 +44,7 @@ func CreateReview(identityPublicKey [32]byte, identityPrivateKey [64]byte, revie
return nil, errors.New("CreateReview called with reviewMap containing invalid NetworkType: " + networkTypeString)
}
broadcastTime := time.Now().Unix()
creationTime := time.Now().Unix()
reviewedHashString, exists := reviewMap["ReviewedHash"]
if (exists == false){
@ -70,7 +70,7 @@ func CreateReview(identityPublicKey [32]byte, identityPrivateKey [64]byte, revie
identityKeyEncoded, err := encoding.EncodeMessagePackBytes(identityPublicKey)
if (err != nil) { return nil, err }
broadcastTimeEncoded, err := encoding.EncodeMessagePackBytes(broadcastTime)
creationTimeEncoded, err := encoding.EncodeMessagePackBytes(creationTime)
if (err != nil) { return nil, err }
reviewedHashEncoded, err := encoding.EncodeMessagePackBytes(reviewedHashBytes)
@ -83,7 +83,7 @@ func CreateReview(identityPublicKey [32]byte, identityPrivateKey [64]byte, revie
1: reviewVersionEncoded,
2: networkTypeEncoded,
3: identityKeyEncoded,
4: broadcastTimeEncoded,
4: creationTimeEncoded,
5: reviewedHashEncoded,
6: reviewVerdictEncoded,
}

View file

@ -547,7 +547,7 @@ func GetMyNewestReviewsListSorted(reviewType string, networkType byte)(bool, [][
if (err != nil) { return false, nil, err }
type ReviewObject struct{
ReviewBroadcastTime int64
ReviewCreationTime int64
ReviewBytes []byte
}
@ -557,7 +557,7 @@ func GetMyNewestReviewsListSorted(reviewType string, networkType byte)(bool, [][
reviewedHashBytes := []byte(reviewedHashString)
ableToRead, _, reviewNetworkType, reviewAuthorIdentityHash, reviewBroadcastTime, currentReviewType, currentReviewedHash, _, _, err := readReviews.ReadReview(false, reviewBytes)
ableToRead, _, reviewNetworkType, reviewAuthorIdentityHash, reviewCreationTime, currentReviewType, currentReviewedHash, _, _, err := readReviews.ReadReview(false, reviewBytes)
if (err != nil) { return false, nil, err }
if (ableToRead == false){
return false, nil, errors.New("getMyNewestReviewsMap returning invalid review")
@ -577,23 +577,23 @@ func GetMyNewestReviewsListSorted(reviewType string, networkType byte)(bool, [][
}
reviewObject := ReviewObject{
ReviewBroadcastTime: reviewBroadcastTime,
ReviewCreationTime: reviewCreationTime,
ReviewBytes: reviewBytes,
}
newestReviewObjectsList = append(newestReviewObjectsList, reviewObject)
}
compareReviewsFunction := func(reviewA ReviewObject, reviewB ReviewObject)int{
compareReviewsFunction := func(review1 ReviewObject, review2 ReviewObject)int{
reviewABroadcastTime := reviewA.ReviewBroadcastTime
reviewBBroadcastTime := reviewB.ReviewBroadcastTime
review1CreationTime := review1.ReviewCreationTime
review2CreationTime := review2.ReviewCreationTime
if (reviewABroadcastTime == reviewBBroadcastTime){
if (review1CreationTime == review2CreationTime){
return 0
}
if (reviewABroadcastTime < reviewBBroadcastTime){
if (review1CreationTime < review2CreationTime){
return 1
}

View file

@ -81,14 +81,14 @@ func GetReportTypeFromReportHash(inputHash [30]byte)(string, error){
// -[30]byte: Report Hash
// -int: Report Version
// -byte: Network Type (1 == Mainnet, 2 == Testnet1)
// -int64: Broadcast Time (alleged, could be fake, like all broadcast times)
// -int64: Creation Time (alleged, could be fake, like all creation times)
// -string: Report Type
// -[]byte: Reported Hash
// -map[string]string: Report map
// -error
func ReadReportAndHash(verifyReport bool, inputReport []byte)(bool, [30]byte, int, byte, int64, string, []byte, map[string]string, error){
ableToRead, reportVersion, reportNetworkType, reportBroadcastTime, reportType, reportedHash, reportMap, err := ReadReport(verifyReport, inputReport)
ableToRead, reportVersion, reportNetworkType, reportCreationTime, reportType, reportedHash, reportMap, err := ReadReport(verifyReport, inputReport)
if (err != nil){ return false, [30]byte{}, 0, 0, 0, "", nil, nil, err }
if (ableToRead == false){
return false, [30]byte{}, 0, 0, 0, "", nil, nil, nil
@ -122,7 +122,7 @@ func ReadReportAndHash(verifyReport bool, inputReport []byte)(bool, [30]byte, in
reportHash := [30]byte(reportHashSlice)
return true, reportHash, reportVersion, reportNetworkType, reportBroadcastTime, reportType, reportedHash, reportMap, nil
return true, reportHash, reportVersion, reportNetworkType, reportCreationTime, reportType, reportedHash, reportMap, nil
}
// This function does not compute the report hash, thus it is faster
@ -130,7 +130,7 @@ func ReadReportAndHash(verifyReport bool, inputReport []byte)(bool, [30]byte, in
// -bool: Able to read
// -int: Report Version
// -byte: Network Type (1 == Mainnet, 2 == Testnet1)
// -int64: Broadcast Time (alleged, could be fake, like all broadcast times)
// -int64: Creation Time (alleged, could be fake, like all creation times)
// -string: Report Type
// -[]byte: Reported Hash
// -map[string]string: Report map
@ -180,15 +180,15 @@ func ReadReport(verifyReport bool, inputReport []byte)(bool, int, byte, int64, s
return false, 0, 0, 0, "", nil, nil, nil
}
broadcastTimeMessagepack, exists := reportContentMap[3]
creationTimeMessagepack, exists := reportContentMap[3]
if (exists == false){
// Invalid Report: Missing BroadcastTime
// Invalid Report: Missing CreationTime
return false, 0, 0, 0, "", nil, nil, nil
}
broadcastTime, err := encoding.DecodeRawMessagePackToInt64(broadcastTimeMessagepack)
creationTime, err := encoding.DecodeRawMessagePackToInt64(creationTimeMessagepack)
if (err != nil) {
// Invalid Report: Invalid BroadcastTime
// Invalid Report: Invalid CreationTime
return false, 0, 0, 0, "", nil, nil, nil
}
@ -240,9 +240,9 @@ func ReadReport(verifyReport bool, inputReport []byte)(bool, int, byte, int64, s
if (verifyReport == true){
isValid := helpers.VerifyBroadcastTime(broadcastTime)
isValid := helpers.VerifyCreationTime(creationTime)
if (isValid == false){
// Invalid report: Invalid broadcast time
// Invalid report: Invalid creation time
return false, 0, 0, 0, "", nil, nil, nil
}
@ -273,7 +273,7 @@ func ReadReport(verifyReport bool, inputReport []byte)(bool, int, byte, int64, s
reportNetworkTypeString := helpers.ConvertByteToString(reportNetworkType)
broadcastTimeString := helpers.ConvertInt64ToString(broadcastTime)
creationTimeString := helpers.ConvertInt64ToString(creationTime)
reportedHashString, err := helpers.EncodeReportedHashBytesToString(reportedHash)
if (err != nil) { return false, 0, 0, 0, "", nil, nil, err }
@ -281,7 +281,7 @@ func ReadReport(verifyReport bool, inputReport []byte)(bool, int, byte, int64, s
reportMap := map[string]string{
"ReportVersion": reportVersionString,
"NetworkType": reportNetworkTypeString,
"BroadcastTime": broadcastTimeString,
"CreationTime": creationTimeString,
"ReportedHash": reportedHashString,
}
@ -295,7 +295,7 @@ func ReadReport(verifyReport bool, inputReport []byte)(bool, int, byte, int64, s
reportMap["Reason"] = reason
}
return true, 1, reportNetworkType, broadcastTime, reportType, reportedHash, reportMap, nil
return true, 1, reportNetworkType, creationTime, reportType, reportedHash, reportMap, nil
}

View file

@ -84,7 +84,7 @@ func GetReviewTypeFromReviewHash(inputHash [29]byte)(string, error){
// -int: Review version
// -byte: Network Type (1 == Mainnet, 2 == Testnet1)
// -[16]byte: Identity Hash of reviewer (Review author)
// -int64: Broadcast time (alleged, can be faked)
// -int64: Creation time (alleged, can be faked)
// -string: Review type
// -[]byte: Reviewed hash
// -string: Review Verdict
@ -92,7 +92,7 @@ func GetReviewTypeFromReviewHash(inputHash [29]byte)(string, error){
// -error (returns err if there is a bug in the code)
func ReadReviewAndHash(verifyReview bool, inputReview []byte)(bool, [29]byte, int, byte, [16]byte, int64, string, []byte, string, map[string]string, error){
ableToRead, reviewVersion, reviewNetworkType, reviewAuthor, reviewBroadcastTime, reviewType, reviewedHash, reviewVerdict, reviewMap, err := ReadReview(verifyReview, inputReview)
ableToRead, reviewVersion, reviewNetworkType, reviewAuthor, reviewCreationTime, reviewType, reviewedHash, reviewVerdict, reviewMap, err := ReadReview(verifyReview, inputReview)
if (err != nil) { return false, [29]byte{}, 0, 0, [16]byte{}, 0, "", nil, "", nil, err }
if (ableToRead == false){
return false, [29]byte{}, 0, 0, [16]byte{}, 0, "", nil, "", nil, nil
@ -130,7 +130,7 @@ func ReadReviewAndHash(verifyReview bool, inputReview []byte)(bool, [29]byte, in
reviewHash := [29]byte(reviewHashSlice)
return true, reviewHash, reviewVersion, reviewNetworkType, reviewAuthor, reviewBroadcastTime, reviewType, reviewedHash, reviewVerdict, reviewMap, nil
return true, reviewHash, reviewVersion, reviewNetworkType, reviewAuthor, reviewCreationTime, reviewType, reviewedHash, reviewVerdict, reviewMap, nil
}
@ -142,7 +142,7 @@ func ReadReviewAndHash(verifyReview bool, inputReview []byte)(bool, [29]byte, in
// -int: Review version
// -byte: Network Type (1 == Mainnet, 2 == Testnet1)
// -[16]byte: Identity Hash of reviewer (Review author)
// -int64: Broadcast time (alleged, can be faked)
// -int64: Creation time (alleged, can be faked)
// -string: Review type
// -[]byte: Reviewed hash
// -string: Review Verdict
@ -242,15 +242,15 @@ func ReadReview(verifyReview bool, inputReview []byte)(bool, int, byte, [16]byte
authorIdentityHash, err := identity.ConvertIdentityKeyToIdentityHash(authorIdentityKey, "Moderator")
if (err != nil) { return false, 0, 0, [16]byte{}, 0, "", nil, "", nil, err }
broadcastTimeMessagepack, exists := reviewContentMap[4]
creationTimeMessagepack, exists := reviewContentMap[4]
if (exists == false){
// Invalid Review: Missing BroadcastTime
// Invalid Review: Missing CreationTime
return false, 0, 0, [16]byte{}, 0, "", nil, "", nil, nil
}
broadcastTime, err := encoding.DecodeRawMessagePackToInt64(broadcastTimeMessagepack)
creationTime, err := encoding.DecodeRawMessagePackToInt64(creationTimeMessagepack)
if (err != nil) {
// Invalid Review: Invalid BroadcastTime
// Invalid Review: Invalid CreationTime
return false, 0, 0, [16]byte{}, 0, "", nil, "", nil, nil
}
@ -315,9 +315,9 @@ func ReadReview(verifyReview bool, inputReview []byte)(bool, int, byte, [16]byte
if (verifyReview == true){
isValid := helpers.VerifyBroadcastTime(broadcastTime)
isValid := helpers.VerifyCreationTime(creationTime)
if (isValid == false){
// Invalid review: Review contains contains invalid BroadcastTime
// Invalid review: Review contains contains invalid CreationTime
return false, 0, 0, [16]byte{}, 0, "", nil, "", nil, nil
}
@ -368,7 +368,7 @@ func ReadReview(verifyReview bool, inputReview []byte)(bool, int, byte, [16]byte
authorIdentityKeyHex := encoding.EncodeBytesToHexString(authorIdentityKey[:])
broadcastTimeString := helpers.ConvertInt64ToString(broadcastTime)
creationTimeString := helpers.ConvertInt64ToString(creationTime)
reviewedHashString, err := helpers.EncodeReviewedHashBytesToString(reviewedHash)
if (err != nil){
@ -379,7 +379,7 @@ func ReadReview(verifyReview bool, inputReview []byte)(bool, int, byte, [16]byte
"ReviewVersion": "1",
"NetworkType": reviewNetworkTypeString,
"IdentityKey": authorIdentityKeyHex,
"BroadcastTime": broadcastTimeString,
"CreationTime": creationTimeString,
"ReviewedHash": reviewedHashString,
"Verdict": reviewVerdict,
}
@ -394,7 +394,7 @@ func ReadReview(verifyReview bool, inputReview []byte)(bool, int, byte, [16]byte
reviewMap["MessageCipherKey"] = messageCipherKey
}
return true, 1, reviewNetworkType, authorIdentityHash, broadcastTime, reviewType, reviewedHash, reviewVerdict, reviewMap, nil
return true, 1, reviewNetworkType, authorIdentityHash, creationTime, reviewType, reviewedHash, reviewVerdict, reviewMap, nil
}
@ -536,7 +536,7 @@ func getModeratorNewestVerdictMapsFromReviewsList(reviewsList []ReviewWithHash,
// This stores info about a review
type ReviewInfoObject struct{
ReviewHash [29]byte
BroadcastTime int64
CreationTime int64
Verdict string
}
@ -549,7 +549,7 @@ func getModeratorNewestVerdictMapsFromReviewsList(reviewsList []ReviewWithHash,
reviewHash := reviewWithHash.ReviewHash
reviewBytes := reviewWithHash.ReviewBytes
ableToRead, _, reviewNetworkType, reviewAuthor, reviewBroadcastTime, currentReviewType, currentReviewedHash, reviewVerdict, reviewMap, err := ReadReview(false, reviewBytes)
ableToRead, _, reviewNetworkType, reviewAuthor, reviewCreationTime, currentReviewType, currentReviewedHash, reviewVerdict, reviewMap, err := ReadReview(false, reviewBytes)
if (err != nil) { return nil, nil, err }
if (ableToRead == false){
return nil, nil, errors.New("getModeratorNewestVerdictMapsFromReviewsList called with invalid review.")
@ -576,9 +576,9 @@ func getModeratorNewestVerdictMapsFromReviewsList(reviewsList []ReviewWithHash,
existingNewestReviewInfoObject, exists := newestReviewsMap[reviewAuthor]
if (exists == true){
existingNewestReviewBroadcastTime := existingNewestReviewInfoObject.BroadcastTime
existingNewestReviewCreationTime := existingNewestReviewInfoObject.CreationTime
if (existingNewestReviewBroadcastTime == reviewBroadcastTime){
if (existingNewestReviewCreationTime == reviewCreationTime){
// The reviewer must be malicious, or their computer clock was skewed somehow
// We compare the review hashes to see which review to use
// This is necessary so that a moderator's newest review will always be calculated the same way by all Seekia clients.
@ -595,7 +595,7 @@ func getModeratorNewestVerdictMapsFromReviewsList(reviewsList []ReviewWithHash,
continue
}
} else if (existingNewestReviewBroadcastTime > reviewBroadcastTime){
} else if (existingNewestReviewCreationTime > reviewCreationTime){
// This review was overwritten/replaced by a newer review
continue
}
@ -603,7 +603,7 @@ func getModeratorNewestVerdictMapsFromReviewsList(reviewsList []ReviewWithHash,
newNewestReviewInfoObject := ReviewInfoObject{
ReviewHash: reviewHash,
BroadcastTime: reviewBroadcastTime,
CreationTime: reviewCreationTime,
Verdict: reviewVerdict,
}
@ -619,17 +619,17 @@ func getModeratorNewestVerdictMapsFromReviewsList(reviewsList []ReviewWithHash,
for reviewerIdentityHash, reviewerNewestReviewInfoObject := range newestReviewsMap{
newestReviewVerdict := reviewerNewestReviewInfoObject.Verdict
reviewBroadcastTime := reviewerNewestReviewInfoObject.BroadcastTime
reviewCreationTime := reviewerNewestReviewInfoObject.CreationTime
if (newestReviewVerdict == "Approve"){
approveAdvocatesMap[reviewerIdentityHash] = reviewBroadcastTime
approveAdvocatesMap[reviewerIdentityHash] = reviewCreationTime
continue
} else if (newestReviewVerdict == "Ban"){
banAdvocatesMap[reviewerIdentityHash] = reviewBroadcastTime
banAdvocatesMap[reviewerIdentityHash] = reviewCreationTime
continue
@ -686,9 +686,9 @@ func GetModeratorNewestProfileReviewFromReviewsList(inputReviewsList []ReviewWit
return true, nil
}
reviewExists, reviewBytes, reviewMap, reviewVerdict, reviewBroadcastTime, err := getNewestModeratorReviewFromReviewsList(inputReviewsList, moderatorIdentityHash, "Profile", profileHash[:], profileNetworkType, verifyReviewIsValidFunction)
reviewExists, reviewBytes, reviewMap, reviewVerdict, reviewCreationTime, err := getNewestModeratorReviewFromReviewsList(inputReviewsList, moderatorIdentityHash, "Profile", profileHash[:], profileNetworkType, verifyReviewIsValidFunction)
return reviewExists, reviewBytes, reviewMap, reviewVerdict, reviewBroadcastTime, err
return reviewExists, reviewBytes, reviewMap, reviewVerdict, reviewCreationTime, err
}
//Outputs:
@ -756,7 +756,7 @@ func GetModeratorNewestMessageReviewFromReviewsList(inputReviewsList []ReviewWit
// -[]byte: Newest review bytes
// -map[string]string: Newest review map
// -string: Newest review verdict
// -int64: Newest review broadcast time
// -int64: Newest review creation time
// -error
func getNewestModeratorReviewFromReviewsList(inputReviewsList []ReviewWithHash, moderatorIdentityHash [16]byte, reviewType string, reviewedHash []byte, networkType byte, verifyReviewIsValid func(map[string]string)(bool, error))(bool, []byte, map[string]string, string, int64, error){
@ -781,7 +781,7 @@ func getNewestModeratorReviewFromReviewsList(inputReviewsList []ReviewWithHash,
newestReviewHash := [29]byte{}
newestReviewBytes := make([]byte, 0)
newestReviewMap := make(map[string]string)
newestReviewBroadcastTime := int64(0)
newestReviewCreationTime := int64(0)
newestReviewVerdict := ""
for _, reviewWithHash := range inputReviewsList{
@ -789,7 +789,7 @@ func getNewestModeratorReviewFromReviewsList(inputReviewsList []ReviewWithHash,
reviewHash := reviewWithHash.ReviewHash
reviewBytes := reviewWithHash.ReviewBytes
ableToRead, _, reviewNetworkType, reviewAuthor, reviewBroadcastTime, currentReviewType, currentReviewedHash, reviewVerdict, reviewMap, err := ReadReview(false, reviewBytes)
ableToRead, _, reviewNetworkType, reviewAuthor, reviewCreationTime, currentReviewType, currentReviewedHash, reviewVerdict, reviewMap, err := ReadReview(false, reviewBytes)
if (err != nil) { return false, nil, nil, "", 0, err }
if (ableToRead == false){
return false, nil, nil, "", 0, errors.New("getNewestModeratorReviewFromReviewsList called with invalid review")
@ -817,9 +817,9 @@ func getNewestModeratorReviewFromReviewsList(inputReviewsList []ReviewWithHash,
continue
}
if (anyReviewFound == false || reviewBroadcastTime >= newestReviewBroadcastTime){
if (anyReviewFound == false || reviewCreationTime >= newestReviewCreationTime){
if (reviewBroadcastTime == newestReviewBroadcastTime){
if (reviewCreationTime == newestReviewCreationTime){
// The reviewer must be malicious, or their computer clock was skewed somehow
// We compare the review hashes to see which review to use
// This is necessary so that a moderator's newest review will always be calculated the same way by all Seekia clients.
@ -839,7 +839,7 @@ func getNewestModeratorReviewFromReviewsList(inputReviewsList []ReviewWithHash,
newestReviewHash = reviewHash
newestReviewBytes = reviewBytes
newestReviewMap = reviewMap
newestReviewBroadcastTime = reviewBroadcastTime
newestReviewCreationTime = reviewCreationTime
newestReviewVerdict = reviewVerdict
}
}
@ -851,7 +851,7 @@ func getNewestModeratorReviewFromReviewsList(inputReviewsList []ReviewWithHash,
return false, nil, nil, "", 0, nil
}
return true, newestReviewBytes, newestReviewMap, newestReviewVerdict, newestReviewBroadcastTime, nil
return true, newestReviewBytes, newestReviewMap, newestReviewVerdict, newestReviewCreationTime, nil
}
@ -890,7 +890,7 @@ func GetNewestModeratorReviewsMapFromReviewsList(inputReviewsList []ReviewWithHa
type ReviewInfoObject struct{
ReviewHash [29]byte
Verdict string
BroadcastTime int64
CreationTime int64
ReviewBytes []byte
}
@ -903,7 +903,7 @@ func GetNewestModeratorReviewsMapFromReviewsList(inputReviewsList []ReviewWithHa
reviewHash := reviewWithHash.ReviewHash
reviewBytes := reviewWithHash.ReviewBytes
ableToRead, _, reviewNetworkType, reviewAuthor, reviewBroadcastTime, currentReviewType, reviewedHash, reviewVerdict, _, err := ReadReview(false, reviewBytes)
ableToRead, _, reviewNetworkType, reviewAuthor, reviewCreationTime, currentReviewType, reviewedHash, reviewVerdict, _, err := ReadReview(false, reviewBytes)
if (err != nil) { return nil, err }
if (ableToRead == false){
return nil, errors.New("GetNewestModeratorReviewsMapFromReviewsList called with invalid review")
@ -923,12 +923,12 @@ func GetNewestModeratorReviewsMapFromReviewsList(inputReviewsList []ReviewWithHa
existingNewestReviewInfoObject, exists := newestReviewInfoObjectsMap[string(reviewedHash)]
if (exists == true){
existingBroadcastTime := existingNewestReviewInfoObject.BroadcastTime
existingCreationTime := existingNewestReviewInfoObject.CreationTime
if (exists == false){
return nil, errors.New("reviewBroadcastTimesMap missing reviewHash entry")
return nil, errors.New("reviewCreationTimesMap missing reviewHash entry")
}
if (existingBroadcastTime == reviewBroadcastTime){
if (existingCreationTime == reviewCreationTime){
// The reviewer must be malicious, or their computer clock was skewed somehow
// We compare the review hashes to see which review to use
// This is necessary so that a moderator's newest review will always be calculated the same way by all Seekia clients.
@ -945,7 +945,7 @@ func GetNewestModeratorReviewsMapFromReviewsList(inputReviewsList []ReviewWithHa
continue
}
} else if (existingBroadcastTime > reviewBroadcastTime){
} else if (existingCreationTime > reviewCreationTime){
// The user has replaced their review with a newer one
continue
}
@ -954,7 +954,7 @@ func GetNewestModeratorReviewsMapFromReviewsList(inputReviewsList []ReviewWithHa
newNewestReviewInfoObject := ReviewInfoObject{
ReviewHash: reviewHash,
Verdict: reviewVerdict,
BroadcastTime: reviewBroadcastTime,
CreationTime: reviewCreationTime,
ReviewBytes: reviewBytes,
}

View file

@ -263,7 +263,7 @@ func GetModeratorNewestProfileReviews(moderatorIdentityHash [16]byte, profileHas
// -[]byte: Review bytes
// -map[string]string: Review map
// -string: Review verdict
// -int64: Review broadcast time
// -int64: Review creation time
// -error
func getModeratorNewestFullProfileReview(moderatorIdentityHash [16]byte, profileHash [28]byte, profileNetworkType byte)(bool, []byte, map[string]string, string, int64, error){
@ -357,7 +357,7 @@ func GetModeratorNewestProfileAttributeReview(moderatorIdentityHash [16]byte, at
// -[]byte: Review bytes
// -map[string]string: Review map
// -string: Review verdict
// -int64: Review broadcast time
// -int64: Review creation time
// -error
getModeratorNewestAttributeReview := func()(bool, []byte, map[string]string, string, int64, error){

View file

@ -160,12 +160,12 @@ func GetServerResponseForRequest(requestBytes []byte, networkType byte, connecti
for _, parametersType := range allParametersTypesList{
parametersFound, _, _, parametersBroadcastTime, err := parametersStorage.GetAuthorizedParameters(parametersType, networkType)
parametersFound, _, _, parametersCreationTime, err := parametersStorage.GetAuthorizedParameters(parametersType, networkType)
if (err != nil) { return nil, err }
if (parametersFound == false){
continue
}
parametersInfoMap[parametersType] = parametersBroadcastTime
parametersInfoMap[parametersType] = parametersCreationTime
}
responseBytes, err := serverResponse.CreateServerResponse_GetParametersInfo(myHostPublicIdentityKey, myHostPrivateIdentityKey, connectionKey, requestIdentifier, parametersInfoMap)
@ -442,7 +442,7 @@ func GetServerResponseForRequest(requestBytes []byte, networkType byte, connecti
continue
}
ableToRead, profileHash_Retrieved, profileVersion, profileNetworkType, profileAuthor, profileBroadcastTime, profileIsDisabled, rawProfileMap, err := readProfiles.ReadProfileAndHash(false, profileBytes)
ableToRead, profileHash_Retrieved, profileVersion, profileNetworkType, profileAuthor, profileCreationTime, profileIsDisabled, rawProfileMap, err := readProfiles.ReadProfileAndHash(false, profileBytes)
if (err != nil) { return nil, err }
if (ableToRead == false){
return nil, errors.New("Database corrupt: contains invalid " + profileTypeToRetrieve + " profile")
@ -484,7 +484,7 @@ func GetServerResponseForRequest(requestBytes []byte, networkType byte, connecti
profileInfoObject := serverResponse.ProfileInfoStruct{
ProfileHash: profileHash,
ProfileAuthor: profileAuthor,
ProfileBroadcastTime: profileBroadcastTime,
ProfileCreationTime: profileCreationTime,
}
profileInfoObjectsList = append(profileInfoObjectsList, profileInfoObject)

View file

@ -161,8 +161,8 @@ func GetEligibleHostsList(networkType byte)([][16]byte, error){
viewableHostsList := make([][16]byte, 0)
// Map structure: Host identity hash -> Newest viewable profile broadcast time
hostBroadcastTimesMap := make(map[[16]byte]int64)
// Map structure: Host identity hash -> Newest viewable profile creation time
hostCreationTimesMap := make(map[[16]byte]int64)
for _, hostIdentityHash := range fundedHostsList{
@ -173,13 +173,13 @@ func GetEligibleHostsList(networkType byte)([][16]byte, error){
//TODO: Check if host is a network entry host, in which case, they cannot be banned
exists, _, _, _, profileBroadcastTime, _, err := viewableProfiles.GetNewestViewableUserProfile(hostIdentityHash, networkType, true, true, true)
exists, _, _, _, profileCreationTime, _, err := viewableProfiles.GetNewestViewableUserProfile(hostIdentityHash, networkType, true, true, true)
if (err != nil) { return nil, err }
if (exists == false){
continue
}
hostBroadcastTimesMap[hostIdentityHash] = profileBroadcastTime
hostCreationTimesMap[hostIdentityHash] = profileCreationTime
viewableHostsList = append(viewableHostsList, hostIdentityHash)
}
@ -200,9 +200,9 @@ func GetEligibleHostsList(networkType byte)([][16]byte, error){
for _, hostIdentityHash := range viewableHostsList{
hostProfileBroadcastTime, exists := hostBroadcastTimesMap[hostIdentityHash]
hostProfileCreationTime, exists := hostCreationTimesMap[hostIdentityHash]
if (exists == false){
return nil, errors.New("hostBroadcastTimesMap missing host identity hash.")
return nil, errors.New("hostCreationTimesMap missing host identity hash.")
}
_, maximumExistenceDuration, err := getParameters.GetHostProfileMaximumExistenceDuration(networkType)
@ -210,7 +210,7 @@ func GetEligibleHostsList(networkType byte)([][16]byte, error){
currentTime := time.Now().Unix()
profileAge := currentTime - hostProfileBroadcastTime
profileAge := currentTime - hostProfileCreationTime
if (profileAge > maximumExistenceDuration){
// Host's profile has expired

View file

@ -401,7 +401,7 @@ func StartNewestUserProfileDownload(userIdentityHash [16]byte, networkType byte,
profilesInfoObject := profilesInfoObjectsList[0]
profileHash := profilesInfoObject.ProfileHash
profileBroadcastTime := profilesInfoObject.ProfileBroadcastTime
profileCreationTime := profilesInfoObject.ProfileCreationTime
// We check if we already have this profile
alreadyExists, _, err := profileStorage.GetStoredProfile(profileHash)
@ -429,8 +429,8 @@ func StartNewestUserProfileDownload(userIdentityHash [16]byte, networkType byte,
expectedProfileIdentityHashesMap := make(map[[28]byte][16]byte)
expectedProfileIdentityHashesMap[profileHash] = userIdentityHash
expectedProfileBroadcastTimesMap := make(map[[28]byte]int64)
expectedProfileBroadcastTimesMap[profileHash] = profileBroadcastTime
expectedProfileCreationTimesMap := make(map[[28]byte]int64)
expectedProfileCreationTimesMap[profileHash] = profileCreationTime
processFound, processIsComplete, errorEncountered, _, _, _, _ = GetProcessInfo(processIdentifier)
if (processFound == false){
@ -442,7 +442,7 @@ func StartNewestUserProfileDownload(userIdentityHash [16]byte, networkType byte,
return nil
}
downloadSuccessful, listOfProfiles, err := sendRequests.GetProfilesFromHost(connectionIdentifier, hostIdentityHash, networkType, userIdentityType, profileHashesToDownloadList, expectedProfileIdentityHashesMap, expectedProfileBroadcastTimesMap, nil)
downloadSuccessful, listOfProfiles, err := sendRequests.GetProfilesFromHost(connectionIdentifier, hostIdentityHash, networkType, userIdentityType, profileHashesToDownloadList, expectedProfileIdentityHashesMap, expectedProfileCreationTimesMap, nil)
if (err != nil) { return err }
if (downloadSuccessful == false){

View file

@ -204,11 +204,11 @@ func GetMyNewestBroadcastProfile(myIdentityHash [16]byte, networkType byte)(bool
var newestProfileHash [28]byte
newestProfileBytes := make([]byte, 0)
newestProfileRawProfileMap := make(map[int]messagepack.RawMessage)
newestProfileBroadcastTime := int64(0)
newestProfileCreationTime := int64(0)
for _, profileBytes := range broadcastProfilesList{
ableToRead, profileHash, profileVersion, profileNetworkType, profileIdentityHash, profileBroadcastTime, _, rawProfileMap, err := readProfiles.ReadProfileAndHash(true, profileBytes)
ableToRead, profileHash, profileVersion, profileNetworkType, profileIdentityHash, profileCreationTime, _, rawProfileMap, err := readProfiles.ReadProfileAndHash(true, profileBytes)
if (err != nil) { return false, 0, [28]byte{}, nil, nil, err }
if (ableToRead == false){
return false, 0, [28]byte{}, nil, nil, errors.New("MyBroadcasts contains invalid profile.")
@ -221,14 +221,14 @@ func GetMyNewestBroadcastProfile(myIdentityHash [16]byte, networkType byte)(bool
continue
}
if (anyProfileFound == false || profileBroadcastTime > newestProfileBroadcastTime){
if (anyProfileFound == false || profileCreationTime > newestProfileCreationTime){
anyProfileFound = true
newestProfileVersion = profileVersion
newestProfileHash = profileHash
newestProfileBytes = profileBytes
newestProfileRawProfileMap = rawProfileMap
newestProfileBroadcastTime = profileBroadcastTime
newestProfileCreationTime = profileCreationTime
}
}
@ -265,7 +265,7 @@ func UpdateMyBroadcastProfile(myIdentityType string, networkType byte)(bool, [28
return false, [28]byte{}, errors.New("UpdateMyBroadcastProfile called when export profile is missing.")
}
ableToRead, newProfileHash, _, newProfileNetworkType, profileIdentityHash, newProfileBroadcastTime, _, newProfileRawProfileMap, err := readProfiles.ReadProfileAndHash(true, newProfileBytes)
ableToRead, newProfileHash, _, newProfileNetworkType, profileIdentityHash, newProfileCreationTime, _, newProfileRawProfileMap, err := readProfiles.ReadProfileAndHash(true, newProfileBytes)
if (err != nil) { return false, [28]byte{}, err }
if (ableToRead == false){
return false, [28]byte{}, errors.New("MyExports contains invalid profile.")
@ -331,7 +331,7 @@ func UpdateMyBroadcastProfile(myIdentityType string, networkType byte)(bool, [28
if (err != nil) { return false, [28]byte{}, err }
if (latestChatKeysTimeNeedsUpdate == true){
err := myChatKeys.SetMyChatKeysLatestUpdateTime(myIdentityHash, networkType, newProfileBroadcastTime)
err := myChatKeys.SetMyChatKeysLatestUpdateTime(myIdentityHash, networkType, newProfileCreationTime)
if (err != nil) { return false, [28]byte{}, err }
}

View file

@ -100,11 +100,11 @@ func DownloadAllNewestViewableUserProfiles(profileType string, networkType byte)
return errors.New("DownloadAllNewestViewableUserProfiles called with invalid profileType: " + profileType)
}
checkIfProfileShouldBeDownloaded := func(_ [28]byte, profileAuthor [16]byte, profileBroadcastTime int64)(bool, error){
checkIfProfileShouldBeDownloaded := func(_ [28]byte, profileAuthor [16]byte, profileCreationTime int64)(bool, error){
// Check to see if our newest profile is older than the received profile
newestViewableProfileExists, _, _, _, storedProfileBroadcastTime, _, err := viewableProfiles.GetNewestViewableUserProfile(profileAuthor, networkType, true, false, true)
newestViewableProfileExists, _, _, _, storedProfileCreationTime, _, err := viewableProfiles.GetNewestViewableUserProfile(profileAuthor, networkType, true, false, true)
if (err != nil) { return false, err }
if (newestViewableProfileExists == false){
// We do not have any viewable profiles for this host
@ -112,7 +112,7 @@ func DownloadAllNewestViewableUserProfiles(profileType string, networkType byte)
return true, nil
}
if (profileBroadcastTime <= storedProfileBroadcastTime){
if (profileCreationTime <= storedProfileCreationTime){
// Host we are retrieving from has a profile that is not newer than our existing profile
// We can skip this profile
return false, nil
@ -175,7 +175,7 @@ func DownloadMateProfilesToBrowse(networkType byte)error{
emptyList := make([][16]byte, 0)
checkIfProfileShouldBeDownloaded := func(_ [28]byte, profileAuthor [16]byte, profileBroadcastTime int64)(bool, error){
checkIfProfileShouldBeDownloaded := func(_ [28]byte, profileAuthor [16]byte, profileCreationTime int64)(bool, error){
// This function is only called if profile hash is not already downloaded
// We check if we have a profile that is newer (and viewable)
// If we have a newer viewable profile, we will skip downloading this profile
@ -183,13 +183,13 @@ func DownloadMateProfilesToBrowse(networkType byte)error{
// We wont check, but if we have a newer profile that is not known to be viewable, we will still download this profile
// We will delete this older profile if and when the newer profile becomes viewable
profileExists, _, _, _, storedProfileBroadcastTime, _, err := viewableProfiles.GetNewestViewableUserProfile(profileAuthor, networkType, true, false, true)
profileExists, _, _, _, storedProfileCreationTime, _, err := viewableProfiles.GetNewestViewableUserProfile(profileAuthor, networkType, true, false, true)
if (err != nil) { return false, err }
if (profileExists == false){
return true, nil
}
if (storedProfileBroadcastTime >= profileBroadcastTime){
if (storedProfileCreationTime >= profileCreationTime){
// The profile the host is offering is not newer than our existing
// We will skip it
@ -305,18 +305,18 @@ func DownloadMateOutlierProfiles(outlierType string, networkType byte, missingOr
}
}
checkIfProfileShouldBeDownloaded := func(_ [28]byte, profileAuthor [16]byte, profileBroadcastTime int64)(bool, error){
checkIfProfileShouldBeDownloaded := func(_ [28]byte, profileAuthor [16]byte, profileCreationTime int64)(bool, error){
// We check to see if this profile is newer than our stored newest viewable profile for the identity
// If it is, we download the profile
profileExists, _, _, _, existingProfileBroadcastTime, _, err := viewableProfiles.GetNewestViewableUserProfile(profileAuthor, networkType, true, false, true)
profileExists, _, _, _, existingProfileCreationTime, _, err := viewableProfiles.GetNewestViewableUserProfile(profileAuthor, networkType, true, false, true)
if (err != nil) { return false, err }
if (profileExists == false){
return true, nil
}
if (profileBroadcastTime <= existingProfileBroadcastTime){
if (profileCreationTime <= existingProfileCreationTime){
return false, nil
}
@ -364,7 +364,7 @@ func DownloadProfilesToHost(profileType string, networkType byte)error{
return nil
}
checkIfProfileShouldBeDownloaded := func(profileHash [28]byte, profileAuthor [16]byte, profileBroadcastTime int64)(bool, error){
checkIfProfileShouldBeDownloaded := func(profileHash [28]byte, profileAuthor [16]byte, profileCreationTime int64)(bool, error){
//TODO
@ -389,7 +389,7 @@ func DownloadProfilesToHost(profileType string, networkType byte)error{
// We only want to download this older profile if it can be used by moderators to determine if the identity should be banned
// We dont want this to be abused, if an attacker created a report for many old profiles that existed on the network, they could cause hosts to download all those old profiles
// So, if profile has been approved for a long enough period of time, it does not need to be hosted anymore
// We cannot trust the broadcastTimes for reviews, reports, or profiles, so each host keeps track of the time that a consensus has existed based on the reviews it has downloaded
// We cannot trust the creationTimes for reviews, reports, or profiles, so each host keeps track of the time that a consensus has existed based on the reviews it has downloaded
// We use verdictHistory for this
// If offered profile is approved, we check to see if profile has been approved for at least the maximum time to store old approved profiles
@ -472,7 +472,7 @@ func DownloadProfilesToModerate(profileType string, networkType byte)error{
return nil
}
checkIfProfileShouldBeDownloaded := func(profileHash [28]byte, profileIdentityHash [16]byte, profileBroadcastTime int64)(bool, error){
checkIfProfileShouldBeDownloaded := func(profileHash [28]byte, profileIdentityHash [16]byte, profileCreationTime int64)(bool, error){
//TODO: See if we have already reviewed the profile, if yes, then we don't need to download it.
// Also, if we have the profile's metadata, and it is not the user's newest profile, and it has no ban reviews, we don't need to download it.

View file

@ -109,17 +109,17 @@ func DownloadParametersFromHosts(allowClearnet bool, networkType byte, numberOfH
return false, nil
}
// We will check to see if our parameters broadcast time is older than the one the host is offering
// We will check to see if our parameters creation time is older than the one the host is offering
// If it is, we will download it and continue
parametersTypesToRetrieveList := make([]string, 0)
for parametersType, parametersBroadcastTime := range parametersInfoMap{
for parametersType, parametersCreationTime := range parametersInfoMap{
storedParametersFound, _, _, storedParametersBroadcastTime, err := parametersStorage.GetAuthorizedParameters(parametersType, networkType)
storedParametersFound, _, _, storedParametersCreationTime, err := parametersStorage.GetAuthorizedParameters(parametersType, networkType)
if (err != nil) { return false, err }
if (storedParametersFound == true){
if (storedParametersBroadcastTime < parametersBroadcastTime){
if (storedParametersCreationTime < parametersCreationTime){
// The offered parameters are not newer than our existing parameters
// Skip downloading them.
continue
@ -471,8 +471,8 @@ func DownloadProfilesFromHosts(
profileHashesToDownloadList := make([][28]byte, 0)
// Structure: Profile Hash -> Expected Broadcast Time
profileBroadcastTimesMap := make(map[[28]byte]int64)
// Structure: Profile Hash -> Expected Creation Time
profileCreationTimesMap := make(map[[28]byte]int64)
// Structure: Profile Hash -> Identity Hash
profileIdentityHashesMap := make(map[[28]byte][16]byte)
@ -485,7 +485,7 @@ func DownloadProfilesFromHosts(
receivedProfileAuthor := profileInfoObject.ProfileAuthor
receivedProfileBroadcastTime := profileInfoObject.ProfileBroadcastTime
receivedProfileCreationTime := profileInfoObject.ProfileCreationTime
// Now we check to see if we already have the profile
// We check to see if it is known to be outside of requested range/identities list/criteria (host is malicious)
@ -502,7 +502,7 @@ func DownloadProfilesFromHosts(
return false, nil
}
ableToRead, storedProfileHash, profileVersion, profileNetworkType, storedProfileAuthor, storedProfileBroadcastTime, _, storedRawProfileMap, err := readProfiles.ReadProfileAndHash(false, storedProfileBytes)
ableToRead, storedProfileHash, profileVersion, profileNetworkType, storedProfileAuthor, storedProfileCreationTime, _, storedRawProfileMap, err := readProfiles.ReadProfileAndHash(false, storedProfileBytes)
if (err != nil) { return false, err }
if (ableToRead == false){
return false, errors.New("Database corrupt: Contains invalid profile.")
@ -516,7 +516,7 @@ func DownloadProfilesFromHosts(
if (storedProfileAuthor != receivedProfileAuthor){
return true, nil
}
if (storedProfileBroadcastTime != receivedProfileBroadcastTime){
if (storedProfileCreationTime != receivedProfileCreationTime){
return true, nil
}
@ -543,7 +543,7 @@ func DownloadProfilesFromHosts(
profileHashesToDownloadList = append(profileHashesToDownloadList, receivedProfileHash)
profileIdentityHashesMap[receivedProfileHash] = receivedProfileAuthor
profileBroadcastTimesMap[receivedProfileHash] = receivedProfileBroadcastTime
profileCreationTimesMap[receivedProfileHash] = receivedProfileCreationTime
continue
}
@ -553,7 +553,7 @@ func DownloadProfilesFromHosts(
// This is done to prevent hosts learning our private desires
profileHashesToDownloadList = append(profileHashesToDownloadList, receivedProfileHash)
profileIdentityHashesMap[receivedProfileHash] = receivedProfileAuthor
profileBroadcastTimesMap[receivedProfileHash] = receivedProfileBroadcastTime
profileCreationTimesMap[receivedProfileHash] = receivedProfileCreationTime
continue
}
@ -573,13 +573,13 @@ func DownloadProfilesFromHosts(
// Profile does not exist, we must check if we want to download it
// This works differently for Hosting, Moderation, and Browsing
shouldDownload, err := checkIfProfileShouldBeDownloaded(receivedProfileHash, receivedProfileAuthor, receivedProfileBroadcastTime)
shouldDownload, err := checkIfProfileShouldBeDownloaded(receivedProfileHash, receivedProfileAuthor, receivedProfileCreationTime)
if (err != nil) { return false, err }
if (shouldDownload == true){
profileHashesToDownloadList = append(profileHashesToDownloadList, receivedProfileHash)
profileIdentityHashesMap[receivedProfileHash] = receivedProfileAuthor
profileBroadcastTimesMap[receivedProfileHash] = receivedProfileBroadcastTime
profileCreationTimesMap[receivedProfileHash] = receivedProfileCreationTime
continue
}
}
@ -607,7 +607,7 @@ func DownloadProfilesFromHosts(
for _, profileHashesSublist := range profileHashesSublistsList{
downloadSuccessful, profilesList, err := sendRequests.GetProfilesFromHost(connectionIdentifier, hostIdentityHash, networkType, profileTypeToRetrieve, profileHashesSublist, profileIdentityHashesMap, profileBroadcastTimesMap, nil)
downloadSuccessful, profilesList, err := sendRequests.GetProfilesFromHost(connectionIdentifier, hostIdentityHash, networkType, profileTypeToRetrieve, profileHashesSublist, profileIdentityHashesMap, profileCreationTimesMap, nil)
if (err != nil) { return false, err }
if (downloadSuccessful == false){
// Request has failed

View file

@ -35,7 +35,7 @@ import "slices"
//Outputs:
// -bool: Download successsful
// -map[string]int64: Map of ParametersType -> Parameters broadcast time
// -map[string]int64: Map of ParametersType -> Parameters Creation time
// -error
func GetParametersInfoFromHost(connectionIdentifier [21]byte, hostIdentityHash [16]byte, networkType byte)(bool, map[string]int64, error){
@ -338,7 +338,7 @@ func GetProfilesFromHost(
profileTypeToRetrieve string,
profileHashesList [][28]byte,
expectedProfileIdentityHashesMap map[[28]byte][16]byte, // Profile Hash -> Profile Identity hash
expectedProfileBroadcastTimesMap map[[28]byte]int64, // Profile Hash -> Profile Broadcast Time
expectedProfileCreationTimesMap map[[28]byte]int64, // Profile Hash -> Profile Creation Time
expectedCriteria []byte)(bool, [][]byte, error){
connectionExists, connectionHostIdentityHash, connectionKey, connectionNetworkType, err := peerClient.GetConnectionMetadata(connectionIdentifier)
@ -394,7 +394,7 @@ func GetProfilesFromHost(
for _, profileBytes := range profilesList{
ableToRead, profileHash, profileVersion, profileNetworkType, profileIdentityHash, profileBroadcastTime, _, rawProfileMap, err := readProfiles.ReadProfileAndHash(false, profileBytes)
ableToRead, profileHash, profileVersion, profileNetworkType, profileIdentityHash, profileCreationTime, _, rawProfileMap, err := readProfiles.ReadProfileAndHash(false, profileBytes)
if (err != nil) { return false, err }
if (ableToRead == false){
return false, errors.New("ReadServerResponse_GetProfiles not verifying received profile is valid.")
@ -416,12 +416,12 @@ func GetProfilesFromHost(
return false, nil
}
expectedProfileBroadcastTime, exists := expectedProfileBroadcastTimesMap[profileHash]
expectedProfileCreationTime, exists := expectedProfileCreationTimesMap[profileHash]
if (exists == false){
return false, errors.New("expectedProfileBroadcastTimesMap missing entry for profile contained in ProfileHashesList")
return false, errors.New("expectedProfileCreationTimesMap missing entry for profile contained in ProfileHashesList")
}
if (profileBroadcastTime != expectedProfileBroadcastTime){
// Profile is does not fulfill the expected BroadcastTime
if (profileCreationTime != expectedProfileCreationTime){
// Profile is does not fulfill the expected CreationTime
return false, nil
}

View file

@ -215,7 +215,7 @@ func CreateServerResponse_GetParametersInfo(hostPublicIdentityKey [32]byte, host
HostIdentityKey [32]byte
RequestIdentifier [16]byte
ResponseType string
ParametersInfo map[string]int64 // Parameters Type -> Parameters broadcast time
ParametersInfo map[string]int64 // Parameters Type -> Parameters creation time
}
responseContentObject := responseContentStruct{
@ -238,7 +238,7 @@ func CreateServerResponse_GetParametersInfo(hostPublicIdentityKey [32]byte, host
// -bool: Able to read server response
// -[16]byte: Request Identifier
// -[16]byte: Host Identity Hash
// -map[string]int64: Parameters Info map (Parameters Type -> Parameters broadcast time)
// -map[string]int64: Parameters Info map (Parameters Type -> Parameters creation time)
// -error (returns err if input keys are invalid)
func ReadServerResponse_GetParametersInfo(responseBytes []byte, connectionKey [32]byte)(bool, [16]byte, [16]byte, map[string]int64, error){
@ -381,7 +381,7 @@ func ReadServerResponse_GetParameters(responseBytes []byte, connectionKey [32]by
type ProfileInfoStruct struct{
ProfileHash [28]byte
ProfileAuthor [16]byte
ProfileBroadcastTime int64
ProfileCreationTime int64
}
//Outputs:
@ -395,7 +395,7 @@ func CreateServerResponse_GetProfilesInfo(hostPublicIdentityKey [32]byte, hostPr
profileHash := profileInfoObject.ProfileHash
profileAuthor := profileInfoObject.ProfileAuthor
profileBroadcastTime := profileInfoObject.ProfileBroadcastTime
profileCreationTime := profileInfoObject.ProfileCreationTime
profileType, _, err := readProfiles.ReadProfileHashMetadata(profileHash)
if (err != nil){
@ -413,10 +413,10 @@ func CreateServerResponse_GetProfilesInfo(hostPublicIdentityKey [32]byte, hostPr
return nil, errors.New("Cannot create response: Invalid profileInfoObjectsList: ProfileHash profile type does not match profileAuthor identity type.")
}
isValid := helpers.VerifyBroadcastTime(profileBroadcastTime)
isValid := helpers.VerifyCreationTime(profileCreationTime)
if (isValid == false){
broadcastTimeString := helpers.ConvertInt64ToString(profileBroadcastTime)
return nil, errors.New("Cannot create response: Invalid profileInfoObjectsList: Invalid broadcastTime: " + broadcastTimeString)
creationTimeString := helpers.ConvertInt64ToString(profileCreationTime)
return nil, errors.New("Cannot create response: Invalid profileInfoObjectsList: Invalid creationTime: " + creationTimeString)
}
}

View file

@ -284,12 +284,12 @@ func TestCreateAndReadResponse_GetProfilesInfo(t *testing.T){
t.Fatalf("Failed to create random identity hash: " + err.Error())
}
profileBroadcastTime := time.Now().Unix()
profileCreationTime := time.Now().Unix()
profileInfoObject := serverResponse.ProfileInfoStruct{
ProfileHash: profileHash,
ProfileAuthor: profileAuthor,
ProfileBroadcastTime: profileBroadcastTime,
ProfileCreationTime: profileCreationTime,
}
profileInfoObjectsList = append(profileInfoObjectsList, profileInfoObject)

View file

@ -8,7 +8,7 @@ package createParameters
// ParametersVersion = 1
// NetworkType = 2
// AdminPublicKeys = 3
// BroadcastTime = 4
// CreationTime = 4
// ParametersType = 5
import "seekia/internal/cryptography/blake3"
@ -116,7 +116,7 @@ func CreateParametersContentBytes(adminPublicKeysList [][32]byte, parametersMap
parametersVersion := 1
broadcastTime := time.Now().Unix()
creationTime := time.Now().Unix()
parametersVersionEncoded, err := encoding.EncodeMessagePackBytes(parametersVersion)
if (err != nil) { return nil, err }
@ -127,7 +127,7 @@ func CreateParametersContentBytes(adminPublicKeysList [][32]byte, parametersMap
adminPublicKeysEncoded, err := encoding.EncodeMessagePackBytes(adminPublicKeysList)
if (err != nil) { return nil, err }
broadcastTimeEncoded, err := encoding.EncodeMessagePackBytes(broadcastTime)
creationTimeEncoded, err := encoding.EncodeMessagePackBytes(creationTime)
if (err != nil) { return nil, err }
parametersTypeEncoded, err := encoding.EncodeMessagePackBytes(parametersType)
@ -137,7 +137,7 @@ func CreateParametersContentBytes(adminPublicKeysList [][32]byte, parametersMap
1: parametersVersionEncoded,
2: networkTypeByteEncoded,
3: adminPublicKeysEncoded,
4: broadcastTimeEncoded,
4: creationTimeEncoded,
5: parametersTypeEncoded,
}

View file

@ -152,7 +152,7 @@ func GetHostProfileMaximumExistenceDuration(networkType byte)(bool, int64, error
// -bool: Parameters exist
// -float64: Identity network cost per day / grams gold (atomic units) //TODO: change from gram to milligram?
// -error
func GetIdentityBalanceGoldCostPerDay(networkType byte, identityType string, broadcastTime int64)(bool, float64, error){
func GetIdentityBalanceGoldCostPerDay(networkType byte, identityType string, creationTime int64)(bool, float64, error){
isValid := helpers.VerifyNetworkType(networkType)
if (isValid == false){
@ -176,7 +176,7 @@ func GetIdentityBalanceGoldCostPerDay(networkType byte, identityType string, bro
// -bool: Parameters exist
// -float64: Cost in grams of gold to fund 1KB message for 1 day
// -error
func GetMessageKilobyteGoldCostPerDay(networkType byte, broadcastTime int64)(bool, float64, error){
func GetMessageKilobyteGoldCostPerDay(networkType byte, creationTime int64)(bool, float64, error){
//TODO
// This represents the amount of gold it costs to fund a message on the network
@ -191,7 +191,7 @@ func GetMessageKilobyteGoldCostPerDay(networkType byte, broadcastTime int64)(boo
// -bool: Parameters exist
// -float64: Cost in grams of gold to fund a report
// -error
func GetFundReportCostInGold(networkType byte, broadcastTime int64)(bool, float64, error){
func GetFundReportCostInGold(networkType byte, creationTime int64)(bool, float64, error){
//TODO
// This represents the amount of gold it costs to fund a report on the network
@ -203,7 +203,7 @@ func GetFundReportCostInGold(networkType byte, broadcastTime int64)(bool, float6
// -bool: Parameters exist
// -float64: Grams of gold cost to fund a mate profile
// -error
func GetFundMateProfileCostInGold(networkType byte, broadcastTime int64)(bool, float64, error){
func GetFundMateProfileCostInGold(networkType byte, creationTime int64)(bool, float64, error){
//TODO
// This will return the cost in gold to fund a mate profile

View file

@ -26,13 +26,13 @@ const masterAdminPublicKey string = "TODO"
// -error
func AddParameters(inputParameters []byte)(bool, bool, error){
ableToRead, _, parametersNetworkType, listOfAdmins, parametersType, parametersBroadcastTime, _, err := readParameters.ReadParameters(true, inputParameters)
ableToRead, _, parametersNetworkType, listOfAdmins, parametersType, parametersCreationTime, _, err := readParameters.ReadParameters(true, inputParameters)
if (err != nil) { return false, false, err }
if (ableToRead == false){
return false, false, nil
}
adminParametersFound, parametersAreAuthorized, err := verifyParametersAreAuthorized(parametersType, parametersNetworkType, parametersBroadcastTime, listOfAdmins)
adminParametersFound, parametersAreAuthorized, err := verifyParametersAreAuthorized(parametersType, parametersNetworkType, parametersCreationTime, listOfAdmins)
if (err != nil) { return false, false, err }
if (adminParametersFound == false){
// We do not have admin parameters. We cannot determine if parameters to add are authorized
@ -46,10 +46,10 @@ func AddParameters(inputParameters []byte)(bool, bool, error){
// We check if parameters already exist that are newer
parametersFound, _, _, existingParametersBroadcastTime, err := GetAuthorizedParameters(parametersType, parametersNetworkType)
parametersFound, _, _, existingParametersCreationTime, err := GetAuthorizedParameters(parametersType, parametersNetworkType)
if (err != nil) { return false, false, err }
if (parametersFound == true){
if (existingParametersBroadcastTime >= parametersBroadcastTime){
if (existingParametersCreationTime >= parametersCreationTime){
// These parameters are older than our existing stored authorized parameters.
// We will not add them.
return true, true, nil
@ -78,7 +78,7 @@ func AddParameters(inputParameters []byte)(bool, bool, error){
// -bool: Requested parameters found and signed by valid admins
// -[]byte: Parameters bytes
// -map[string]string: Parameters map
// -int64: Parameters broadcast time
// -int64: Parameters creation time
// -error
func GetAuthorizedParameters(parametersType string, networkType byte)(bool, []byte, map[string]string, int64, error){
@ -99,7 +99,7 @@ func GetAuthorizedParameters(parametersType string, networkType byte)(bool, []by
return false, nil, nil, 0, nil
}
ableToRead, _, parametersNetworkType, listOfSigners, currentParametersType, parametersBroadcastTime, parametersMap, err := readParameters.ReadParameters(true, storedParametersBytes)
ableToRead, _, parametersNetworkType, listOfSigners, currentParametersType, parametersCreationTime, parametersMap, err := readParameters.ReadParameters(true, storedParametersBytes)
if (err != nil) { return false, nil, nil, 0, err }
if (ableToRead == false) {
return false, nil, nil, 0, errors.New("Stored parameters are corrupt: storing corrupt " + parametersType + "parameter.")
@ -111,20 +111,20 @@ func GetAuthorizedParameters(parametersType string, networkType byte)(bool, []by
return false, nil, nil, 0, errors.New("getStoredParameters returning different parametersType parameters")
}
adminPermissionsFound, parametersAreAuthorized, err := verifyParametersAreAuthorized(parametersType, networkType, parametersBroadcastTime, listOfSigners)
adminPermissionsFound, parametersAreAuthorized, err := verifyParametersAreAuthorized(parametersType, networkType, parametersCreationTime, listOfSigners)
if (err != nil) { return false, nil, nil, 0, err }
if (adminPermissionsFound == false || parametersAreAuthorized == false){
return false, nil, nil, 0, nil
}
return true, storedParametersBytes, parametersMap, parametersBroadcastTime, nil
return true, storedParametersBytes, parametersMap, parametersCreationTime, nil
}
//Outputs:
// -bool: Admin permissions found
// -bool: Parameters are authorized
// -error
func verifyParametersAreAuthorized(parametersType string, networkType byte, parametersBroadcastTime int64, parametersSigners [][32]byte)(bool, bool, error){
func verifyParametersAreAuthorized(parametersType string, networkType byte, parametersCreationTime int64, parametersSigners [][32]byte)(bool, bool, error){
containsDuplicates, _ := helpers.CheckIfListContainsDuplicates(parametersSigners)
if (containsDuplicates == true){
@ -204,17 +204,17 @@ func verifyParametersAreAuthorized(parametersType string, networkType byte, para
return false, false, errors.New("Parameters storage is corrupt: AdminPermissions contains less authorizedAdmins than minimumSigners")
}
minimumBroadcastTime, exists := adminPermissionsMap[parametersType + "_MinimumBroadcastTime"]
minimumCreationTime, exists := adminPermissionsMap[parametersType + "_MinimumCreationTime"]
if (exists == false) {
return false, false, errors.New("Parameters storage is corrupt: AdminPermissions missing minimumBroadcastTime but contains AuthorizedAdmins for parameterType.")
return false, false, errors.New("Parameters storage is corrupt: AdminPermissions missing minimumCreationTime but contains AuthorizedAdmins for parameterType.")
}
minimumBroadcastTimeInt64, err := helpers.ConvertStringToInt64(minimumBroadcastTime)
minimumCreationTimeInt64, err := helpers.ConvertStringToInt64(minimumCreationTime)
if (err != nil) {
return false, false, errors.New("Parameters storage is corrupt: AdminPermissions contains invalid minimumBroadcastTime: " + minimumBroadcastTime)
return false, false, errors.New("Parameters storage is corrupt: AdminPermissions contains invalid minimumCreationTime: " + minimumCreationTime)
}
if (parametersBroadcastTime < minimumBroadcastTimeInt64){
if (parametersCreationTime < minimumCreationTimeInt64){
return false, false, nil
}

View file

@ -63,12 +63,12 @@ func VerifyParameters(inputParameters []byte)(bool, error){
// -byte: Parameters network type byte (1 == Mainnet, 2 == Testnet1)
// -[][32]byte: List of admins who signed the parameters
// -string: Parameters type
// -int64: Parameters broadcast time
// -int64: Parameters creation time
// -map[string]string: Parameters Map
// -error (will return error if there is a bug in the function)
func ReadParametersAndHash(verifyParameters bool, inputParameters []byte)(bool, [31]byte, int, byte, [][32]byte, string, int64, map[string]string, error){
ableToRead, parametersVersion, parametersNetworkType, parametersAuthorsList, parametersType, parametersBroadcastTime, parametersMap, err := ReadParameters(verifyParameters, inputParameters)
ableToRead, parametersVersion, parametersNetworkType, parametersAuthorsList, parametersType, parametersCreationTime, parametersMap, err := ReadParameters(verifyParameters, inputParameters)
if (err != nil) { return false, [31]byte{}, 0, 0, nil, "", 0, nil, err }
if (ableToRead == false){
return false, [31]byte{}, 0, 0, nil, "", 0, nil, nil
@ -84,7 +84,7 @@ func ReadParametersAndHash(verifyParameters bool, inputParameters []byte)(bool,
parametersHash := [31]byte(parametersHashSlice)
return true, parametersHash, parametersVersion, parametersNetworkType, parametersAuthorsList, parametersType, parametersBroadcastTime, parametersMap, nil
return true, parametersHash, parametersVersion, parametersNetworkType, parametersAuthorsList, parametersType, parametersCreationTime, parametersMap, nil
}
@ -95,7 +95,7 @@ func ReadParametersAndHash(verifyParameters bool, inputParameters []byte)(bool,
// -byte: Parameters network type byte (1 == Mainnet, 2 == Testnet1)
// -[][32]byte: List of admins who signed the parameters
// -string: Parameters type
// -int64: Parameters broadcast time
// -int64: Parameters creation time
// -map[string]string: Parameters Map
// -error (will return error if there is a bug in the function)
func ReadParameters(verifyParameters bool, inputParameters []byte)(bool, int, byte, [][32]byte, string, int64, map[string]string, error){
@ -213,15 +213,15 @@ func ReadParameters(verifyParameters bool, inputParameters []byte)(bool, int, by
}
}
broadcastTimeEncoded, exists := rawParametersMap[4]
creationTimeEncoded, exists := rawParametersMap[4]
if (exists == false){
// Invalid parameters: Missing BroadcastTime
// Invalid parameters: Missing CreationTime
return false, 0, 0, nil, "", 0, nil, nil
}
broadcastTime, err := encoding.DecodeRawMessagePackToInt64(broadcastTimeEncoded)
creationTime, err := encoding.DecodeRawMessagePackToInt64(creationTimeEncoded)
if (err != nil){
// Invalid parameters: Contains invalid BroadcastTime
// Invalid parameters: Contains invalid CreationTime
return false, 0, 0, nil, "", 0, nil, nil
}
@ -239,9 +239,9 @@ func ReadParameters(verifyParameters bool, inputParameters []byte)(bool, int, by
if (verifyParameters == true){
isValid := helpers.VerifyBroadcastTime(broadcastTime)
isValid := helpers.VerifyCreationTime(creationTime)
if (isValid == false){
// Invalid parameters: Invalid BroadcastTime
// Invalid parameters: Invalid CreationTime
return false, 0, 0, nil, "", 0, nil, nil
}
@ -254,7 +254,7 @@ func ReadParameters(verifyParameters bool, inputParameters []byte)(bool, int, by
networkTypeString := helpers.ConvertByteToString(networkTypeByte)
broadcastTimeString := helpers.ConvertInt64ToString(broadcastTime)
creationTimeString := helpers.ConvertInt64ToString(creationTime)
adminPublicKeyStringsList := make([]string, 0, len(adminPublicKeysList))
@ -271,13 +271,13 @@ func ReadParameters(verifyParameters bool, inputParameters []byte)(bool, int, by
"ParametersVersion": "1",
"NetworkType": networkTypeString,
"ParametersType": parametersType,
"BroadcastTime": broadcastTimeString,
"CreationTime": creationTimeString,
"AdminPublicKeys": adminPublicKeysJoined,
}
//TODO: Add more
return true, parametersVersion, networkTypeByte, adminPublicKeysList, parametersType, broadcastTime, parametersMap, nil
return true, parametersVersion, networkTypeByte, adminPublicKeysList, parametersType, creationTime, parametersMap, nil
}

View file

@ -135,9 +135,9 @@ func GetProfileAttributeDisplayInfo(attributeName string)(string, bool, func(str
return titleTranslated, false, translateValueFunction, "", "", nil
}
case "BroadcastTime":{
case "CreationTime":{
titleTranslated := translation.TranslateTextFromEnglishToMyLanguage("Broadcast Time")
titleTranslated := translation.TranslateTextFromEnglishToMyLanguage("Creation Time")
return titleTranslated, true, passValueFunction, "", "", nil
}

View file

@ -54,9 +54,9 @@ func CreateProfile(identityPublicKey [32]byte, identityPrivateKey [64]byte, inpu
identityPublicKeyEncoded, err := encoding.EncodeMessagePackBytes(identityPublicKey)
if (err != nil) { return nil, err }
broadcastTime := time.Now().Unix()
creationTime := time.Now().Unix()
broadcastTimeEncoded, err := encoding.EncodeMessagePackBytes(broadcastTime)
creationTimeEncoded, err := encoding.EncodeMessagePackBytes(creationTime)
if (err != nil) { return nil, err }
profileContentMap := map[int]messagepack.RawMessage{
@ -64,7 +64,7 @@ func CreateProfile(identityPublicKey [32]byte, identityPrivateKey [64]byte, inpu
1: profileVersionEncoded,
2: identityPublicKeyEncoded,
3: profileTypeEncoded,
4: broadcastTimeEncoded,
4: creationTimeEncoded,
}
getProfileIsDisabledBool := func()bool{
@ -96,7 +96,7 @@ func CreateProfile(identityPublicKey [32]byte, identityPrivateKey [64]byte, inpu
return nil, errors.New("CreateProfile called with profileMap containing empty value.")
}
if (attributeName == "BroadcastTime" || attributeName == "ProfileVersion"){
if (attributeName == "CreationTime" || attributeName == "ProfileVersion"){
// This function should be called with profile maps which do not contain these attributes.
return nil, errors.New("CreateProfile called with profileMap containing unwanted attribute: " + attributeName)
}

View file

@ -81,7 +81,7 @@ func UpdateMyExportedProfile(myProfileType string, networkType byte)error{
attributeName := attributeObject.AttributeName
if (attributeName == "ProfileType" || attributeName == "BroadcastTime" || attributeName == "IdentityKey" || attributeName == "ProfileVersion" || attributeName == "Disabled"){
if (attributeName == "ProfileType" || attributeName == "CreationTime" || attributeName == "IdentityKey" || attributeName == "ProfileVersion" || attributeName == "Disabled"){
continue
}
@ -300,7 +300,7 @@ func UpdateMyExportedProfile(myProfileType string, networkType byte)error{
if (existingNaclKey != myNaclKey || existingKyberKey != myKyberKey){
// This profile contains new keys.
// Our latestChatKeysUpdateTime is now the creation time of the profile we are currently creating
// We will get the time now, which may be a second older than the broadcastTime of the profile, which doesn't matter
// We will get the time now, which may be a second older than the creationTime of the profile, which doesn't matter
currentTime := time.Now().Unix()
return currentTime, nil
}

View file

@ -83,15 +83,15 @@ func GetMyProfileIsActiveStatus(myIdentityHash [16]byte, networkType byte)(bool,
if (myIdentityType == "Mate" || myIdentityType == "Host"){
attributeExists, _, broadcastTimeString, err := getAnyAttributeFromMyBroadcastProfile("BroadcastTime")
attributeExists, _, creationTimeString, err := getAnyAttributeFromMyBroadcastProfile("CreationTime")
if (err != nil) { return false, false, err }
if (attributeExists == false) {
return false, false, errors.New("Malformed broadcast profile: Missing BroadcastTime.")
return false, false, errors.New("Malformed broadcast profile: Missing CreationTime.")
}
broadcastTimeInt64, err := helpers.ConvertBroadcastTimeStringToInt64(broadcastTimeString)
creationTimeInt64, err := helpers.ConvertCreationTimeStringToInt64(creationTimeString)
if (err != nil) {
return false, false, errors.New("Malformed broadcast profile: Contains invalid BroadcastTime: " + broadcastTimeString)
return false, false, errors.New("Malformed broadcast profile: Contains invalid CreationTime: " + creationTimeString)
}
identityExists, myIdentityIsActivated, myBalanceIsSufficient, balanceIsSufficientStartTime, _, err := myIdentityBalance.GetMyIdentityBalanceStatus(myIdentityHash, networkType)
@ -102,7 +102,7 @@ func GetMyProfileIsActiveStatus(myIdentityHash [16]byte, networkType byte)(bool,
if (myIdentityIsActivated == false || myBalanceIsSufficient == false){
return true, false, nil
}
if (balanceIsSufficientStartTime > broadcastTimeInt64){
if (balanceIsSufficientStartTime > creationTimeInt64){
// Our balance is sufficient now, but wasn't at the time of the broadcast of our current broadcast profile
// This should not happen... unless we got invalid identity deposit data from hosts either now or earlier.
// We say profile is not active
@ -135,7 +135,7 @@ func GetMyProfileIsActiveStatus(myIdentityHash [16]byte, networkType byte)(bool,
currentTime := time.Now().Unix()
timeElapsed := currentTime - broadcastTimeInt64
timeElapsed := currentTime - creationTimeInt64
if (maximumExistenceDuration <= timeElapsed){
// Profile has expired from network

View file

@ -60,7 +60,7 @@ type AttributeObject struct{
AttributeName string
// Is true if this attribute is required for all profileTypes returned by GetProfileTypes
// Example: "BroadcastTime" and "ProfileType" are required attributes for all profiles
// Example: "CreationTime" and "ProfileType" are required attributes for all profiles
// Input: Profile Version
// Output: Attribute is required, error
GetIsRequired func(int)(bool, error)
@ -444,17 +444,17 @@ func initializeProfileAttributeObjectsList(){
}
attributeObjectsList = append(attributeObjectsList, attributeObject_ProfileType)
checkValueFunction_BroadcastTime := func(profileVersion int, profileType string, input string)(bool, bool, error){
checkValueFunction_CreationTime := func(profileVersion int, profileType string, input string)(bool, bool, error){
if (profileVersion != 1){
return false, false, errors.New("Trying to check profile value for unknown profile version.")
}
if (profileType != "Mate" && profileType != "Host" && profileType != "Moderator"){
return false, false, errors.New("Invalid profile type when trying to check BroadcastTime: " + profileType)
return false, false, errors.New("Invalid profile type when trying to check CreationTime: " + profileType)
}
_, err := helpers.ConvertBroadcastTimeStringToInt64(input)
_, err := helpers.ConvertCreationTimeStringToInt64(input)
if (err != nil){
return false, false, nil
}
@ -462,17 +462,17 @@ func initializeProfileAttributeObjectsList(){
return true, true, nil
}
attributeObject_BroadcastTime := AttributeObject{
attributeObject_CreationTime := AttributeObject{
ProfileVersions: []int{1},
AttributeIdentifier: 4,
AttributeName: "BroadcastTime",
AttributeName: "CreationTime",
GetIsRequired: getIsRequired_Yes,
GetMandatoryAttributes: getMandatoryAttributes_None,
GetProfileTypes: getProfileTypes_All,
GetIsCanonical: getIsCanonical_Always,
CheckValueFunction: checkValueFunction_BroadcastTime,
CheckValueFunction: checkValueFunction_CreationTime,
}
attributeObjectsList = append(attributeObjectsList, attributeObject_BroadcastTime)
attributeObjectsList = append(attributeObjectsList, attributeObject_CreationTime)
checkValueFunction_Disabled := func(profileVersion int, profileType string, input string)(bool, bool, error){
@ -2111,7 +2111,7 @@ func initializeProfileAttributeObjectsList(){
return false, false, errors.New("Invalid profile type when trying to verify ChatKeysLatestUpdateTime: " + profileType)
}
_, err := helpers.ConvertBroadcastTimeStringToInt64(input)
_, err := helpers.ConvertCreationTimeStringToInt64(input)
if (err != nil){
return false, false, nil
}

View file

@ -152,7 +152,7 @@ func AddUserProfile(inputProfile []byte)(bool, [28]byte, error){
// -int: Profile version
// -[28]byte: Profile hash
// -[]byte: Profile bytes
// -int64: Profile broadcast time
// -int64: Profile creation time
// -map[int]messagepack.RawMessage: Raw profile map
// -error
func GetNewestUserProfile(userIdentityHash [16]byte, networkType byte)(bool, int, [28]byte, []byte, int64, map[int]messagepack.RawMessage, error){
@ -177,12 +177,12 @@ func GetNewestUserProfile(userIdentityHash [16]byte, networkType byte)(bool, int
anyProfileFound := false
//TODO: Deal with 2 profiles with identical broadcastTimes
//TODO: Deal with 2 profiles with identical creationTimes
// We must compare the profile hashes
var newestProfileHash [28]byte
newestProfileVersion := 0
newestProfileBroadcastTime := int64(0)
newestProfileCreationTime := int64(0)
newestProfileBytes := make([]byte, 0)
newestProfileRawProfileMap := make(map[int]messagepack.RawMessage)
@ -195,7 +195,7 @@ func GetNewestUserProfile(userIdentityHash [16]byte, networkType byte)(bool, int
continue
}
ableToRead, profileVersion, profileNetworkType, profileIdentityHash, profileBroadcastTime, _, rawProfileMap, err := readProfiles.ReadProfile(false, profileBytes)
ableToRead, profileVersion, profileNetworkType, profileIdentityHash, profileCreationTime, _, rawProfileMap, err := readProfiles.ReadProfile(false, profileBytes)
if (err != nil) { return false, 0, [28]byte{}, nil, 0, nil, err }
if (ableToRead == false){
return false, 0, [28]byte{}, nil, 0, nil, errors.New("Database corrupt: Contains invalid profile.")
@ -209,10 +209,10 @@ func GetNewestUserProfile(userIdentityHash [16]byte, networkType byte)(bool, int
continue
}
if (anyProfileFound == false || profileBroadcastTime > newestProfileBroadcastTime){
if (anyProfileFound == false || profileCreationTime > newestProfileCreationTime){
newestProfileVersion = profileVersion
newestProfileHash = profileHash
newestProfileBroadcastTime = profileBroadcastTime
newestProfileCreationTime = profileCreationTime
newestProfileRawProfileMap = rawProfileMap
newestProfileBytes = profileBytes
}
@ -224,7 +224,7 @@ func GetNewestUserProfile(userIdentityHash [16]byte, networkType byte)(bool, int
return false, 0, [28]byte{}, nil, 0, nil, nil
}
return true, newestProfileVersion, newestProfileHash, newestProfileBytes, newestProfileBroadcastTime, newestProfileRawProfileMap, nil
return true, newestProfileVersion, newestProfileHash, newestProfileBytes, newestProfileCreationTime, newestProfileRawProfileMap, nil
}

View file

@ -163,13 +163,13 @@ func ReadAttributeHashMetadata(attributeHash [27]byte)(string, bool, error){
// -int: Profile version
// -byte: Network type (1 == Mainnet, 2 == Testnet1)
// -[16]byte: Profile author identity hash
// -int64: Profile broadcast time (alleged, can be faked)
// -int64: Profile creation time (alleged, can be faked)
// -bool: Profile is disabled
// -map[int]messagepack.RawMessage: Raw profile map (Attribute Identifier -> Attribute messagepack bytes value)
// -error (will return err if there is a bug)
func ReadProfileAndHash(verifyProfile bool, inputProfile []byte)(bool, [28]byte, int, byte, [16]byte, int64, bool, map[int]messagepack.RawMessage, error){
ableToRead, profileVersion, networkType, profileAuthor, profileBroadcastTime, profileIsDisabled, rawProfileMap, err := ReadProfile(verifyProfile, inputProfile)
ableToRead, profileVersion, networkType, profileAuthor, profileCreationTime, profileIsDisabled, rawProfileMap, err := ReadProfile(verifyProfile, inputProfile)
if (err != nil) { return false, [28]byte{}, 0, 0, [16]byte{}, 0, false, nil, err }
if (ableToRead == false){
return false, [28]byte{}, 0, 0, [16]byte{}, 0, false, nil, nil
@ -214,7 +214,7 @@ func ReadProfileAndHash(verifyProfile bool, inputProfile []byte)(bool, [28]byte,
profileHash := [28]byte(profileHashSlice)
return true, profileHash, profileVersion, networkType, profileAuthor, profileBroadcastTime, profileIsDisabled, rawProfileMap, nil
return true, profileHash, profileVersion, networkType, profileAuthor, profileCreationTime, profileIsDisabled, rawProfileMap, nil
}
@ -225,7 +225,7 @@ func ReadProfileAndHash(verifyProfile bool, inputProfile []byte)(bool, [28]byte,
// -int: Profile version
// -byte: Network type (1 == Mainnet, 2 == Testnet1)
// -[16]byte: Profile author identity hash
// -int64: Profile broadcast time (alleged, can be faked)
// -int64: Profile creation time (alleged, can be faked)
// -bool: Profile is disabled
// -map[int]messagepack.RawMessage: Raw profile map (Attribute identifier -> Attribute raw bytes)
// -error (will return err if there is a bug)
@ -333,23 +333,23 @@ func ReadProfile(verifyProfile bool, inputProfile []byte)(bool, int, byte, [16]b
identityHash, err := identity.ConvertIdentityKeyToIdentityHash(identityKey, profileType)
if (err != nil) { return false, 0, 0, [16]byte{}, 0, false, nil, err }
broadcastTimeEncoded, exists := rawProfileMap[4]
creationTimeEncoded, exists := rawProfileMap[4]
if (exists == false) {
// Profile is malformed: missing BroadcastTime
// Profile is malformed: missing CreationTime
return false, 0, 0, [16]byte{}, 0, false, nil, nil
}
broadcastTimeInt64, err := encoding.DecodeRawMessagePackToInt64(broadcastTimeEncoded)
creationTimeInt64, err := encoding.DecodeRawMessagePackToInt64(creationTimeEncoded)
if (err != nil) {
// Profile is malformed: Contains invalid BroadcastTime
// Profile is malformed: Contains invalid CreationTime
return false, 0, 0, [16]byte{}, 0, false, nil, nil
}
if (verifyProfile == true){
isValid := helpers.VerifyBroadcastTime(broadcastTimeInt64)
isValid := helpers.VerifyCreationTime(creationTimeInt64)
if (isValid == false){
// Profile is malformed: Contains invalid BroadcastTime
// Profile is malformed: Contains invalid CreationTime
return false, 0, 0, [16]byte{}, 0, false, nil, nil
}
}
@ -387,7 +387,7 @@ func ReadProfile(verifyProfile bool, inputProfile []byte)(bool, int, byte, [16]b
return false, 0, 0, [16]byte{}, 0, false, nil, nil
}
return true, profileVersion, networkType, identityHash, broadcastTimeInt64, true, rawProfileMap, nil
return true, profileVersion, networkType, identityHash, creationTimeInt64, true, rawProfileMap, nil
}
if (verifyProfile == true){
@ -399,7 +399,7 @@ func ReadProfile(verifyProfile bool, inputProfile []byte)(bool, int, byte, [16]b
attributeName := attributeObject.AttributeName
if (attributeName == "Disabled" || attributeName == "ProfileType" || attributeName == "IdentityKey" || attributeName == "ProfileVersion" || attributeName == "NetworkType" || attributeName == "BroadcastTime"){
if (attributeName == "Disabled" || attributeName == "ProfileType" || attributeName == "IdentityKey" || attributeName == "ProfileVersion" || attributeName == "NetworkType" || attributeName == "CreationTime"){
// We already verified these attributes
continue
}
@ -476,7 +476,7 @@ func ReadProfile(verifyProfile bool, inputProfile []byte)(bool, int, byte, [16]b
}
}
return true, profileVersion, networkType, identityHash, broadcastTimeInt64, false, rawProfileMap, nil
return true, profileVersion, networkType, identityHash, creationTimeInt64, false, rawProfileMap, nil
}
// This function must be called on profiles which have already been verified
@ -520,7 +520,7 @@ func formatProfileAttributeRawMessagePackToString(attributeName string, attribut
switch attributeName{
// Some attributes are encoded in special ways in MessagePack to save space
// For example, BroadcastTime is encoded as a int64 rather than a string
// For example, CreationTime is encoded as a int64 rather than a string
case "ProfileVersion":{
@ -571,18 +571,18 @@ func formatProfileAttributeRawMessagePackToString(attributeName string, attribut
return true, identityKeyHexString, nil
}
case "BroadcastTime":{
case "CreationTime":{
broadcastTimeInt64, err := encoding.DecodeRawMessagePackToInt64(attributeValueBytes)
creationTimeInt64, err := encoding.DecodeRawMessagePackToInt64(attributeValueBytes)
if (err != nil) {
// Profile is malformed: Contains invalid BroadcastTime
// This should never happen, because this function should only be called after the profile's BroadcastTime has been verified
return false, "", errors.New("formatProfileAttributeRawMessagePackToString called with invalid BroadcastTime.")
// Profile is malformed: Contains invalid CreationTime
// This should never happen, because this function should only be called after the profile's CreationTime has been verified
return false, "", errors.New("formatProfileAttributeRawMessagePackToString called with invalid CreationTime.")
}
broadcastTimeString := helpers.ConvertInt64ToString(broadcastTimeInt64)
creationTimeString := helpers.ConvertInt64ToString(creationTimeInt64)
return true, broadcastTimeString, nil
return true, creationTimeString, nil
}
case "Disabled":{

View file

@ -97,7 +97,7 @@ func GetRetrieveAnyNewestViewableUserProfileAttributeFunction(identityHash [16]b
// -int: Profile version
// -[28]byte: Viewable Profile hash
// -[]byte: Viewable Profile bytes
// -int64: Profile broadcast time
// -int64: Profile creation time
// -map[int]messagepack.RawMessage: Viewable Profile Map
// -error
func GetNewestViewableUserProfile(identityHash [16]byte, networkType byte, allowTrustedStatus bool, allowUnknownStatus bool, alwaysAllowDisabled bool)(bool, int, [28]byte, []byte, int64, map[int]messagepack.RawMessage, error){
@ -167,7 +167,7 @@ func GetNewestViewableUserProfile(identityHash [16]byte, networkType byte, allow
newestViewableProfileIsDisabled := false
newestViewableProfileRawProfileMap := make(map[int]messagepack.RawMessage)
newestViewableProfileBytes := make([]byte, 0)
newestViewableProfileBroadcastTime := int64(0)
newestViewableProfileCreationTime := int64(0)
for _, profileHash := range profileHashesList{
@ -178,7 +178,7 @@ func GetNewestViewableUserProfile(identityHash [16]byte, networkType byte, allow
continue
}
ableToRead, profileVersion, profileNetworkType, profileIdentityHash, profileBroadcastTime, profileIsDisabled, rawProfileMap, err := readProfiles.ReadProfile(false, profileBytes)
ableToRead, profileVersion, profileNetworkType, profileIdentityHash, profileCreationTime, profileIsDisabled, rawProfileMap, err := readProfiles.ReadProfile(false, profileBytes)
if (err != nil) { return false, 0, [28]byte{}, nil, 0, nil, err }
if (ableToRead == false){
return false, 0, [28]byte{}, nil, 0, nil, errors.New("Database corrupt: Contains invalid profile.")
@ -257,11 +257,11 @@ func GetNewestViewableUserProfile(identityHash [16]byte, networkType byte, allow
if (profileIsViewable == false){
// Profile is not viewable, so we skip it
if (newestViewableProfileFound == true && newestViewableProfileIsDisabled == true && newestViewableProfileBroadcastTime < profileBroadcastTime){
if (newestViewableProfileFound == true && newestViewableProfileIsDisabled == true && newestViewableProfileCreationTime < profileCreationTime){
// This user broadcasted a non-disabled profile after broadcasting their disabled profile
// This user created a non-disabled profile after creating their disabled profile
// We reset the newestViewableProfileFound status so that we do not return the disabled profile
// We only allow the disabled profile to be returned if it is the newest profile the user has broadcasted
// We only allow the disabled profile to be returned if it is the newest profile the user has created
// Otherwise, users could see a user as being disabled, when in reality their newest profile has not been approved yet
newestViewableProfileFound = false
@ -271,14 +271,14 @@ func GetNewestViewableUserProfile(identityHash [16]byte, networkType byte, allow
}
}
if (newestViewableProfileFound == false || newestViewableProfileBroadcastTime < profileBroadcastTime){
if (newestViewableProfileFound == false || newestViewableProfileCreationTime < profileCreationTime){
newestViewableProfileFound = true
newestViewableProfileVersion = profileVersion
newestViewableProfileHash = profileHash
newestViewableProfileIsDisabled = profileIsDisabled
newestViewableProfileBytes = profileBytes
newestViewableProfileRawProfileMap = rawProfileMap
newestViewableProfileBroadcastTime = profileBroadcastTime
newestViewableProfileCreationTime = profileCreationTime
}
}
@ -287,14 +287,14 @@ func GetNewestViewableUserProfile(identityHash [16]byte, networkType byte, allow
}
if (newestViewableProfileIsDisabled == true && alwaysAllowDisabled == true){
return true, newestViewableProfileVersion, newestViewableProfileHash, newestViewableProfileBytes, newestViewableProfileBroadcastTime, newestViewableProfileRawProfileMap, nil
return true, newestViewableProfileVersion, newestViewableProfileHash, newestViewableProfileBytes, newestViewableProfileCreationTime, newestViewableProfileRawProfileMap, nil
}
if (identityIsViewableStatus == false){
return false, 0, [28]byte{}, nil, 0, nil, nil
}
return true, newestViewableProfileVersion, newestViewableProfileHash, newestViewableProfileBytes, newestViewableProfileBroadcastTime, newestViewableProfileRawProfileMap, nil
return true, newestViewableProfileVersion, newestViewableProfileHash, newestViewableProfileBytes, newestViewableProfileCreationTime, newestViewableProfileRawProfileMap, nil
}