Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

thirtyDayPeriodsSinceEpoch update #195

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ import uniffi.xmtpv3.FfiListConversationsOptions
import uniffi.xmtpv3.FfiMessage
import uniffi.xmtpv3.FfiMessageCallback
import uniffi.xmtpv3.GroupPermissions
import java.time.Instant
import java.time.temporal.ChronoUnit
import java.util.Date
import kotlin.time.Duration.Companion.nanoseconds
import kotlin.time.DurationUnit
Expand Down Expand Up @@ -306,7 +308,7 @@ data class Conversations(
fun getHmacKeys(
request: Keystore.GetConversationHmacKeysRequest? = null,
): Keystore.GetConversationHmacKeysResponse {
val thirtyDayPeriodsSinceEpoch = (Date().time / 1000 / 60 / 60 / 24 / 30).toInt()
val thirtyDayPeriodsSinceEpoch = (Instant.now().until(Instant.EPOCH, ChronoUnit.DAYS) / 30).toInt()
val hmacKeysResponse = Keystore.GetConversationHmacKeysResponse.newBuilder()

var topics = conversationsByTopic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import org.xmtp.android.library.XMTPException
import org.xmtp.android.library.codecs.ContentCodec
import org.xmtp.android.library.codecs.EncodedContent
import java.math.BigInteger
import java.time.Instant
import java.time.temporal.ChronoUnit
import java.util.Date

typealias MessageV2 = org.xmtp.proto.message.contents.MessageOuterClass.MessageV2
Expand Down Expand Up @@ -152,8 +154,7 @@ class MessageV2Builder(val senderHmac: ByteArray? = null, val shouldPush: Boolea
val signedBytes = signedContent.toByteArray()
val ciphertext = Crypto.encrypt(keyMaterial, signedBytes, additionalData = headerBytes)

val thirtyDayPeriodsSinceEpoch =
(Date().time / 1000 / 60 / 60 / 24 / 30).toInt()
val thirtyDayPeriodsSinceEpoch = (Instant.now().until(Instant.EPOCH, ChronoUnit.DAYS) / 30).toInt()
val info = "$thirtyDayPeriodsSinceEpoch-${client.address}"
val infoEncoded = info.toByteStringUtf8().toByteArray()
val senderHmacGenerated =
Expand Down
Loading