Skip to content

Commit

Permalink
use AxlSignDouble impl (it's much faster in js than using Long)
Browse files Browse the repository at this point in the history
  • Loading branch information
luca992 committed Dec 21, 2022
1 parent fc540b6 commit 1eab8a3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"

Expand All @@ -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]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit 1eab8a3

Please sign in to comment.