Remove Cryptography multiplatform library
- Added extension functions to convert BigInteger to hex string, and viceversa. - Updated Android Gradle Plugin to the latest version. - Updated AndroidX Activity Compose to the latest stable version.
This commit is contained in:
parent
584008004b
commit
a07805c8cc
6 changed files with 18 additions and 13 deletions
|
@ -1,13 +1,12 @@
|
||||||
[versions]
|
[versions]
|
||||||
agp = "8.2.0"
|
agp = "8.2.2"
|
||||||
android-compileSdk = "34"
|
android-compileSdk = "34"
|
||||||
android-minSdk = "26"
|
android-minSdk = "26"
|
||||||
android-targetSdk = "34"
|
android-targetSdk = "34"
|
||||||
androidx-activityCompose = "1.8.2"
|
androidx-activityCompose = "1.9.0"
|
||||||
composeCompiler = "1.5.12"
|
|
||||||
composeBom = "2024.04.01"
|
composeBom = "2024.04.01"
|
||||||
|
composeCompiler = "1.5.12"
|
||||||
coroutines = "1.8.0"
|
coroutines = "1.8.0"
|
||||||
cryptography = "0.3.0"
|
|
||||||
kotlin = "1.9.23"
|
kotlin = "1.9.23"
|
||||||
ktor = "2.3.9"
|
ktor = "2.3.9"
|
||||||
multiplatform-settings = "1.1.1"
|
multiplatform-settings = "1.1.1"
|
||||||
|
@ -25,7 +24,6 @@ compose-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-mani
|
||||||
compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
|
compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
|
||||||
compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
|
compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
|
||||||
coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "coroutines" }
|
coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "coroutines" }
|
||||||
cryptography-bigint = { group = "dev.whyoleg.cryptography", name = "cryptography-bigint", version.ref = "cryptography" }
|
|
||||||
kotlin-test = { group = "org.jetbrains.kotlin", name = "kotlin-test", version.ref = "kotlin" }
|
kotlin-test = { group = "org.jetbrains.kotlin", name = "kotlin-test", version.ref = "kotlin" }
|
||||||
ktor-client-cio = { group = "io.ktor", name = "ktor-client-cio", version.ref = "ktor" }
|
ktor-client-cio = { group = "io.ktor", name = "ktor-client-cio", version.ref = "ktor" }
|
||||||
ktor-client-core = { group = "io.ktor", name = "ktor-client-core", version.ref = "ktor" }
|
ktor-client-core = { group = "io.ktor", name = "ktor-client-core", version.ref = "ktor" }
|
||||||
|
|
|
@ -3,7 +3,5 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(libs.cryptography.bigint)
|
|
||||||
|
|
||||||
testImplementation(libs.kotlin.test)
|
testImplementation(libs.kotlin.test)
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package net.agorise.shared.crypto
|
||||||
|
|
||||||
|
import java.math.BigInteger
|
||||||
|
|
||||||
|
@OptIn(ExperimentalStdlibApi::class)
|
||||||
|
fun BigInteger.toHexString(format: HexFormat = HexFormat.Default): String =
|
||||||
|
toByteArray().toHexString(format)
|
||||||
|
|
||||||
|
@OptIn(ExperimentalStdlibApi::class)
|
||||||
|
fun String.hexToBigInteger(format: HexFormat = HexFormat.Default): BigInteger =
|
||||||
|
BigInteger(hexToByteArray(format))
|
|
@ -6,7 +6,6 @@ dependencies {
|
||||||
implementation(projects.library.crypto)
|
implementation(projects.library.crypto)
|
||||||
|
|
||||||
implementation(libs.coroutines.core)
|
implementation(libs.coroutines.core)
|
||||||
implementation(libs.cryptography.bigint)
|
|
||||||
implementation(libs.ktor.client.cio)
|
implementation(libs.ktor.client.cio)
|
||||||
implementation(libs.ktor.client.core)
|
implementation(libs.ktor.client.core)
|
||||||
implementation(libs.ktor.client.websockets)
|
implementation(libs.ktor.client.websockets)
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package net.agorise.shared.stargate.mnemonics
|
package net.agorise.shared.stargate.mnemonics
|
||||||
|
|
||||||
import dev.whyoleg.cryptography.bigint.BigInt
|
|
||||||
import dev.whyoleg.cryptography.bigint.decodeToBigInt
|
|
||||||
import io.ktor.utils.io.core.toByteArray
|
import io.ktor.utils.io.core.toByteArray
|
||||||
import net.agorise.shared.crypto.Crc32
|
import net.agorise.shared.crypto.Crc32
|
||||||
|
import java.math.BigInteger
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides functionality to create and validate mnemonics.
|
* Provides functionality to create and validate mnemonics.
|
||||||
|
@ -40,7 +39,7 @@ class Mnemonics {
|
||||||
/**
|
/**
|
||||||
* Given a list of words, returns the associated key if the words are valid or an exception otherwise
|
* Given a list of words, returns the associated key if the words are valid or an exception otherwise
|
||||||
*/
|
*/
|
||||||
fun getKeyAndLanguageFromWords(words: List<String>): Result<Pair<BigInt, String>> {
|
fun getKeyAndLanguageFromWords(words: List<String>): Result<Pair<BigInteger, String>> {
|
||||||
// The list must contain SEED_LENGTH + 1 words. The SEED_LENGTH + 1 word is the checksum
|
// The list must contain SEED_LENGTH + 1 words. The SEED_LENGTH + 1 word is the checksum
|
||||||
if (words.size != (SEED_LENGTH + 1)) {
|
if (words.size != (SEED_LENGTH + 1)) {
|
||||||
return Result.failure(Exception("Invalid seed"))
|
return Result.failure(Exception("Invalid seed"))
|
||||||
|
@ -79,7 +78,7 @@ class Mnemonics {
|
||||||
|
|
||||||
val languageName = languages[languageIndex].name
|
val languageName = languages[languageIndex].name
|
||||||
|
|
||||||
return Result.success(Pair(key.decodeToBigInt(), languageName))
|
return Result.success(Pair(BigInteger(key), languageName))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package net.agorise.shared.stargate.mnemonics
|
package net.agorise.shared.stargate.mnemonics
|
||||||
|
|
||||||
import dev.whyoleg.cryptography.bigint.toHexString
|
|
||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
import kotlin.test.assertFalse
|
import kotlin.test.assertFalse
|
||||||
import kotlin.test.assertTrue
|
import kotlin.test.assertTrue
|
||||||
|
import net.agorise.shared.crypto.toHexString
|
||||||
|
|
||||||
class MnemonicsTest {
|
class MnemonicsTest {
|
||||||
private val mnemonics = Mnemonics()
|
private val mnemonics = Mnemonics()
|
||||||
|
|
Loading…
Reference in a new issue