frost: harden recovery and refresh verification
This commit is contained in:
1 parent
c272492b59
commit
64fc85cc98
12 files changed
+444
-29
No files matched your search
@@ -456,6 +456,9 @@
|
||||
<string name="refresh_shares_description">Re-issue every member's share without changing the group's key or this room.</string>
|
||||
<string name="current_share_epoch">Current share epoch: %1$s</string>
|
||||
<string name="next_share_epoch">Next share epoch: %1$s</string>
|
||||
<string name="active_share_epoch">Active share epoch: %1$s</string>
|
||||
<string name="refresh_unchanged_group_key">Unchanged group key: %1$s</string>
|
||||
<string name="refresh_member_roster">Share holders: %1$s</string>
|
||||
<string name="refresh_backup_warning">Refreshing does not erase old backups. If a threshold of old shares is compromised, make a new group key instead.</string>
|
||||
<string name="refresh_all_members_required">Every share holder must take part before the new shares can activate.</string>
|
||||
<string name="commitments_received">Commitments: %1$s of %2$s</string>
|
||||
|
||||
@@ -71,6 +71,12 @@ interface ChatMessageDao {
|
||||
unresolvedTypes: Collection<String>
|
||||
): List<HexKey>
|
||||
|
||||
@Query(
|
||||
"SELECT * FROM ChatMessage WHERE reEnrollmentSessionId = :sessionId " +
|
||||
"AND messageType = :messageType AND senderPublicKey = :actor LIMIT 1"
|
||||
)
|
||||
suspend fun findReEnrollmentNotice(sessionId: String, messageType: String, actor: HexKey): ChatMessage?
|
||||
|
||||
@Upsert
|
||||
suspend fun upsert(chatMessage: mobi.giza.compose.database.model.ChatMessage): Long
|
||||
}
|
||||
@@ -334,6 +334,22 @@ data class ChatMessage(
|
||||
val FROST_SETTLEMENTS = setOf(TYPE_FROST_COMPLETE, TYPE_FROST_FAILED)
|
||||
|
||||
/** Every signing line, for rendering them as system lines rather than bubbles. */
|
||||
const val TYPE_REENROLLMENT_STARTED = "reEnrollmentStarted"
|
||||
const val TYPE_REENROLLMENT_READY = "reEnrollmentReady"
|
||||
const val TYPE_REENROLLMENT_ACTIVATING = "reEnrollmentActivating"
|
||||
const val TYPE_REENROLLMENT_COMPLETE = "reEnrollmentComplete"
|
||||
const val TYPE_REENROLLMENT_FAILED = "reEnrollmentFailed"
|
||||
|
||||
val REENROLLMENT_TYPES = setOf(
|
||||
TYPE_REENROLLMENT_STARTED,
|
||||
TYPE_REENROLLMENT_READY,
|
||||
TYPE_REENROLLMENT_ACTIVATING,
|
||||
TYPE_REENROLLMENT_COMPLETE,
|
||||
TYPE_REENROLLMENT_FAILED,
|
||||
)
|
||||
|
||||
val REENROLLMENT_AUTHORED_TYPES = setOf(TYPE_REENROLLMENT_STARTED, TYPE_REENROLLMENT_FAILED)
|
||||
|
||||
val FROST_TYPES = setOf(
|
||||
TYPE_FROST_STARTED,
|
||||
TYPE_FROST_NONCE,
|
||||
|
||||
+75
-6
@@ -20,11 +20,13 @@ import fr.acinq.bitcoin.crypto.frost.FrostRefresh
|
||||
import fr.acinq.bitcoin.crypto.frost.RefreshCandidate
|
||||
import fr.acinq.bitcoin.crypto.frost.RefreshDealerFault
|
||||
import fr.acinq.bitcoin.utils.Either
|
||||
import fr.acinq.secp256k1.Secp256k1
|
||||
import kotlin.time.Clock
|
||||
import kotlin.time.Duration.Companion.minutes
|
||||
import kotlin.time.Instant
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import mobi.giza.compose.database.GizaDatabase
|
||||
import mobi.giza.compose.database.model.ChatMessage
|
||||
import mobi.giza.compose.database.model.DkgSession
|
||||
import mobi.giza.compose.database.model.FrostReEnrollmentMessage
|
||||
import mobi.giza.compose.database.model.FrostReEnrollmentSession
|
||||
@@ -80,7 +82,9 @@ object FrostReEnrollmentManager {
|
||||
require(roomMembers.containsAll(participants)) { "Every share holder must be in the Marmot room" }
|
||||
require(participants.size == key.participantCount) { "The share-holder roster does not match the ceremony" }
|
||||
require(FrostSignerOrder.signerIdOf(database, key, userPublicKey) != null) { "This device is not a share holder" }
|
||||
require(key.publicShareList()?.size == key.participantCount) { "A complete public-share table is required" }
|
||||
require(hasValidPublicShares(key)) {
|
||||
"A validated current public-share table is required; repair it with current members before refreshing"
|
||||
}
|
||||
require(
|
||||
database.frostSigningSessionDao().getSessionsForChatRoom(localChatRoom.chatRoom.id)
|
||||
.none { it.dkgSessionId == key.id && it.stage != FrostSigningStage.COMPLETE && it.stage != FrostSigningStage.FAILED }
|
||||
@@ -105,6 +109,7 @@ object FrostReEnrollmentManager {
|
||||
joinApprovedAt = Clock.System.now(),
|
||||
)
|
||||
database.frostReEnrollmentDao().upsert(session)
|
||||
announceStarted(database, session)
|
||||
check(
|
||||
broadcast(
|
||||
database, localChatRoom, session, ReEnrollmentEvents.PROPOSAL, key.thresholdPublicKey.orEmpty(),
|
||||
@@ -246,7 +251,9 @@ object FrostReEnrollmentManager {
|
||||
sessionId: String,
|
||||
) = database.frostReEnrollmentDao().getSessionById(sessionId)?.let { session ->
|
||||
if (session.stage != ReEnrollmentStage.ACTIVATING) return@let null
|
||||
FrostSigningManager.proposeRefreshActivation(database, localChatRoom, userPublicKey, session)
|
||||
val activation = FrostSigningManager.proposeRefreshActivation(database, localChatRoom, userPublicKey, session)
|
||||
noteActivation(database, session)
|
||||
activation
|
||||
}
|
||||
|
||||
/** Validate and atomically apply a signed key-epoch state. */
|
||||
@@ -264,7 +271,9 @@ object FrostReEnrollmentManager {
|
||||
val candidateShares = session.candidatePublicShareList() ?: return null
|
||||
val candidateSecret = session.candidateSecretShare ?: return null
|
||||
val currentState = GroupKeyStateManager.keyStateFor(database, chatRoomId) ?: return null
|
||||
if (session.stage != ReEnrollmentStage.ACTIVATING) return null
|
||||
if (session.stage != ReEnrollmentStage.ACTIVATING &&
|
||||
!(session.stage == ReEnrollmentStage.FAILED && session.readyAt != null)
|
||||
) return null
|
||||
if (key.shareEpoch != session.currentShareEpoch || currentState.shareEpoch != session.currentShareEpoch) return null
|
||||
if (state.shareEpoch != session.nextShareEpoch || state.refreshSessionId != session.id) return null
|
||||
if (state.refreshTranscriptHash != session.transcriptHash) return null
|
||||
@@ -298,6 +307,10 @@ object FrostReEnrollmentManager {
|
||||
)
|
||||
database.frostReEnrollmentDao().scrubMessagesByKind(session.id, ReEnrollmentEvents.PRIVATE_EVALUATION)
|
||||
database.marmotInnerEventDao().scrubContentByChatRoomAndKind(chatRoomId, ReEnrollmentEvents.PRIVATE_EVALUATION)
|
||||
announce(
|
||||
database, session, ChatMessage.TYPE_REENROLLMENT_COMPLETE,
|
||||
"Share epoch ${session.nextShareEpoch} is active. The previous local share material was retired.",
|
||||
)
|
||||
}
|
||||
}
|
||||
return state
|
||||
@@ -336,7 +349,7 @@ object FrostReEnrollmentManager {
|
||||
if (nextEpoch != key.shareEpoch + 1 || threshold != key.threshold || members.size != key.participantCount) return null
|
||||
if (!thresholdPublicKey.equals(key.thresholdPublicKey, ignoreCase = true)) return null
|
||||
if (state.dkgSessionId != key.id || state.shareEpoch != key.shareEpoch || previousState.id != previousStateId) return null
|
||||
if (key.publicShareList()?.size != key.participantCount) return null
|
||||
if (!hasValidPublicShares(key)) return null
|
||||
|
||||
val session = FrostReEnrollmentSession(
|
||||
id = sessionId,
|
||||
@@ -353,6 +366,7 @@ object FrostReEnrollmentManager {
|
||||
dealerRandom = RandomInstance.bytes(32).toHex(),
|
||||
)
|
||||
database.frostReEnrollmentDao().upsert(session)
|
||||
announceStarted(database, session)
|
||||
replayStoredMessages(database, localChatRoom, session)
|
||||
return session
|
||||
}
|
||||
@@ -508,7 +522,13 @@ object FrostReEnrollmentManager {
|
||||
|
||||
val ready = database.frostReEnrollmentDao().getMessagesByKind(session.id, ReEnrollmentEvents.READY)
|
||||
if (ready.size < session.participantCount || ready.any { it.payload != session.transcriptHash }) return
|
||||
moveTo(database, session, ReEnrollmentStage.ACTIVATING)
|
||||
val activating = moveTo(database, session, ReEnrollmentStage.ACTIVATING)
|
||||
if (session.stage != ReEnrollmentStage.ACTIVATING && activating.stage == ReEnrollmentStage.ACTIVATING) {
|
||||
announce(
|
||||
database, session, ChatMessage.TYPE_REENROLLMENT_READY,
|
||||
"All ${session.participantCount} members verified the same candidate for share epoch ${session.nextShareEpoch}.",
|
||||
)
|
||||
}
|
||||
} catch (e: CancellationException) {
|
||||
throw e
|
||||
} catch (e: Throwable) {
|
||||
@@ -521,6 +541,39 @@ object FrostReEnrollmentManager {
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun announceStarted(database: GizaDatabase, session: FrostReEnrollmentSession) = announce(
|
||||
database, session, ChatMessage.TYPE_REENROLLMENT_STARTED,
|
||||
"proposed refreshing every member's signing share without changing the group key.",
|
||||
)
|
||||
|
||||
suspend fun noteActivation(database: GizaDatabase, session: FrostReEnrollmentSession) = announce(
|
||||
database, session, ChatMessage.TYPE_REENROLLMENT_ACTIVATING,
|
||||
"A quorum was asked to sign share epoch ${session.nextShareEpoch} into use.",
|
||||
)
|
||||
|
||||
private suspend fun announce(
|
||||
database: GizaDatabase,
|
||||
session: FrostReEnrollmentSession,
|
||||
messageType: String,
|
||||
content: String,
|
||||
actor: HexKey = session.coordinatorPublicKey,
|
||||
) {
|
||||
if (database.chatMessageDao().findReEnrollmentNotice(session.id, messageType, actor) != null) return
|
||||
database.chatMessageDao().upsert(
|
||||
ChatMessage(
|
||||
senderPublicKey = actor,
|
||||
isUserMessage = actor == session.userPublicKey,
|
||||
giftWrapPayloadId = null,
|
||||
marmotGroupEventId = null,
|
||||
marmotInnerEventId = null,
|
||||
chatRoomId = session.chatRoomId,
|
||||
content = content,
|
||||
messageType = messageType,
|
||||
reEnrollmentSessionId = session.id,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private suspend fun activeKey(database: GizaDatabase, session: FrostReEnrollmentSession): DkgSession =
|
||||
database.dkgSessionDao().getSessionById(session.dkgSessionId)?.takeIf {
|
||||
it.stage == DkgRitualStage.COMPLETE && it.shareEpoch == session.currentShareEpoch
|
||||
@@ -571,6 +624,17 @@ object FrostReEnrollmentManager {
|
||||
return Crypto.sha256(input.encodeToByteArray()).toHex()
|
||||
}
|
||||
|
||||
fun hasValidPublicShares(key: DkgSession): Boolean {
|
||||
val shares = key.publicShareList() ?: return false
|
||||
if (shares.size != key.participantCount) return false
|
||||
val thresholdPublicKey = key.thresholdPublicKey?.hexToByteArray() ?: return false
|
||||
return runCatching {
|
||||
Secp256k1.frostThresholdInfoValidate(
|
||||
thresholdPublicKey, shares.map { it.value.toByteArray() }.toTypedArray(), key.threshold,
|
||||
)
|
||||
}.getOrDefault(false)
|
||||
}
|
||||
|
||||
/** Hash a public-share table. This contains no secret material. */
|
||||
fun publicSharesHash(publicShares: List<PublicKey>): String =
|
||||
Crypto.sha256((PUBLIC_SHARES_TAG + publicShares.joinToString(",") { it.value.toHex() }).encodeToByteArray()).toHex()
|
||||
@@ -655,10 +719,15 @@ object FrostReEnrollmentManager {
|
||||
stage = ReEnrollmentStage.FAILED,
|
||||
failureReason = reason,
|
||||
dealerRandom = null,
|
||||
candidateSecretShare = null,
|
||||
candidateSecretShare = if (current.readyAt == null) null else current.candidateSecretShare,
|
||||
)
|
||||
}
|
||||
database.frostReEnrollmentDao().scrubMessagesByKind(session.id, ReEnrollmentEvents.PRIVATE_EVALUATION)
|
||||
announce(
|
||||
database, current, ChatMessage.TYPE_REENROLLMENT_FAILED,
|
||||
"abandoned the share refresh. The previous group key and active share epoch are unchanged.",
|
||||
actor = current.userPublicKey,
|
||||
)
|
||||
broadcast(database, localChatRoom, current, ReEnrollmentEvents.FAILURE, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -634,7 +634,8 @@ object FrostSigningManager {
|
||||
if (innerEvent.kind != FrostSigningEvents.PROPOSAL_V2 ||
|
||||
refresh.dkgSessionId != key.id || refresh.nextShareEpoch != proposalEpoch ||
|
||||
refresh.candidateSecretShare == null || refresh.candidatePublicShareList() == null ||
|
||||
refresh.stage != mobi.giza.compose.database.model.types.ReEnrollmentStage.ACTIVATING
|
||||
(refresh.stage != mobi.giza.compose.database.model.types.ReEnrollmentStage.ACTIVATING &&
|
||||
!(refresh.stage == mobi.giza.compose.database.model.types.ReEnrollmentStage.FAILED && refresh.readyAt != null))
|
||||
) {
|
||||
logger.w("Signing proposal $sessionId does not have a valid activation candidate; dropping")
|
||||
return null
|
||||
@@ -741,6 +742,7 @@ object FrostSigningManager {
|
||||
database.frostSigningSessionDao().upsert(session)
|
||||
database.frostSigningSessionDao().upsertItems(itemsOver(sessionId, unsignedEvents))
|
||||
announceStarted(database, session)
|
||||
refresh?.let { FrostReEnrollmentManager.noteActivation(database, it) }
|
||||
|
||||
logger.i(
|
||||
"Recorded signing session $sessionId over ${describe(unsignedEvents.size)} " +
|
||||
@@ -1063,7 +1065,8 @@ object FrostSigningManager {
|
||||
refresh.stage !in setOf(
|
||||
mobi.giza.compose.database.model.types.ReEnrollmentStage.ACTIVATING,
|
||||
mobi.giza.compose.database.model.types.ReEnrollmentStage.COMPLETE,
|
||||
)
|
||||
) && !(refresh.stage == mobi.giza.compose.database.model.types.ReEnrollmentStage.FAILED &&
|
||||
refresh.readyAt != null)
|
||||
)
|
||||
) {
|
||||
logger.i("Activation session $sessionId has no matching staged candidate; leaving it")
|
||||
@@ -2266,7 +2269,8 @@ object FrostSigningManager {
|
||||
refresh.stage !in setOf(
|
||||
mobi.giza.compose.database.model.types.ReEnrollmentStage.ACTIVATING,
|
||||
mobi.giza.compose.database.model.types.ReEnrollmentStage.COMPLETE,
|
||||
)
|
||||
) && !(refresh.stage == mobi.giza.compose.database.model.types.ReEnrollmentStage.FAILED &&
|
||||
refresh.readyAt != null)
|
||||
)
|
||||
) {
|
||||
logger.i("Activation session $sessionId has no staged candidate to resend")
|
||||
|
||||
+6
@@ -49,6 +49,7 @@ import mobi.giza.compose.repository.NostrRepository
|
||||
import mobi.giza.compose.ui.composable.navigation.routes.ChatRoomDetailRoute
|
||||
import mobi.giza.compose.ui.composable.navigation.routes.DkgRitualRoute
|
||||
import mobi.giza.compose.ui.composable.navigation.routes.ProposalListRoute
|
||||
import mobi.giza.compose.ui.composable.navigation.routes.ReEnrollmentRoute
|
||||
import mobi.giza.compose.ui.composable.navigation.routes.proposalDestination
|
||||
import mobi.giza.compose.ui.composable.navigation.routes.Route
|
||||
import mobi.giza.compose.ui.composable.widgets.LoadingDataIndicator
|
||||
@@ -196,6 +197,11 @@ fun ChatRoomMessagingScreen(
|
||||
)
|
||||
)
|
||||
},
|
||||
onOpenReEnrollment = { sessionId ->
|
||||
onNavigateToRoute(
|
||||
ReEnrollmentRoute(activeUserPublicKey, chatRoomId, sessionId)
|
||||
)
|
||||
},
|
||||
// The notice has just counted the proposals
|
||||
// waiting on this member and said so. Opening
|
||||
// the room's whole signing history from it
|
||||
|
||||
+27
-3
@@ -21,6 +21,7 @@ import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import mobi.giza.compose.database.model.types.ReEnrollmentPurpose
|
||||
import mobi.giza.compose.database.model.types.ReEnrollmentStage
|
||||
@@ -29,6 +30,7 @@ import mobi.giza.compose.repository.ChatRepository
|
||||
import mobi.giza.compose.repository.ReEnrollmentRepository
|
||||
import mobi.giza.compose.resources.Res
|
||||
import mobi.giza.compose.resources.abandon
|
||||
import mobi.giza.compose.resources.active_share_epoch
|
||||
import mobi.giza.compose.resources.approve_share_repair
|
||||
import mobi.giza.compose.resources.ask_again
|
||||
import mobi.giza.compose.resources.commitments_received
|
||||
@@ -44,6 +46,7 @@ import mobi.giza.compose.resources.refresh_backup_warning
|
||||
import mobi.giza.compose.resources.refresh_complete
|
||||
import mobi.giza.compose.resources.refresh_error
|
||||
import mobi.giza.compose.resources.refresh_failed
|
||||
import mobi.giza.compose.resources.refresh_member_roster
|
||||
import mobi.giza.compose.resources.refresh_pending_activation
|
||||
import mobi.giza.compose.resources.refresh_shares_description
|
||||
import mobi.giza.compose.resources.refresh_signing_shares
|
||||
@@ -55,6 +58,7 @@ import mobi.giza.compose.resources.repair_helpers_responded
|
||||
import mobi.giza.compose.resources.repair_public_table_verified
|
||||
import mobi.giza.compose.resources.repair_share
|
||||
import mobi.giza.compose.resources.refresh_stage
|
||||
import mobi.giza.compose.resources.refresh_unchanged_group_key
|
||||
import mobi.giza.compose.resources.refresh_waiting_on_members
|
||||
import mobi.giza.compose.ui.composable.navigation.routes.ReEnrollmentRoute
|
||||
import mobi.giza.compose.ui.composable.navigation.routes.Route
|
||||
@@ -134,11 +138,31 @@ fun ReEnrollmentScreen(
|
||||
Text(stringResource(Res.string.refresh_shares_description))
|
||||
Text(stringResource(Res.string.refresh_all_members_required))
|
||||
}
|
||||
state.thresholdPublicKey?.let { groupKey ->
|
||||
Text(
|
||||
stringResource(Res.string.refresh_unchanged_group_key, groupKey),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.MiddleEllipsis,
|
||||
)
|
||||
}
|
||||
Text(
|
||||
stringResource(
|
||||
Res.string.refresh_member_roster,
|
||||
session.participantPublicKeySet().sorted().joinToString {
|
||||
it.memberName(state.localChatRoom.localParticipants, session.userPublicKey)
|
||||
},
|
||||
)
|
||||
)
|
||||
Card(modifier = Modifier.fillMaxWidth()) {
|
||||
Column(modifier = Modifier.padding(MaterialTheme.spacing.containerPadding)) {
|
||||
Text(stringResource(Res.string.current_share_epoch, session.currentShareEpoch))
|
||||
if (session.purpose != ReEnrollmentPurpose.REPAIR) {
|
||||
Text(stringResource(Res.string.next_share_epoch, session.nextShareEpoch))
|
||||
if (session.stage == ReEnrollmentStage.COMPLETE) {
|
||||
Text(stringResource(Res.string.active_share_epoch, session.nextShareEpoch))
|
||||
} else {
|
||||
Text(stringResource(Res.string.current_share_epoch, session.currentShareEpoch))
|
||||
if (session.purpose != ReEnrollmentPurpose.REPAIR) {
|
||||
Text(stringResource(Res.string.next_share_epoch, session.nextShareEpoch))
|
||||
}
|
||||
}
|
||||
Text(stringResource(Res.string.of_members_will_be_needed_to_sign_with_this, session.threshold, session.participantCount))
|
||||
Text(stringResource(Res.string.refresh_stage, session.stage.name))
|
||||
|
||||
+25
-1
@@ -45,6 +45,7 @@ import androidx.compose.material.icons.filled.History
|
||||
import androidx.compose.material.icons.filled.Groups
|
||||
import androidx.compose.material.icons.filled.PanTool
|
||||
import androidx.compose.material.icons.filled.PersonAdd
|
||||
import androidx.compose.material.icons.filled.Refresh
|
||||
import androidx.compose.material.icons.filled.Upload
|
||||
import androidx.compose.material.icons.filled.WorkspacePremium
|
||||
import androidx.compose.material.icons.filled.Info
|
||||
@@ -87,6 +88,7 @@ import mobi.giza.compose.resources.loading
|
||||
import mobi.giza.compose.resources.no_chat_message_relays_were_found_for_this
|
||||
import mobi.giza.compose.resources.private_to_you
|
||||
import mobi.giza.compose.resources.review
|
||||
import mobi.giza.compose.resources.refresh_signing_shares
|
||||
import mobi.giza.compose.resources.waiting_for_your_signature
|
||||
import mobi.giza.compose.resources.you
|
||||
import mobi.giza.compose.resources.private_to
|
||||
@@ -121,6 +123,7 @@ fun ChatTranscript(
|
||||
* and cannot say which one it meant.
|
||||
*/
|
||||
onOpenSigning: (sessionId: String?) -> Unit,
|
||||
onOpenReEnrollment: (sessionId: String) -> Unit,
|
||||
/** Opens the room's proposals, all of them, whatever their state. */
|
||||
onOpenProposals: () -> Unit,
|
||||
) {
|
||||
@@ -369,6 +372,19 @@ fun ChatTranscript(
|
||||
return@items
|
||||
}
|
||||
|
||||
if (localChatMessage.chatMessage.messageType in ChatMessage.REENROLLMENT_TYPES) {
|
||||
RitualNotice(
|
||||
localChatMessage = localChatMessage,
|
||||
isAnswered = true,
|
||||
isSettled = true,
|
||||
onClick = localChatMessage.chatMessage.reEnrollmentSessionId?.let { sessionId ->
|
||||
{ onOpenReEnrollment(sessionId) }
|
||||
},
|
||||
opens = stringResource(Res.string.refresh_signing_shares),
|
||||
)
|
||||
return@items
|
||||
}
|
||||
|
||||
// Signing lines are the same kind of thing and get
|
||||
// the same treatment -- nobody said them either --
|
||||
// but they lead somewhere else, because what a
|
||||
@@ -852,6 +868,12 @@ private fun RitualNotice(
|
||||
ChatMessage.TYPE_FROST_RESENT -> Icons.Default.Campaign
|
||||
ChatMessage.TYPE_FROST_APPROVAL_NEEDED -> Icons.Default.Draw
|
||||
|
||||
ChatMessage.TYPE_REENROLLMENT_STARTED,
|
||||
ChatMessage.TYPE_REENROLLMENT_READY,
|
||||
ChatMessage.TYPE_REENROLLMENT_ACTIVATING -> Icons.Default.Refresh
|
||||
ChatMessage.TYPE_REENROLLMENT_COMPLETE -> Icons.Default.CheckCircle
|
||||
ChatMessage.TYPE_REENROLLMENT_FAILED -> Icons.Default.ErrorOutline
|
||||
|
||||
ChatMessage.TYPE_CHRONICLE_REQUESTED -> Icons.Default.History
|
||||
ChatMessage.TYPE_CHRONICLE_SENT -> Icons.Default.Upload
|
||||
ChatMessage.TYPE_CHRONICLE_RECEIVED -> Icons.Default.Download
|
||||
@@ -886,6 +908,7 @@ private fun RitualNotice(
|
||||
val tint = when {
|
||||
chatMessage.messageType == ChatMessage.TYPE_DKG_FAILED ||
|
||||
chatMessage.messageType == ChatMessage.TYPE_FROST_FAILED ||
|
||||
chatMessage.messageType == ChatMessage.TYPE_REENROLLMENT_FAILED ||
|
||||
chatMessage.messageType == ChatMessage.TYPE_MEMBER_INVITE_FAILED ||
|
||||
chatMessage.messageType == ChatMessage.TYPE_CHANGE_REJECTED ->
|
||||
MaterialTheme.colorScheme.error
|
||||
@@ -920,7 +943,8 @@ private fun RitualNotice(
|
||||
// so it follows a rename and is not stuck on the "LOADING..."
|
||||
// placeholder a member is given the moment they are first seen.
|
||||
if (chatMessage.messageType in ChatMessage.DKG_AUTHORED_TYPES ||
|
||||
chatMessage.messageType in ChatMessage.FROST_AUTHORED_TYPES
|
||||
chatMessage.messageType in ChatMessage.FROST_AUTHORED_TYPES ||
|
||||
chatMessage.messageType in ChatMessage.REENROLLMENT_AUTHORED_TYPES
|
||||
) {
|
||||
withStyle(
|
||||
SpanStyle(color = ProfileColor.fromPublicKey(chatMessage.senderPublicKey))
|
||||
|
||||
+4
-1
@@ -53,11 +53,14 @@ class ReEnrollmentViewModel(
|
||||
uiState = ReEnrollmentUIState.Error("This group cannot refresh its shares")
|
||||
return@launch
|
||||
}
|
||||
val thresholdPublicKey = chatRepository.groupKeyState(chatRoomId)?.thresholdPublicKey
|
||||
combine(
|
||||
reEnrollmentRepository.observeSessionById(sessionId),
|
||||
reEnrollmentRepository.observeMessages(sessionId),
|
||||
) { session, messages ->
|
||||
session?.let { ReEnrollmentUIState.Loaded(room, it, messages, reEnrollmentRepository.pendingApproval(it)) }
|
||||
session?.let {
|
||||
ReEnrollmentUIState.Loaded(room, it, messages, reEnrollmentRepository.pendingApproval(it), thresholdPublicKey)
|
||||
}
|
||||
}.collect { state -> state?.let { uiState = it } }
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -13,6 +13,7 @@ sealed interface ReEnrollmentUIState {
|
||||
val session: FrostReEnrollmentSession,
|
||||
val messages: List<FrostReEnrollmentMessage>,
|
||||
val pendingApproval: Boolean,
|
||||
val thresholdPublicKey: String? = null,
|
||||
) : ReEnrollmentUIState {
|
||||
val commitments: Int get() = messages.count { it.kind == ReEnrollmentEvents.COMMITMENTS }
|
||||
val evaluations: Int get() = messages.count {
|
||||
|
||||
+270
-11
@@ -12,6 +12,7 @@ import fr.acinq.bitcoin.crypto.frost.KeyMaterial
|
||||
import kotlin.test.AfterTest
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFailsWith
|
||||
import kotlin.test.assertFalse
|
||||
import kotlin.test.assertNotNull
|
||||
import kotlin.test.assertNull
|
||||
@@ -19,6 +20,7 @@ import kotlin.test.assertTrue
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import mobi.giza.compose.database.GizaDatabase
|
||||
import mobi.giza.compose.database.builder.getRoomDatabase
|
||||
import mobi.giza.compose.database.model.ChatMessage
|
||||
import mobi.giza.compose.database.model.ChatRoom
|
||||
import mobi.giza.compose.database.model.DkgParticipantMessage
|
||||
import mobi.giza.compose.database.model.DkgSession
|
||||
@@ -37,18 +39,18 @@ import mobi.giza.compose.nostr.frost.GroupKeyStateEvent
|
||||
import mobi.giza.compose.nostr.frost.ReEnrollmentEvents
|
||||
|
||||
class FrostReEnrollmentManagerJvmTest {
|
||||
private val participants = 3
|
||||
private val threshold = 2
|
||||
private val keyMaterial: KeyMaterial = Frost.trustedDealerKeygen(
|
||||
private var participants = 3
|
||||
private var threshold = 2
|
||||
private var keyMaterial: KeyMaterial = Frost.trustedDealerKeygen(
|
||||
PrivateKey(ByteVector32("1c0ffee0000000000000000000000000000000000000000000000000000000a1")),
|
||||
participants,
|
||||
threshold,
|
||||
)
|
||||
private val thresholdPublicKey = keyMaterial.thresholdPublicKey.value.toHex()
|
||||
private val roomId = SharedKeyDerivation.marmotGroupId(thresholdPublicKey)
|
||||
private var thresholdPublicKey = keyMaterial.thresholdPublicKey.value.toHex()
|
||||
private var roomId = SharedKeyDerivation.marmotGroupId(thresholdPublicKey)
|
||||
private val ceremonyId = "ceremony".padEnd(64, '0')
|
||||
private val members = listOf("a", "b", "c").map { it.repeat(64) }
|
||||
private val hostKeys = listOf("2a", "2b", "2c").map { it.padEnd(66, '0') }
|
||||
private var members = listOf("a", "b", "c").map { it.repeat(64) }
|
||||
private var hostKeys = listOf("2a", "2b", "2c").map { it.padEnd(66, '0') }
|
||||
private val devices = mutableListOf<Device>()
|
||||
private val delivered = mutableSetOf<String>()
|
||||
|
||||
@@ -141,8 +143,26 @@ class FrostReEnrollmentManagerJvmTest {
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun openDevices(signerHostKeys: List<String> = hostKeys) {
|
||||
devices += List(participants) { index -> Device(index, signerHostKeys).apply { open() } }
|
||||
private suspend fun openDevices(
|
||||
participantCount: Int = participants,
|
||||
minimumSigners: Int = threshold,
|
||||
signerHostKeys: List<String>? = null,
|
||||
) {
|
||||
require(devices.isEmpty())
|
||||
participants = participantCount
|
||||
threshold = minimumSigners
|
||||
keyMaterial = Frost.trustedDealerKeygen(
|
||||
PrivateKey(ByteVector32("1c0ffee0000000000000000000000000000000000000000000000000000000a1")),
|
||||
participants,
|
||||
threshold,
|
||||
)
|
||||
thresholdPublicKey = keyMaterial.thresholdPublicKey.value.toHex()
|
||||
roomId = SharedKeyDerivation.marmotGroupId(thresholdPublicKey)
|
||||
members = List(participants) { index -> ('a' + index).toString().repeat(64) }
|
||||
hostKeys = List(participants) { index -> "2${'a' + index}".padEnd(66, '0') }
|
||||
val orderedHostKeys = signerHostKeys ?: hostKeys
|
||||
require(orderedHostKeys.size == participants)
|
||||
devices += List(participants) { index -> Device(index, orderedHostKeys).apply { open() } }
|
||||
}
|
||||
|
||||
private suspend fun pump(
|
||||
@@ -189,6 +209,32 @@ class FrostReEnrollmentManagerJvmTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `an unavailable or invalid public table prevents any refresh message`() = runBlocking {
|
||||
openDevices()
|
||||
val coordinator = devices[0]
|
||||
val key = coordinator.db.dkgSessionDao().getSessionById(ceremonyId)!!
|
||||
coordinator.db.dkgSessionDao().upsert(key.copy(publicShares = null))
|
||||
val missing = assertFailsWith<IllegalArgumentException> {
|
||||
FrostReEnrollmentManager.proposeReEnrollment(coordinator.db, coordinator.room, coordinator.member)
|
||||
}
|
||||
assertTrue(missing.message!!.contains("repair it with current members"))
|
||||
|
||||
val fabricated = Frost.trustedDealerKeygen(
|
||||
PrivateKey(ByteVector32("8".repeat(64))), participants, threshold,
|
||||
).publicShares.joinToString(",") { it.value.toHex() }
|
||||
coordinator.db.dkgSessionDao().upsert(key.copy(publicShares = fabricated))
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
FrostReEnrollmentManager.proposeReEnrollment(coordinator.db, coordinator.room, coordinator.member)
|
||||
}
|
||||
assertTrue(
|
||||
coordinator.db.marmotInnerEventDao().getByChatRoomAndKinds(
|
||||
roomId,
|
||||
listOf(ReEnrollmentEvents.PROPOSAL, ReEnrollmentEvents.COMMITMENTS, ReEnrollmentEvents.PRIVATE_EVALUATION),
|
||||
).isEmpty()
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `all members reach activation with the same verified candidate`() = runBlocking {
|
||||
openDevices()
|
||||
@@ -222,8 +268,12 @@ class FrostReEnrollmentManagerJvmTest {
|
||||
assertEquals(participants * (participants - 1), direct.distinctBy { it.id }.size)
|
||||
}
|
||||
|
||||
private suspend fun refreshAndActivate(signerHostKeys: List<String> = hostKeys) {
|
||||
openDevices(signerHostKeys)
|
||||
private suspend fun refreshAndActivate(
|
||||
signerHostKeys: List<String>? = null,
|
||||
participantCount: Int = participants,
|
||||
minimumSigners: Int = threshold,
|
||||
) {
|
||||
openDevices(participantCount, minimumSigners, signerHostKeys)
|
||||
devices[0].let { FrostReEnrollmentManager.proposeReEnrollment(it.db, it.room, it.member) }
|
||||
pump { it.kind == ReEnrollmentEvents.PROPOSAL }
|
||||
devices.drop(1).forEach { device ->
|
||||
@@ -382,6 +432,200 @@ class FrostReEnrollmentManagerJvmTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a signed activation takes precedence over a local failure`() = runBlocking {
|
||||
openDevices()
|
||||
devices[0].let { FrostReEnrollmentManager.proposeReEnrollment(it.db, it.room, it.member) }
|
||||
pump { it.kind == ReEnrollmentEvents.PROPOSAL }
|
||||
devices.drop(1).forEach { device ->
|
||||
FrostReEnrollmentManager.approve(device.db, device.room, device.session()!!.id)
|
||||
}
|
||||
pump()
|
||||
val activation = devices[0].let {
|
||||
FrostReEnrollmentManager.proposeActivation(it.db, it.room, it.member, it.session()!!.id)
|
||||
}!!
|
||||
val target = devices[2]
|
||||
target.receive(
|
||||
MarmotInnerEvent(
|
||||
id = "f".repeat(64),
|
||||
publicKey = devices[0].member,
|
||||
chatRoomId = roomId,
|
||||
kind = ReEnrollmentEvents.FAILURE,
|
||||
tags = ReEnrollmentEvents.assembleTags(activation.refreshSessionId!!),
|
||||
content = "A local failure arrived before the signature",
|
||||
createdAt = kotlin.time.Instant.fromEpochSeconds(1_700_000_100),
|
||||
)
|
||||
)
|
||||
val failed = target.session()!!
|
||||
assertEquals(ReEnrollmentStage.FAILED, failed.stage)
|
||||
assertNotNull(failed.candidateSecretShare)
|
||||
assertNotNull(failed.candidatePublicShares)
|
||||
assertEquals(0, target.db.dkgSessionDao().getSessionById(ceremonyId)!!.shareEpoch)
|
||||
|
||||
pump { it.kind == FrostSigningEvents.PROPOSAL_V2 }
|
||||
FrostSigningManager.approve(devices[1].db, devices[1].room, activation.id)
|
||||
pump { it.kind in FrostSigningEvents.ALL }
|
||||
|
||||
devices.forEach { device ->
|
||||
assertEquals(1, device.db.dkgSessionDao().getSessionById(ceremonyId)!!.shareEpoch)
|
||||
assertEquals(ReEnrollmentStage.COMPLETE, device.session()!!.stage)
|
||||
assertNull(device.session()!!.candidateSecretShare)
|
||||
}
|
||||
val signed = target.db.groupSignedEventDao().getByKind(ReEnrollmentEvents.KEY_EPOCH_STATE).single().toEvent()
|
||||
assertTrue(Nip01Crypto.verify(signed.sig.hexToByteArray(), signed.id.hexToByteArray(), roomId.hexToByteArray()))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `activation retry keeps the candidate and uses fresh nonce seeds`() = runBlocking {
|
||||
openDevices()
|
||||
devices[0].let { FrostReEnrollmentManager.proposeReEnrollment(it.db, it.room, it.member) }
|
||||
pump { it.kind == ReEnrollmentEvents.PROPOSAL }
|
||||
devices.drop(1).forEach { device ->
|
||||
FrostReEnrollmentManager.approve(device.db, device.room, device.session()!!.id)
|
||||
}
|
||||
pump()
|
||||
val refreshId = devices[2].session()!!.id
|
||||
val candidate = devices[2].session()!!
|
||||
val first = devices[0].let {
|
||||
FrostReEnrollmentManager.proposeActivation(it.db, it.room, it.member, refreshId)
|
||||
}!!
|
||||
pump { it.kind == FrostSigningEvents.PROPOSAL_V2 }
|
||||
devices.drop(1).forEach { device -> FrostSigningManager.decline(device.db, device.room, first.id) }
|
||||
pump()
|
||||
|
||||
devices.forEach { device ->
|
||||
assertEquals(mobi.giza.compose.database.model.types.FrostSigningStage.FAILED,
|
||||
device.db.frostSigningSessionDao().getSessionById(first.id)!!.stage)
|
||||
}
|
||||
assertEquals(candidate.candidateSecretShare, devices[2].session()!!.candidateSecretShare)
|
||||
assertEquals(candidate.candidatePublicShares, devices[2].session()!!.candidatePublicShares)
|
||||
|
||||
val coordinator = devices[2]
|
||||
val retry = FrostReEnrollmentManager.proposeActivation(coordinator.db, coordinator.room, coordinator.member, refreshId)!!
|
||||
assertTrue(retry.id != first.id)
|
||||
pump { it.kind == FrostSigningEvents.PROPOSAL_V2 }
|
||||
devices.forEach { device ->
|
||||
val original = device.db.frostSigningSessionDao().getItems(first.id).single().nonceRandom
|
||||
val replacement = device.db.frostSigningSessionDao().getItems(retry.id).single().nonceRandom
|
||||
assertTrue(original != replacement)
|
||||
}
|
||||
devices.filter { it.member != coordinator.member }.forEach { device ->
|
||||
FrostSigningManager.approve(device.db, device.room, retry.id)
|
||||
}
|
||||
pump()
|
||||
|
||||
devices.forEach { device ->
|
||||
assertEquals(1, device.db.dkgSessionDao().getSessionById(ceremonyId)!!.shareEpoch)
|
||||
assertEquals(ReEnrollmentStage.COMPLETE, device.session()!!.stage)
|
||||
assertNull(device.session()!!.candidateSecretShare)
|
||||
}
|
||||
val signed = coordinator.db.groupSignedEventDao().getByKind(ReEnrollmentEvents.KEY_EPOCH_STATE).single().toEvent()
|
||||
assertTrue(Nip01Crypto.verify(signed.sig.hexToByteArray(), signed.id.hexToByteArray(), roomId.hexToByteArray()))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a delayed activation signature activates from persisted state`() = runBlocking {
|
||||
openDevices()
|
||||
devices[0].let { FrostReEnrollmentManager.proposeReEnrollment(it.db, it.room, it.member) }
|
||||
pump { it.kind == ReEnrollmentEvents.PROPOSAL }
|
||||
devices.drop(1).forEach { device ->
|
||||
FrostReEnrollmentManager.approve(device.db, device.room, device.session()!!.id)
|
||||
}
|
||||
pump()
|
||||
val activation = devices[0].let {
|
||||
FrostReEnrollmentManager.proposeActivation(it.db, it.room, it.member, it.session()!!.id)
|
||||
}!!
|
||||
pump { it.kind == FrostSigningEvents.PROPOSAL_V2 }
|
||||
devices.drop(1).forEach { device -> FrostSigningManager.approve(device.db, device.room, activation.id) }
|
||||
pump { it.kind != FrostSigningEvents.SIGNATURE }
|
||||
|
||||
val waiting = devices.filter { it.db.dkgSessionDao().getSessionById(ceremonyId)!!.shareEpoch == 0L }
|
||||
assertTrue(waiting.isNotEmpty())
|
||||
waiting.forEach { device ->
|
||||
assertNotNull(device.session()!!.candidateSecretShare)
|
||||
assertEquals(0, device.db.groupKeyStateDao().getByChatRoomId(roomId)!!.shareEpoch)
|
||||
}
|
||||
pump { it.kind == FrostSigningEvents.SIGNATURE }
|
||||
|
||||
devices.forEach { device ->
|
||||
assertEquals(1, device.db.dkgSessionDao().getSessionById(ceremonyId)!!.shareEpoch)
|
||||
assertEquals(1, device.db.groupKeyStateDao().getByChatRoomId(roomId)!!.shareEpoch)
|
||||
assertNull(device.session()!!.candidateSecretShare)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `out-of-order messages replay from storage and duplicates are idempotent`() = runBlocking {
|
||||
openDevices()
|
||||
devices[0].let { FrostReEnrollmentManager.proposeReEnrollment(it.db, it.room, it.member) }
|
||||
pump { it.kind != ReEnrollmentEvents.PROPOSAL }
|
||||
devices.drop(1).forEach { assertNull(it.session()) }
|
||||
|
||||
delivered.clear()
|
||||
pump { it.kind == ReEnrollmentEvents.PROPOSAL }
|
||||
devices.drop(1).forEach { device ->
|
||||
FrostReEnrollmentManager.approve(device.db, device.room, device.session()!!.id)
|
||||
}
|
||||
pump()
|
||||
|
||||
val staged = devices.map { it.session()!! }
|
||||
assertEquals(List(participants) { ReEnrollmentStage.ACTIVATING }, staged.map { it.stage })
|
||||
assertEquals(1, staged.map { it.transcriptHash }.toSet().size)
|
||||
delivered.clear()
|
||||
pump()
|
||||
assertEquals(staged, devices.map { it.session()!! })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a conflicting ready transcript cannot start activation`() = runBlocking {
|
||||
openDevices()
|
||||
devices[0].let { FrostReEnrollmentManager.proposeReEnrollment(it.db, it.room, it.member) }
|
||||
pump { it.kind == ReEnrollmentEvents.PROPOSAL }
|
||||
devices.drop(1).forEach { device ->
|
||||
FrostReEnrollmentManager.approve(device.db, device.room, device.session()!!.id)
|
||||
}
|
||||
pump { it.kind != ReEnrollmentEvents.READY }
|
||||
|
||||
val target = devices[1]
|
||||
val refresh = target.session()!!
|
||||
val ready = devices[0].db.marmotInnerEventDao()
|
||||
.getByChatRoomAndKinds(roomId, listOf(ReEnrollmentEvents.READY))
|
||||
.single { ReEnrollmentEvents.parseSessionId(it.tags) == refresh.id }
|
||||
target.receive(ready.copy(content = "00".repeat(32)))
|
||||
|
||||
assertEquals(ReEnrollmentStage.CANDIDATE_READY, target.session()!!.stage)
|
||||
assertNull(FrostReEnrollmentManager.proposeActivation(target.db, target.room, target.member, refresh.id))
|
||||
assertEquals(0, target.db.dkgSessionDao().getSessionById(ceremonyId)!!.shareEpoch)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `three of five members refresh and the last member can coordinate signing`() = runBlocking {
|
||||
refreshAndActivate(participantCount = 5, minimumSigners = 3)
|
||||
devices.forEach { device ->
|
||||
assertEquals(1, device.db.dkgSessionDao().getSessionById(ceremonyId)!!.shareEpoch)
|
||||
assertEquals(ReEnrollmentStage.COMPLETE, device.session()!!.stage)
|
||||
}
|
||||
val evaluations = devices.flatMap { device ->
|
||||
device.db.marmotInnerEventDao().getByChatRoomAndKinds(roomId, listOf(ReEnrollmentEvents.PRIVATE_EVALUATION))
|
||||
}.distinctBy { it.id }
|
||||
assertEquals(participants * (participants - 1), evaluations.size)
|
||||
assertTrue(evaluations.all { it.content.isEmpty() })
|
||||
|
||||
val coordinator = devices.last()
|
||||
val after = FrostSigningManager.proposeSigning(
|
||||
coordinator.db, coordinator.room, coordinator.member, 1, emptyArray(), "three of five refresh",
|
||||
)
|
||||
pump { it.kind == FrostSigningEvents.PROPOSAL_V2 }
|
||||
devices.filter { it.member != coordinator.member }.forEach { device ->
|
||||
FrostSigningManager.approve(device.db, device.room, after.id)
|
||||
}
|
||||
pump()
|
||||
val signed = coordinator.db.groupSignedEventDao().getByKind(1).single {
|
||||
it.content == "three of five refresh"
|
||||
}.toEvent()
|
||||
assertTrue(Nip01Crypto.verify(signed.sig.hexToByteArray(), signed.id.hexToByteArray(), roomId.hexToByteArray()))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a resend names missing members and republishes the same private bytes`() = runBlocking {
|
||||
openDevices()
|
||||
@@ -467,6 +711,21 @@ class FrostReEnrollmentManagerJvmTest {
|
||||
.getByChatRoomAndKinds(roomId, listOf(ReEnrollmentEvents.PRIVATE_EVALUATION))
|
||||
.all { it.content.isEmpty() }
|
||||
)
|
||||
val notices = device.db.chatMessageDao().getChatMessagesByChatRoomId(roomId)
|
||||
.map { it.chatMessage }
|
||||
.filter { it.reEnrollmentSessionId == refresh.id }
|
||||
assertEquals(
|
||||
setOf(
|
||||
ChatMessage.TYPE_REENROLLMENT_STARTED,
|
||||
ChatMessage.TYPE_REENROLLMENT_READY,
|
||||
ChatMessage.TYPE_REENROLLMENT_ACTIVATING,
|
||||
ChatMessage.TYPE_REENROLLMENT_COMPLETE,
|
||||
),
|
||||
notices.map { it.messageType }.toSet(),
|
||||
)
|
||||
assertEquals(notices.size, notices.map { it.messageType }.toSet().size)
|
||||
assertTrue(notices.none { it.content.contains(key.secretShare!!) })
|
||||
assertTrue(notices.none { it.content.contains(keyMaterial.secretShares[index].value.toHex()) })
|
||||
}
|
||||
|
||||
val after = devices[0].let {
|
||||
|
||||
@@ -160,9 +160,9 @@ internal object GroupFixtures {
|
||||
private fun signature(material: KeyMaterial, eventId: String): String =
|
||||
signWith(material, SharedKeyDerivation.derive(thresholdKeyOf(material), path).cache, ByteVector(eventId.hexToByteArray())).toHex()
|
||||
|
||||
/** A 2-of-3 FROST signature by [material]'s quorum over [message] under [cache] -- a leaf's, an address's, the room's. */
|
||||
/** A threshold FROST signature by [material]'s quorum over [message] under [cache]. */
|
||||
fun signWith(material: KeyMaterial, cache: TweakCache, message: ByteVector): ByteVector64 {
|
||||
val signerIds = listOf(0, 1)
|
||||
val signerIds = (0 until material.threshold).toList()
|
||||
|
||||
val nonces = signerIds.map { signerId ->
|
||||
SecretNonce.generate(
|
||||
@@ -178,8 +178,8 @@ internal object GroupFixtures {
|
||||
aggregatedNonce = IndividualNonce.aggregate(nonces.map { it.second }).right!!,
|
||||
signerIds = signerIds.map { it.toUInt() },
|
||||
signerPublicShares = signerIds.map { material.publicShares[it] },
|
||||
nParticipants = PARTICIPANTS,
|
||||
threshold = THRESHOLD,
|
||||
nParticipants = material.nParticipants,
|
||||
threshold = material.threshold,
|
||||
tweakCache = cache,
|
||||
message = message,
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user