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

Add DKLS/Schnorr keygen #1528

Merged
merged 1 commit into from
Dec 27, 2024
Merged
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 @@ -79,6 +79,13 @@ internal class MainActivity : AppCompatActivity() {
navController.route(it.dst.route, it.opts)
}
}

LaunchedEffect(Unit) {
mainViewModel.route.collect {
navController.route(it)
}
}

Box(
modifier = Modifier
.background(color = Colors.Default.oxfordBlue800)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ internal class MainViewModel @Inject constructor(

val destination: Flow<NavigateAction<Destination>> = navigator.destination

val route: Flow<Any> = navigator.route

val snakeBarHostState = SnackbarHostState()

init {
Expand Down
7 changes: 6 additions & 1 deletion app/src/main/java/com/vultisig/wallet/data/db/AppDatabase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.vultisig.wallet.data.db

import androidx.room.Database
import androidx.room.RoomDatabase
import androidx.room.TypeConverters
import com.vultisig.wallet.data.db.converters.SigningLibTypeTypeConverter
import com.vultisig.wallet.data.db.dao.AddressBookEntryDao
import com.vultisig.wallet.data.db.dao.AddressBookOrderDao
import com.vultisig.wallet.data.db.dao.FolderDao
Expand Down Expand Up @@ -39,9 +41,12 @@ import com.vultisig.wallet.data.db.models.VaultOrderEntity
FolderOrderEntity::class,
VaultMetadataEntity::class,
],
version = 19,
version = 20,
exportSchema = false,
)
@TypeConverters(
SigningLibTypeTypeConverter::class,
)
abstract class AppDatabase : RoomDatabase() {

abstract fun vaultDao(): VaultDao
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.vultisig.wallet.data.db.migrations.MIGRATION_15_16
import com.vultisig.wallet.data.db.migrations.MIGRATION_16_17
import com.vultisig.wallet.data.db.migrations.MIGRATION_17_18
import com.vultisig.wallet.data.db.migrations.MIGRATION_18_19
import com.vultisig.wallet.data.db.migrations.MIGRATION_19_20
import com.vultisig.wallet.data.db.migrations.MIGRATION_1_2
import com.vultisig.wallet.data.db.migrations.MIGRATION_2_3
import com.vultisig.wallet.data.db.migrations.MIGRATION_3_4
Expand Down Expand Up @@ -72,6 +73,7 @@ internal interface DatabaseModule {
MIGRATION_16_17,
MIGRATION_17_18,
MIGRATION_18_19,
MIGRATION_19_20,
)
.build()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,4 +346,14 @@ internal val MIGRATION_18_19 = object : Migration(18, 19) {
""".trimIndent()
)
}
}

internal val MIGRATION_19_20 = object : Migration(19, 20) {
override fun migrate(db: SupportSQLiteDatabase) {
db.execSQL(
"""
ALTER TABLE `vault` ADD COLUMN `libType` TEXT NOT NULL DEFAULT 'GG20'
""".trimIndent()
)
}
}
25 changes: 25 additions & 0 deletions app/src/main/java/com/vultisig/wallet/data/keygen/DklsHelper.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.vultisig.wallet.data.keygen

import kotlin.math.ceil

object DklsHelper {
fun getThreshold(input: Int): Long {
return ceil(input * 2.0 / 3.0).toLong()
}

fun arrayToBytes(parties: List<String>): ByteArray {
if (parties.isEmpty()) {
return byteArrayOf()
}
val byteArray = mutableListOf<Byte>()
for (item in parties) {
val utf8Bytes = item.toByteArray(Charsets.UTF_8)
byteArray.addAll(utf8Bytes.toList())
byteArray.add(0)
}
if (byteArray.last() == 0.toByte()) {
byteArray.removeAt(byteArray.size - 1)
}
return byteArray.toByteArray()
}
}
Loading
Loading