From 41f29539910d64c7bd2fe536f2a7420dfc8f4846 Mon Sep 17 00:00:00 2001 From: Cristian G Date: Tue, 25 Apr 2023 12:30:27 -0400 Subject: [PATCH] fix: Implement test for key pair creation using mnemonics and seed for curve SECP256K1 --- .../iohk/atala/prism/walletsdk/apollo/ApolloTests.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/apollo/ApolloTests.kt b/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/apollo/ApolloTests.kt index 68e7c9832..340f6b196 100644 --- a/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/apollo/ApolloTests.kt +++ b/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/apollo/ApolloTests.kt @@ -1,5 +1,6 @@ package io.iohk.atala.prism.walletsdk.apollo +import io.iohk.atala.prism.apollo.base64.base64UrlEncoded import io.iohk.atala.prism.apollo.derivation.MnemonicChecksumException import io.iohk.atala.prism.apollo.derivation.MnemonicLengthException import io.iohk.atala.prism.apollo.utils.ECConfig @@ -116,4 +117,15 @@ class ApolloTests { assertEquals(32, privateKey.value.size) assertEquals(32, publicKey.value.size) } + + @Test + fun testCreateKeyPair_whenUsingSeedAndMnemonics_thenKeyPairIsCorrect() { + val mnemonics = arrayOf("blade", "multiply", "coil", "rare", "fox", "doll", "tongue", "please", "icon", "mind", "gesture", "moral", "old", "laugh", "symptom", "assume", "burden", "appear", "always", "oil", "ticket", "vault", "return", "height") + val seed = apollo.createSeed(mnemonics, "") + + val expectedPrivateKeyBase64Url = "xURclKhT6as1Tb9vg4AJRRLPAMWb9dYTTthDvXEKjMc" + + val keyPair = apollo.createKeyPair(seed, KeyCurve(Curve.SECP256K1)) + assertEquals(expectedPrivateKeyBase64Url, keyPair.privateKey.value.base64UrlEncoded) + } }