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

fix: Compress and uncompress functionality for Android not implemented #102

Closed
wants to merge 5 commits into from
Closed
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
@@ -1,7 +1,15 @@
package io.iohk.atala.prism.apollo.secp256k1

import com.ionspin.kotlin.bignum.integer.BigInteger
import fr.acinq.secp256k1.Secp256k1
import io.iohk.atala.prism.apollo.hashing.SHA256
import io.iohk.atala.prism.apollo.utils.ECConfig
import io.iohk.atala.prism.apollo.utils.KMMECPoint
import io.iohk.atala.prism.apollo.utils.KMMECSecp256k1PublicKey
import io.iohk.atala.prism.apollo.utils.KMMEllipticCurve
import io.iohk.atala.prism.apollo.utils.toKotlinBigInteger
import org.bouncycastle.jce.ECNamedCurveTable
import java.security.spec.ECPoint

actual class Secp256k1Lib {
actual fun createPublicKey(privateKey: ByteArray, compressed: Boolean): ByteArray {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ interface KMMECSecp256k1PublicKeyCommonStaticInterface {
require(encoded.size == 33 || encoded.size == 65) {
"Encoded byte array's expected length is 33 (compressed) or 65 (uncompressed), but got ${encoded.size} bytes"
}

return if (encoded[0].toInt() != 0x04) {
KMMECSecp256k1PublicKey(Secp256k1Lib().uncompressPublicKey(encoded))
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,16 @@ class MnemonicTests {

assertEquals(derived.size, 64)
}

@Test
fun testCreateSeedWithPW2() {
val mnemonics = "tool knock nerve skate detail early limit energy foam garage resource boring traffic violin cave place accuse can bring bring cargo clip stick dog"
val c = 2048
val dklen = 64
val passphrase = "mnemonic"

val derived = PBKDF2SHA512.derive(mnemonics, passphrase, c, dklen)

assertEquals(derived.size, 64)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.iohk.atala.prism.apollo.secp256k1

import fr.acinq.secp256k1.Secp256k1Native
import io.iohk.atala.prism.apollo.hashing.SHA256
import io.iohk.atala.prism.apollo.utils.KMMECPoint

actual class Secp256k1Lib {
actual fun createPublicKey(privateKey: ByteArray, compressed: Boolean): ByteArray {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@ import com.ionspin.kotlin.bignum.integer.BigInteger
import io.iohk.atala.prism.apollo.hashing.SHA256
import io.iohk.atala.prism.apollo.hashing.internal.toHexString
import io.iohk.atala.prism.apollo.utils.ECConfig
import io.iohk.atala.prism.apollo.utils.KMMECPoint
import io.iohk.atala.prism.apollo.utils.KMMECSecp256k1PrivateKey
import io.iohk.atala.prism.apollo.utils.KMMECSecp256k1PublicKey
import io.iohk.atala.prism.apollo.utils.asByteArray
import io.iohk.atala.prism.apollo.utils.asUint8Array
import io.iohk.atala.prism.apollo.utils.decodeHex
import io.iohk.atala.prism.apollo.utils.external.BN
import io.iohk.atala.prism.apollo.utils.external.ec
import io.iohk.atala.prism.apollo.utils.external.secp256k1.getPublicKey
import node.buffer.Buffer
import org.khronos.webgl.Uint8Array
import org.khronos.webgl.get

actual class Secp256k1Lib actual constructor() {
actual fun createPublicKey(privateKey: ByteArray, compressed: Boolean): ByteArray {
Expand Down
Loading