From 1eab8a3477833a0a4a535ea064be8f288025cf23 Mon Sep 17 00:00:00 2001 From: Luca Spinazzola Date: Wed, 21 Dec 2022 02:39:25 -0500 Subject: [PATCH] use AxlSignDouble impl (it's much faster in js than using Long) --- gradle.properties | 2 +- gradle/libs.versions.toml | 4 +++- .../kotlin/io/eqoty/secretk/utils/EnigmaUtils.kt | 9 +++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/gradle.properties b/gradle.properties index 776f80c..26476aa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4g # Publishing : Required GROUP=io.eqoty.secretk -VERSION_NAME=1.0.0 +VERSION_NAME=1.1.0-SNAPSHOT POM_ARTIFACT_ID=client # Publishing : Optional diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c935d52..34b39b0 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -17,6 +17,7 @@ kotlin = "1.7.20" ## ⬆ = "1.7.255-SNAPSHOT" ## ⬆ = "1.8.0-Beta" ## ⬆ = "1.8.0-RC" +## ⬆ = "1.8.0-RC2" ## ⬆ = "1.8.255-SNAPSHOT" agp = "7.3.1" ##⬆ = "7.4.0-alpha01" @@ -100,6 +101,7 @@ compose-jb = "1.2.2" ## ⬆ = "1.3.0-beta04-dev883" ## ⬆ = "1.3.0-beta04-dev885" ## ⬆ = "1.3.0-beta04-dev889" +## ⬆ = "1.3.0-beta04-dev897" ## ⬆ = "1.3.0-rc01" bootstrap-compose = "0.1.10" @@ -114,7 +116,7 @@ ripemd160 = "1.1.3-nativempp" slf4j-simple = "2.0.6" siv-mode = "1.4.4" -kryptools="0.1.1" +kryptools="0.2.0" [libraries] diff --git a/secretk/src/commonMain/kotlin/io/eqoty/secretk/utils/EnigmaUtils.kt b/secretk/src/commonMain/kotlin/io/eqoty/secretk/utils/EnigmaUtils.kt index 87c89d9..6b46b86 100644 --- a/secretk/src/commonMain/kotlin/io/eqoty/secretk/utils/EnigmaUtils.kt +++ b/secretk/src/commonMain/kotlin/io/eqoty/secretk/utils/EnigmaUtils.kt @@ -3,8 +3,8 @@ package io.eqoty.secretk.utils import com.ionspin.kotlin.crypto.util.LibsodiumRandom import com.ionspin.kotlin.crypto.util.encodeToUByteArray import io.eqoty.kryptools.aessiv.AesSIV -import io.eqoty.kryptools.axlsign.AxlSign.generateKeyPair -import io.eqoty.kryptools.axlsign.AxlSign.sharedKey +import io.eqoty.kryptools.axlsign.AxlSign +import io.eqoty.kryptools.axlsign.AxlSignDouble import io.eqoty.kryptools.deriveHKDFKey import io.ktor.client.* import io.ktor.client.call.* @@ -67,6 +67,7 @@ class EnigmaUtils internal constructor(val apiUrl: String, val seed: UByteArray) private val siv = AesSIV() + private val axlSign = AxlSignDouble() private val privKey: UByteArray val pubKey: UByteArray @@ -95,7 +96,7 @@ class EnigmaUtils internal constructor(val apiUrl: String, val seed: UByteArray) } fun GenerateNewKeyPairFromSeed(seed: UByteArray): KeyPair { - val keys = generateKeyPair(seed.toIntArray()) + val keys = AxlSignDouble().generateKeyPair(seed.toIntArray()) return KeyPair( keys.privateKey.toUByteArray(), keys.publicKey.toUByteArray() @@ -157,7 +158,7 @@ class EnigmaUtils internal constructor(val apiUrl: String, val seed: UByteArray) override suspend fun getTxEncryptionKey(nonce: UByteArray): UByteArray { val consensusIoPubKey = getConsensusIoPubKey() - val txEncryptionIkm = sharedKey(this.privKey.toIntArray(), consensusIoPubKey.toIntArray()).toUByteArray() + val txEncryptionIkm = axlSign.sharedKey(this.privKey.toIntArray(), consensusIoPubKey.toIntArray()).toUByteArray() return deriveHKDFKey(txEncryptionIkm + nonce, hkdfSalt, len = 32) }