From f97c2be26de419caa5d3d670c76c59b0346ba658 Mon Sep 17 00:00:00 2001 From: Cristian G Date: Mon, 6 Nov 2023 08:25:41 -0500 Subject: [PATCH 1/3] investigate ci --- .../io/iohk/atala/prism/apollo/derivation/HDKey.kt | 11 ++++++++--- .../iohk/atala/prism/apollo/derivation/HDKeyTest.kt | 10 ++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/HDKey.kt b/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/HDKey.kt index b1324d51d..f50b10971 100644 --- a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/HDKey.kt +++ b/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/HDKey.kt @@ -131,6 +131,7 @@ class HDKey( * @param index value used to derive a key */ fun deriveChild(index: BigIntegerWrapper): HDKey { + println("Derive Child iteration") val index = index.value if (chainCode == null) { throw Exception("No chainCode set") @@ -200,9 +201,13 @@ class HDKey( const val MASTER_SECRET = "Atala Prism" fun sha512(key: ByteArray, input: ByteArray): ByteArray { - val sha512 = HmacSHA512(key) - sha512.update(input) - return sha512.doFinal() + try { + val sha512 = HmacSHA512(key) + sha512.update(input) + return sha512.doFinal() + } catch (e: Exception) { + throw Error("Sha512 exception: ${e.message}") + } } } } diff --git a/base-asymmetric-encryption/src/commonTest/kotlin/io/iohk/atala/prism/apollo/derivation/HDKeyTest.kt b/base-asymmetric-encryption/src/commonTest/kotlin/io/iohk/atala/prism/apollo/derivation/HDKeyTest.kt index 369d9aabc..eeaa1d0a5 100644 --- a/base-asymmetric-encryption/src/commonTest/kotlin/io/iohk/atala/prism/apollo/derivation/HDKeyTest.kt +++ b/base-asymmetric-encryption/src/commonTest/kotlin/io/iohk/atala/prism/apollo/derivation/HDKeyTest.kt @@ -124,4 +124,14 @@ class HDKeyTest { val key = hdKey.getKMMSecp256k1PrivateKey() assertNotNull(key) } + + @Test + fun testDeriveChild_whithStackOverflowFromCIConditions_then() { + val seedBase64 = "MfAGRk2g_Yo8M-GUm688h8teXC6JYd39wJ2u6D8ocT-Qn8me8eThJW8i3vWX9vywmMQPj9Xpg9iBhpdaC9ZGgA" + val seed = seedBase64.base64UrlDecodedBytes + val path = "m/1'/0'/0'" + + val hdKey = HDKey(seed, 0, 0) + hdKey.derive(path) + } } From 6bab742d8ae27f9415b212d2afa7362f4d58590d Mon Sep 17 00:00:00 2001 From: Cristian G Date: Mon, 6 Nov 2023 08:27:04 -0500 Subject: [PATCH 2/3] add failing seed to test --- .../kotlin/io/iohk/atala/prism/apollo/derivation/HDKeyTest.kt | 2 +- secp256k1/secp256k1 | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 160000 secp256k1/secp256k1 diff --git a/base-asymmetric-encryption/src/commonTest/kotlin/io/iohk/atala/prism/apollo/derivation/HDKeyTest.kt b/base-asymmetric-encryption/src/commonTest/kotlin/io/iohk/atala/prism/apollo/derivation/HDKeyTest.kt index eeaa1d0a5..8d5e3beb3 100644 --- a/base-asymmetric-encryption/src/commonTest/kotlin/io/iohk/atala/prism/apollo/derivation/HDKeyTest.kt +++ b/base-asymmetric-encryption/src/commonTest/kotlin/io/iohk/atala/prism/apollo/derivation/HDKeyTest.kt @@ -127,7 +127,7 @@ class HDKeyTest { @Test fun testDeriveChild_whithStackOverflowFromCIConditions_then() { - val seedBase64 = "MfAGRk2g_Yo8M-GUm688h8teXC6JYd39wJ2u6D8ocT-Qn8me8eThJW8i3vWX9vywmMQPj9Xpg9iBhpdaC9ZGgA" + val seedBase64 = "FJsDqiu6AIamix8TYsGmE2aDU6zo80NyXiQkuFQnfJ0pSQ8wxr0KfTJLJ9CKrmK9qf25VIv6iXNZM1SRgTlYUQ" val seed = seedBase64.base64UrlDecodedBytes val path = "m/1'/0'/0'" diff --git a/secp256k1/secp256k1 b/secp256k1/secp256k1 new file mode 160000 index 000000000..1b21aa517 --- /dev/null +++ b/secp256k1/secp256k1 @@ -0,0 +1 @@ +Subproject commit 1b21aa51752958138aab3f750afdb7549f82ca89 From bae174df6f579cd0202865d507c0e61d9e7c559e Mon Sep 17 00:00:00 2001 From: Cristian G Date: Mon, 6 Nov 2023 08:33:14 -0500 Subject: [PATCH 3/3] remove secp256k1 folder --- secp256k1/secp256k1 | 1 - 1 file changed, 1 deletion(-) delete mode 160000 secp256k1/secp256k1 diff --git a/secp256k1/secp256k1 b/secp256k1/secp256k1 deleted file mode 160000 index 1b21aa517..000000000 --- a/secp256k1/secp256k1 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1b21aa51752958138aab3f750afdb7549f82ca89