feat: one approval screen for a key ceremony (automatic ceremony, Phase 4)

The join screen carries what the round-one screen showed, the members
in particular, and says the device takes it from there. The round-one
and round-two screens, their routes and their strings are gone; the
ritual screen offers only the join, and the ladder describes each round
as something the device does.

Old request lines still read as answered: the automatic round writes
the same line a tapped one did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kgothatso NgakoandClaude Opus 5.5 committed 2026-11-19 22:55:44 +02:00
1 parent 9278ccd54e
commit d71cf0c093
12 files changed
+126 -326

No files matched your search

@@ -180,8 +180,6 @@
<string name="reindex_events">Reindex events</string>
<string name="reposted">reposted</string>
<string name="review">Review</string>
<string name="review_and_confirm">Review and confirm</string>
<string name="review_and_contribute">Review and contribute</string>
<string name="review_and_join">Review and join</string>
<string name="say_what_now">Say what now?</string>
<string name="search">Search</string>
@@ -241,7 +239,6 @@
<string name="this_group_has_not_been_asked_to_sign">This group has not been asked to sign anything yet.</string>
<string name="this_group_has_not_signed_anything_yet">This group has not signed anything yet.</string>
<string name="this_is_fixed_once_the_ceremony_runs">This is fixed once the ceremony runs. Changing it later means generating a new key.</string>
<string name="this_is_the_last_thing_the_ceremony_needs">This is the last thing the ceremony needs from you.</string>
<string name="this_will_be_shown_when_people_open_the_chat">This will be shown when people open the chat for more details.</string>
<string name="this_will_be_shown_when_people_open_your">This will be shown when people open your profile.</string>
<string name="this_will_be_the_display_name_for_this_chat">This will be the display name for this chat room.</string>
@@ -370,8 +367,6 @@
<string name="the_subgroups_key_ceremony_needs_you">The subgroup's key ceremony needs you</string>
<string name="ceremonies_need_you">%1$s key ceremonies need you</string>
<string name="join_the_ceremony_by_publishing_your_key">Join it by publishing your device's key</string>
<string name="send_your_contribution_to_the_key">Send your contribution to the key</string>
<string name="check_the_combined_result">Check the combined result and confirm it</string>
<string name="the_group_has_its_key_finish_setting_it_up">The group has its key — finish setting it up</string>
<string name="open_the_shared_key_ceremony">Open the shared key ceremony</string>
<string name="open_the_proposal">Open the proposal</string>
@@ -452,4 +447,15 @@
<string name="you_already_have_a_chat_with_s">You already have a chat with %1$s.</string>
<string name="checking_whether_s_can_receive_messages_here">Checking whether %1$s can receive messages here.</string>
<string name="s_hasn_t_set_up_encrypted_messaging_yet">%1$s hasn't set up encrypted messaging yet. Try again later, or ask them to open Giza.</string>
<string name="join_the_key_ceremony_question">Join the key ceremony?</string>
<string name="join_the_ceremony">Join the ceremony</string>
<string name="this_group">this group</string>
<string name="s_is_creating_a_shared_key_that_takes">%1$s is creating a shared key that takes %2$d of %3$d members to sign with.</string>
<string name="your_device_publishes_the_key_it_will_be">Your device publishes the key it will be identified by for the rest of the ceremony.</string>
<string name="once_everyone_has_joined_your_device_contributes_to">Once everyone has joined, your device contributes to the key, checks the combined result and confirms it. You will not be asked again.</string>
<string name="your_share_of_the_key_never_leaves_this">Your share of the key never leaves this device.</string>
<string name="the_ceremony_cannot_finish_until_every_member_has">The ceremony cannot finish until every member has taken part. If it stalls on someone, any member can abandon it from the ceremony screen.</string>
<string name="nothing_has_been_published_from_this_device_yet_declining">Nothing has been published from this device yet. Declining leaves the ceremony for the others to abandon or wait on, and you can join later from the shared key screen.</string>
<string name="once_everyone_has_joined_each_member_s_device_commits">Once everyone has joined, each member's device commits to its part of the key. Nobody is asked.</string>
<string name="each_member_s_device_checks_the_combined_result_against">Each member's device checks the combined result against what it sent, and confirms it if they match.</string>
</resources>
@@ -49,13 +49,13 @@ import mobi.giza.compose.ui.composable.widgets.NavigateBackButton
import mobi.giza.compose.ui.theme.readableContent
/**
* The frame every ChillDKG approval screen sits in: the view model, the states
* where there is nothing to approve, and the approve/decline bar.
* The frame a ChillDKG approval screen sits in: the view model, the states where
* there is nothing to approve, and the approve/decline bar.
*
* The three screens are separate because each is asking for something different
* and has its own case to make. What they share is only the chrome and, more
* importantly, the guard below — which is a correctness concern rather than a
* cosmetic one and should not be re-argued three times.
* There is one such screen now, the join (docs/automatic-key-ceremony.md); there
* were three, and the frame stays apart from it because the guard below is a
* correctness concern rather than a cosmetic one, and is the same whatever step a
* screen asks about.
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
@@ -17,17 +17,34 @@ import mobi.giza.compose.repository.DkgRepository
import com.vitorpamplona.quartz.nip01Core.core.HexKey
import mobi.giza.compose.identity.Identity
import kotlinx.coroutines.flow.StateFlow
import mobi.giza.compose.resources.join_the_ceremony
import mobi.giza.compose.resources.join_the_key_ceremony_question
import mobi.giza.compose.resources.nothing_has_been_published_from_this_device_yet_declining
import mobi.giza.compose.resources.once_everyone_has_joined_your_device_contributes_to
import mobi.giza.compose.resources.s_is_creating_a_shared_key_that_takes
import mobi.giza.compose.resources.taking_part_with_these_members
import mobi.giza.compose.resources.the_ceremony_cannot_finish_until_every_member_has
import mobi.giza.compose.resources.this_group
import mobi.giza.compose.resources.you
import mobi.giza.compose.resources.your_device_publishes_the_key_it_will_be
import mobi.giza.compose.resources.your_share_of_the_key_never_leaves_this
import mobi.giza.compose.ui.theme.spacing
/**
* Asks whether to join a shared key ceremony somebody else opened.
*
* The first and most consequential of the three approvals. Publishing a host key
* is what puts this member in the participant set, and the set is what `n` is
* counted over — so a member who joins and then stops answering does not merely
* fail to help, they hold the ceremony open for everybody else. Saying that
* The one approval a ceremony asks for (docs/automatic-key-ceremony.md). Publishing
* a host key is what puts this member in the participant set, and the set is what
* `n` is counted over — so a member who joins and then stops answering does not
* merely fail to help, they hold the ceremony open for everybody else. Saying that
* plainly here is the point of the screen.
*
* Everything after it runs without asking: the device contributes once everyone
* has joined, checks the combined result itself and confirms it. So this screen
* carries what the round-one screen used to, the members in particular. Who the
* key is being made with was settled by the proposal before anyone joined, so it
* was never something a later screen knew and this one could not.
*
* Until this is approved nothing has left the device, which is worth stating
* outright: the member is being asked to start, not to continue.
*/
@@ -43,8 +60,8 @@ fun DkgJoinApprovalScreen(
) {
DkgApprovalScaffold(
step = DkgApprovalStep.HOST_KEY,
title = "Join the key ceremony?",
approveLabel = "Join the ceremony",
title = stringResource(Res.string.join_the_key_ceremony_question),
approveLabel = stringResource(Res.string.join_the_ceremony),
activeUserPublicKey = activeUserPublicKey,
chatRoomId = chatRoomId,
dkgSessionId = dkgSessionId,
@@ -55,11 +72,15 @@ fun DkgJoinApprovalScreen(
canApprove = { state -> !state.session.isGuardedSubgroup },
) { state ->
val session = state.session
val group = state.localChatRoom.chatRoom.subject ?: "this group"
val group = state.localChatRoom.chatRoom.subject ?: stringResource(Res.string.this_group)
Text(
text = "$group is creating a shared key that takes " +
"${session.threshold} of ${state.participantCount} members to sign with.",
text = stringResource(
Res.string.s_is_creating_a_shared_key_that_takes,
group,
session.threshold,
state.participantCount
),
style = MaterialTheme.typography.bodyLarge
)
@@ -78,17 +99,41 @@ fun DkgJoinApprovalScreen(
modifier = Modifier.fillMaxWidth(),
verticalArrangement = Arrangement.spacedBy(MaterialTheme.spacing.itemGap)
) {
DkgApprovalPoint("Your device publishes the key it will be identified by for the rest of the ceremony.")
DkgApprovalPoint("You will be asked twice more before anything of your key material goes out.")
DkgApprovalPoint(
"The ceremony cannot finish until every member has taken part, so joining and " +
"then stopping leaves the group waiting."
)
DkgApprovalPoint(stringResource(Res.string.your_device_publishes_the_key_it_will_be))
DkgApprovalPoint(stringResource(Res.string.once_everyone_has_joined_your_device_contributes_to))
DkgApprovalPoint(stringResource(Res.string.your_share_of_the_key_never_leaves_this))
DkgApprovalPoint(stringResource(Res.string.the_ceremony_cannot_finish_until_every_member_has))
}
// The members, named: this is the last moment "who am I making a key
// with" is a question the member can act on, and from here it is the
// only one they are asked.
Text(
text = stringResource(Res.string.taking_part_with_these_members),
style = MaterialTheme.typography.titleSmall
)
Column(
modifier = Modifier.fillMaxWidth(),
verticalArrangement = Arrangement.spacedBy(MaterialTheme.spacing.relatedGap)
) {
state.ritualMembers.forEach { member ->
val key = member.participant.participantPublicKey
Text(
text = if (key == activeUserPublicKey) {
stringResource(Res.string.you)
} else {
member.profile?.humanReadableNameOrPubkey() ?: key.take(12)
},
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
}
Text(
text = "Nothing has been published from this device yet. Declining leaves the ceremony " +
"for the others to abandon or wait on, and you can join later from the shared key screen.",
text = stringResource(Res.string.nothing_has_been_published_from_this_device_yet_declining),
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
@@ -76,8 +76,6 @@ import mobi.giza.compose.database.model.types.DkgApprovalStep
import mobi.giza.compose.ui.composable.navigation.routes.DkgJoinApprovalRoute
import mobi.giza.compose.ui.composable.navigation.routes.SelectSubgroupAdminsRoute
import mobi.giza.compose.ui.composable.navigation.routes.CreateSharedKeyRoute
import mobi.giza.compose.ui.composable.navigation.routes.DkgRound1ApprovalRoute
import mobi.giza.compose.ui.composable.navigation.routes.DkgRound2ApprovalRoute
import mobi.giza.compose.ui.composable.navigation.routes.Route
import mobi.giza.compose.ui.view.model.DkgRitualViewModel
import mobi.giza.compose.ui.view.state.DkgRitualUIState
@@ -101,9 +99,9 @@ import mobi.giza.compose.resources.the_parent_group_has_certified_this_subgroup
import mobi.giza.compose.resources.key
import mobi.giza.compose.resources.members
import mobi.giza.compose.resources.nothing_was_created_and_no_key_exists_it_is
import mobi.giza.compose.resources.review_and_confirm
import mobi.giza.compose.resources.review_and_contribute
import mobi.giza.compose.resources.review_and_join
import mobi.giza.compose.resources.once_everyone_has_joined_each_member_s_device_commits
import mobi.giza.compose.resources.each_member_s_device_checks_the_combined_result_against
import mobi.giza.compose.resources.shared_key
import mobi.giza.compose.resources.the_ceremony_was_abandoned
import mobi.giza.compose.resources.the_group_has_a_shared_key
@@ -206,40 +204,23 @@ fun DkgRitualScreen(
)
},
bottomBar = {
val pending = dkgRitualUIState.pendingApproval
// The ceremony is stopped, waiting on this member, and will stay
// stopped until they act -- so this outranks everything else the
// bar could offer.
if (pending != null) {
// bar could offer. Joining is the only thing a ceremony asks, so
// it is the only thing this can be (docs/automatic-key-ceremony.md).
if (dkgRitualUIState.pendingApproval == DkgApprovalStep.HOST_KEY) {
BottomAppBar(
floatingActionButton = {
ExtendedFab(
label = when (pending) {
DkgApprovalStep.HOST_KEY -> stringResource(Res.string.review_and_join)
DkgApprovalStep.ROUND_1 -> stringResource(Res.string.review_and_contribute)
DkgApprovalStep.ROUND_2 -> stringResource(Res.string.review_and_confirm)
},
label = stringResource(Res.string.review_and_join),
icon = { Icon(Icons.Default.Key, contentDescription = Decorative) },
onClick = {
onNavigateToRoute(
when (pending) {
DkgApprovalStep.HOST_KEY -> DkgJoinApprovalRoute(
activeUserPublicKey = activeUserPublicKey,
chatRoomId = chatRoomId,
dkgSessionId = session.id
)
DkgApprovalStep.ROUND_1 -> DkgRound1ApprovalRoute(
activeUserPublicKey = activeUserPublicKey,
chatRoomId = chatRoomId,
dkgSessionId = session.id
)
DkgApprovalStep.ROUND_2 -> DkgRound2ApprovalRoute(
activeUserPublicKey = activeUserPublicKey,
chatRoomId = chatRoomId,
dkgSessionId = session.id
)
}
DkgJoinApprovalRoute(
activeUserPublicKey = activeUserPublicKey,
chatRoomId = chatRoomId,
dkgSessionId = session.id
)
)
}
)
@@ -471,9 +452,12 @@ private fun RitualProgress(
isDone = stage != DkgRitualStage.COLLECTING_HOST_KEYS
)
// Said as something each device does rather than something each member is
// waiting to be asked: nobody is asked after joining, and a rung that read as a
// task would send the reader looking for a button that is not there.
RitualStep(
title = "Round one",
detail = "Each member commits to their part of the key.",
detail = stringResource(Res.string.once_everyone_has_joined_each_member_s_device_commits),
count = round1Count,
total = participantCount,
isDone = stage == DkgRitualStage.COLLECTING_ROUND_2 || stage == DkgRitualStage.COMPLETE
@@ -481,7 +465,7 @@ private fun RitualProgress(
RitualStep(
title = "Round two",
detail = "Each member confirms everyone else's part.",
detail = stringResource(Res.string.each_member_s_device_checks_the_combined_result_against),
count = round2Count,
total = participantCount,
isDone = stage == DkgRitualStage.COMPLETE
@@ -1,101 +0,0 @@
package mobi.giza.compose.ui.composable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import mobi.giza.compose.database.model.types.DkgApprovalStep
import mobi.giza.compose.repository.ChatRepository
import mobi.giza.compose.repository.DkgRepository
import com.vitorpamplona.quartz.nip01Core.core.HexKey
import mobi.giza.compose.identity.Identity
import kotlinx.coroutines.flow.StateFlow
import mobi.giza.compose.ui.theme.spacing
import mobi.giza.compose.resources.Res
import org.jetbrains.compose.resources.stringResource
import mobi.giza.compose.resources.taking_part_with_these_members
import mobi.giza.compose.resources.you
/**
* Asks whether to contribute to the key itself.
*
* The step where the member's own secret material first shapes the outcome.
* Joining settled who is in the ceremony; this settles what the key is, and once
* it is out there is no version of the key that does not include it.
*
* The participant set is worth showing here rather than a count, because this is
* the last moment at which "who am I making a key with" is still a question the
* member can act on — everyone is now known, and the ceremony has not yet
* committed to anything.
*/
@Composable
fun DkgRound1ApprovalScreen(
activeUserPublicKey: HexKey,
chatRoomId: String,
dkgSessionId: String,
activeIdentityStateFlow: StateFlow<Identity?>,
chatRepository: ChatRepository,
dkgRepository: DkgRepository,
onDone: () -> Unit,
) {
DkgApprovalScaffold(
step = DkgApprovalStep.ROUND_1,
title = "Contribute to the shared key?",
approveLabel = "Contribute",
activeUserPublicKey = activeUserPublicKey,
chatRoomId = chatRoomId,
dkgSessionId = dkgSessionId,
activeIdentityStateFlow = activeIdentityStateFlow,
chatRepository = chatRepository,
dkgRepository = dkgRepository,
onDone = onDone
) { state ->
val session = state.session
Text(
text = "Everyone has joined. ${state.participantCount} members are making a key that " +
"takes ${session.threshold} of them to sign with.",
style = MaterialTheme.typography.bodyLarge
)
Column(
modifier = Modifier.fillMaxWidth(),
verticalArrangement = Arrangement.spacedBy(MaterialTheme.spacing.itemGap)
) {
DkgApprovalPoint(
"Your device publishes its contribution to the key. Every member's is mixed in, " +
"so no single device ever holds the whole key."
)
DkgApprovalPoint("Your share of it never leaves this device.")
DkgApprovalPoint("You will be asked once more, to check the combined result before it is final.")
}
Text(
text = stringResource(Res.string.taking_part_with_these_members),
style = MaterialTheme.typography.titleSmall
)
Column(
modifier = Modifier.fillMaxWidth(),
verticalArrangement = Arrangement.spacedBy(MaterialTheme.spacing.relatedGap)
) {
state.ritualMembers.forEach { member ->
val key = member.participant.participantPublicKey
Text(
text = if (key == activeUserPublicKey) {
stringResource(Res.string.you)
} else {
member.profile?.humanReadableNameOrPubkey() ?: key.take(12)
},
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
}
}
}
@@ -1,87 +0,0 @@
package mobi.giza.compose.ui.composable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import mobi.giza.compose.database.model.types.DkgApprovalStep
import mobi.giza.compose.repository.ChatRepository
import mobi.giza.compose.repository.DkgRepository
import com.vitorpamplona.quartz.nip01Core.core.HexKey
import mobi.giza.compose.identity.Identity
import kotlinx.coroutines.flow.StateFlow
import mobi.giza.compose.ui.theme.spacing
import mobi.giza.compose.resources.Res
import org.jetbrains.compose.resources.stringResource
import mobi.giza.compose.resources.this_is_the_last_thing_the_ceremony_needs
/**
* Asks whether to confirm the combined result.
*
* The one approval of the three that is a check rather than a decision. Every
* member signs to say the coordinator's combined result matches what they
* themselves sent, and it is that agreement — not the coordinator's word — which
* makes the key final. A coordinator trying to substitute a key the members never
* contributed to is caught precisely here.
*
* The check itself is done by the device, which has the member's own round-1
* message to compare against and would refuse a mismatch outright. So this screen
* is not asking the member to verify anything by eye; it is asking whether to put
* their name to a result their device has already found consistent.
*/
@Composable
fun DkgRound2ApprovalScreen(
activeUserPublicKey: HexKey,
chatRoomId: String,
dkgSessionId: String,
activeIdentityStateFlow: StateFlow<Identity?>,
chatRepository: ChatRepository,
dkgRepository: DkgRepository,
onDone: () -> Unit,
) {
DkgApprovalScaffold(
step = DkgApprovalStep.ROUND_2,
title = "Confirm the shared key?",
approveLabel = "Confirm",
activeUserPublicKey = activeUserPublicKey,
chatRoomId = chatRoomId,
dkgSessionId = dkgSessionId,
activeIdentityStateFlow = activeIdentityStateFlow,
chatRepository = chatRepository,
dkgRepository = dkgRepository,
onDone = onDone
) { state ->
val session = state.session
Text(
text = "Everyone's contributions have been combined into a " +
"${session.threshold}-of-${state.participantCount} key.",
style = MaterialTheme.typography.bodyLarge
)
Column(
modifier = Modifier.fillMaxWidth(),
verticalArrangement = Arrangement.spacedBy(MaterialTheme.spacing.itemGap)
) {
DkgApprovalPoint(
"Your device has checked the combined result against what it sent, and they match."
)
DkgApprovalPoint(
"Confirming signs to say so. The key becomes final once every member has confirmed."
)
DkgApprovalPoint(
"It is this step that stops anyone substituting a key the group did not make together."
)
}
Text(
text = stringResource(Res.string.this_is_the_last_thing_the_ceremony_needs),
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
}
@@ -39,8 +39,6 @@ import mobi.giza.compose.ui.composable.CreateProfileScreen
import mobi.giza.compose.ui.composable.DkgJoinApprovalScreen
import mobi.giza.compose.ui.composable.CreateSharedKeyScreen
import mobi.giza.compose.ui.composable.DkgRitualScreen
import mobi.giza.compose.ui.composable.DkgRound1ApprovalScreen
import mobi.giza.compose.ui.composable.DkgRound2ApprovalScreen
import mobi.giza.compose.ui.composable.HomeScreen
import mobi.giza.compose.ui.composable.ImplementationPendingScreen
import mobi.giza.compose.ui.composable.KeyPackageManagementScreen
@@ -76,8 +74,6 @@ import mobi.giza.compose.ui.composable.navigation.routes.CreateProfileRoute
import mobi.giza.compose.ui.composable.navigation.routes.DkgJoinApprovalRoute
import mobi.giza.compose.ui.composable.navigation.routes.CreateSharedKeyRoute
import mobi.giza.compose.ui.composable.navigation.routes.DkgRitualRoute
import mobi.giza.compose.ui.composable.navigation.routes.DkgRound1ApprovalRoute
import mobi.giza.compose.ui.composable.navigation.routes.DkgRound2ApprovalRoute
import mobi.giza.compose.ui.composable.navigation.routes.HomeRoute
import mobi.giza.compose.ui.composable.navigation.routes.ImplementationPendingRoute
import mobi.giza.compose.ui.composable.navigation.routes.KeyPackageManagementRoute
@@ -631,32 +627,6 @@ fun GizaNavHost(
onDone = { navController.popBackStack() }
)
}
composable<DkgRound1ApprovalRoute> { backStackEntry ->
val route = backStackEntry.toRoute<DkgRound1ApprovalRoute>()
DkgRound1ApprovalScreen(
activeUserPublicKey = route.activeUserPublicKey,
chatRoomId = route.chatRoomId,
dkgSessionId = route.dkgSessionId,
activeIdentityStateFlow = sovereignWalletViewModel.activeIdentity,
chatRepository = databaseChatRepository,
dkgRepository = databaseDkgRepository,
onDone = { navController.popBackStack() }
)
}
composable<DkgRound2ApprovalRoute> { backStackEntry ->
val route = backStackEntry.toRoute<DkgRound2ApprovalRoute>()
DkgRound2ApprovalScreen(
activeUserPublicKey = route.activeUserPublicKey,
chatRoomId = route.chatRoomId,
dkgSessionId = route.dkgSessionId,
activeIdentityStateFlow = sovereignWalletViewModel.activeIdentity,
chatRepository = databaseChatRepository,
dkgRepository = databaseDkgRepository,
onDone = { navController.popBackStack() }
)
}
composable<SelectChatRoomTypeRoute> { backStackEntry ->
val route = backStackEntry.toRoute<SelectChatRoomTypeRoute>()
@@ -1,19 +0,0 @@
package mobi.giza.compose.ui.composable.navigation.routes
import kotlinx.serialization.Serializable
/**
* Contributing this device's share to a shared key.
*
* Its own route rather than a step on a shared one: each approval is a separate
* decision with its own case to make, and being separately addressable is what
* lets the chat line and the ritual screen send a member straight to the one the
* ceremony is actually waiting on.
*/
@Serializable
data class DkgRound1ApprovalRoute(
val activeUserPublicKey: String,
val chatRoomId: String,
/** The ceremony being approved. Required, for the reason `DkgRitualRoute`'s is. */
val dkgSessionId: String
): Route()
@@ -1,19 +0,0 @@
package mobi.giza.compose.ui.composable.navigation.routes
import kotlinx.serialization.Serializable
/**
* Confirming the combined result of a shared-key ceremony.
*
* Its own route rather than a step on a shared one: each approval is a separate
* decision with its own case to make, and being separately addressable is what
* lets the chat line and the ritual screen send a member straight to the one the
* ceremony is actually waiting on.
*/
@Serializable
data class DkgRound2ApprovalRoute(
val activeUserPublicKey: String,
val chatRoomId: String,
/** The ceremony being approved. Required, for the reason `DkgRitualRoute`'s is. */
val dkgSessionId: String
): Route()
@@ -20,8 +20,6 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.AccountTree
import mobi.giza.compose.resources.open
import mobi.giza.compose.resources.the_group_has_its_key_finish_setting_it_up
import mobi.giza.compose.resources.check_the_combined_result
import mobi.giza.compose.resources.send_your_contribution_to_the_key
import mobi.giza.compose.resources.join_the_ceremony_by_publishing_your_key
import mobi.giza.compose.resources.the_subgroups_key_ceremony_needs_you
import mobi.giza.compose.resources.the_key_ceremony_needs_you
@@ -617,17 +615,18 @@ private fun CeremoniesAwaitingYouNotice(
else -> stringResource(Res.string.the_key_ceremony_needs_you)
}
// What it wants, in the words the approval screens use for the same step, so
// What it wants, in the words the approval screen uses for the same step, so
// a member is not asked twice in two vocabularies. The gate comes first: an
// approval is owed by this member and cannot be done by anybody else, while
// finishing the setup is work the coordinator can come back to. The Lightning
// wallet's gates are buttons on its ceremony screen, and say what those say.
// finishing the setup is work the coordinator can come back to.
//
// Joining is the only gate a ceremony has (docs/automatic-key-ceremony.md).
// The two rounds after it are never asked for, so they say nothing here.
val detail = single?.let {
when (val ask = it.ask) {
is ChatMessageListViewModel.Ask.SharedKeyStep -> when (ask.step) {
DkgApprovalStep.HOST_KEY -> stringResource(Res.string.join_the_ceremony_by_publishing_your_key)
DkgApprovalStep.ROUND_1 -> stringResource(Res.string.send_your_contribution_to_the_key)
DkgApprovalStep.ROUND_2 -> stringResource(Res.string.check_the_combined_result)
DkgApprovalStep.ROUND_1, DkgApprovalStep.ROUND_2 -> null
}
is ChatMessageListViewModel.Ask.RoomCreation -> stringResource(Res.string.the_group_has_its_key_finish_setting_it_up)
}
@@ -208,4 +208,23 @@ class TranscriptRequestStateTest {
assertEquals(setOf(hostKey.id), ChatMessage.answeredRequests(transcript))
}
/**
* A round request written by a build that still asked reads as answered once
* the round goes out on its own. The line the round writes is the same one a
* tapped approval wrote, so nothing told the transcript the gate had gone.
*/
@Test
fun `a round request from an older build is answered by the automatic round`() {
val roundOne = line(ChatMessage.TYPE_DKG_APPROVAL_NEEDED_ROUND_1, at = 10)
val roundTwo = line(ChatMessage.TYPE_DKG_APPROVAL_NEEDED_ROUND_2, at = 12)
val transcript = listOf(
roundOne,
line(ChatMessage.TYPE_DKG_ROUND_1, at = 11),
roundTwo,
line(ChatMessage.TYPE_DKG_ROUND_2, at = 13),
)
assertEquals(setOf(roundOne.id, roundTwo.id), ChatMessage.answeredRequests(transcript))
}
}
@@ -140,10 +140,13 @@ class DkgRitualViewModelJvmTest {
signingSessions
// A deliberately slow answer, so a read-modify-write around it would have
// the widest possible window to lose somebody else's write in.
// the widest possible window to lose somebody else's write in. Shaped like
// the real one: joining is the only thing asked, and it is asked until this
// member's host key is out.
override suspend fun pendingApproval(session: DkgSession): DkgApprovalStep? {
delay(5)
return if (messages.value.size >= session.participantCount) DkgApprovalStep.ROUND_1 else null
val joined = messages.value.any { it.participantPublicKey == session.userPublicKey }
return if (joined) null else DkgApprovalStep.HOST_KEY
}
override suspend fun approve(
@@ -264,7 +267,7 @@ class DkgRitualViewModelJvmTest {
val settled = viewModel.awaitLoaded {
it.session?.stage == DkgRitualStage.COLLECTING_ROUND_1 &&
it.hostKeyParticipants.size == 3 &&
it.pendingApproval == DkgApprovalStep.ROUND_1
it.pendingApproval == null
}
assertEquals(sessionId, settled.session?.id)
assertEquals(setOf(ada, bob, "c".repeat(64)), settled.hostKeyParticipants)