|
|
@ -38,11 +38,14 @@ import org.session.libsession.utilities.TextSecurePreferences
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException
|
|
|
|
import java.io.IOException
|
|
|
|
import java.util.*
|
|
|
|
import java.util.*
|
|
|
|
|
|
|
|
import java.util.concurrent.atomic.AtomicReference
|
|
|
|
import kotlin.jvm.Throws
|
|
|
|
import kotlin.jvm.Throws
|
|
|
|
|
|
|
|
|
|
|
|
object ClosedGroupsProtocolV2 {
|
|
|
|
object ClosedGroupsProtocolV2 {
|
|
|
|
const val groupSizeLimit = 100
|
|
|
|
const val groupSizeLimit = 100
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private val pendingKeyPair = AtomicReference<ECKeyPair?>(null)
|
|
|
|
|
|
|
|
|
|
|
|
sealed class Error(val description: String) : Exception() {
|
|
|
|
sealed class Error(val description: String) : Exception() {
|
|
|
|
object NoThread : Error("Couldn't find a thread associated with the given group public key")
|
|
|
|
object NoThread : Error("Couldn't find a thread associated with the given group public key")
|
|
|
|
object NoKeyPair : Error("Couldn't find an encryption key pair associated with the given group public key.")
|
|
|
|
object NoKeyPair : Error("Couldn't find an encryption key pair associated with the given group public key.")
|
|
|
@ -364,7 +367,7 @@ object ClosedGroupsProtocolV2 {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Generate the new encryption key pair
|
|
|
|
// Generate the new encryption key pair
|
|
|
|
val newKeyPair = Curve.generateKeyPair()
|
|
|
|
val newKeyPair = pendingKeyPair.getAndSet(Curve.generateKeyPair()) ?: Curve.generateKeyPair()
|
|
|
|
// Distribute it
|
|
|
|
// Distribute it
|
|
|
|
val proto = SignalServiceProtos.KeyPair.newBuilder()
|
|
|
|
val proto = SignalServiceProtos.KeyPair.newBuilder()
|
|
|
|
proto.publicKey = ByteString.copyFrom(newKeyPair.publicKey.serialize().removing05PrefixIfNeeded())
|
|
|
|
proto.publicKey = ByteString.copyFrom(newKeyPair.publicKey.serialize().removing05PrefixIfNeeded())
|
|
|
|