-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Javier Ribó <[email protected]>
- Loading branch information
1 parent
93a10dc
commit 8c8fd6c
Showing
6 changed files
with
129 additions
and
71 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
apollo/src/appleTest/kotlin/org/hyperledger/identus/apollo/ed25519/KMMEdKeyPairTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.hyperledger.identus.apollo.ed25519 | ||
|
||
import org.hyperledger.identus.apollo.base64.base64DecodedBytes | ||
import org.hyperledger.identus.apollo.base64.base64UrlDecodedBytes | ||
import org.hyperledger.identus.apollo.base64.base64UrlEncoded | ||
import org.hyperledger.identus.apollo.utils.KMMEdKeyPair | ||
import org.hyperledger.identus.apollo.utils.KMMEdPrivateKey | ||
import org.hyperledger.identus.apollo.utils.KMMEdPublicKey | ||
import kotlin.test.Test | ||
import kotlin.test.assertNotNull | ||
import kotlin.test.assertTrue | ||
|
||
class KMMEdKeyPairTest { | ||
private val rawSK = "M7+EvGp9vjLyx5SQ1xiKhRUN+YQ0kjx6d21WgX8P1hE".base64DecodedBytes | ||
private val rawSKEncoded = rawSK.base64UrlEncoded | ||
|
||
@Test | ||
fun ed_signature_verify() { | ||
val message = "testing".encodeToByteArray() | ||
val edsk = KMMEdPublicKey("z+a8g8i/3yajE/QDIxIF7sP1m/aLKTOfygIuSJanRAg".base64DecodedBytes) | ||
val sig = "zZzeTBYjrpowc+skEMVQSVTzntzXvZGcbBbNY0gHKF6z+e40Q5G3o35lX4Mf0J8iRde/LAn77JdzIh6gQv7hAA".base64DecodedBytes | ||
val verify = edsk.verify(message, sig) | ||
assertTrue(verify) | ||
} | ||
|
||
@Test | ||
fun testGenerateKeyPair() { | ||
val keyPair = KMMEdKeyPair.generateKeyPair() | ||
assertNotNull(keyPair) | ||
assertNotNull(keyPair.privateKey) | ||
assertNotNull(keyPair.publicKey) | ||
} | ||
|
||
@Test | ||
fun testConstructorEncoded() { | ||
val key = KMMEdPrivateKey(rawSKEncoded.base64UrlDecodedBytes) | ||
assertTrue(key.raw contentEquals rawSK) | ||
} | ||
} |
18 changes: 0 additions & 18 deletions
18
apollo/src/appleTest/kotlin/org/hyperledger/identus/apollo/secp256k1/KMMEdKeyPairTest.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
apollo/src/jvmTest/kotlin/org.hyperledger.identus.apollo/ed25519/KMMEdKeyPairTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.hyperledger.identus.apollo.ed25519 | ||
|
||
import org.hyperledger.identus.apollo.base64.base64DecodedBytes | ||
import org.hyperledger.identus.apollo.base64.base64UrlDecodedBytes | ||
import org.hyperledger.identus.apollo.base64.base64UrlEncoded | ||
import org.hyperledger.identus.apollo.utils.KMMEdKeyPair | ||
import org.hyperledger.identus.apollo.utils.KMMEdPrivateKey | ||
import org.hyperledger.identus.apollo.utils.KMMEdPublicKey | ||
import kotlin.test.Test | ||
import kotlin.test.assertNotNull | ||
import kotlin.test.assertTrue | ||
|
||
class KMMEdKeyPairTest { | ||
private val rawMessage = "Hello".encodeToByteArray() | ||
private val rawSK = "M7+EvGp9vjLyx5SQ1xiKhRUN+YQ0kjx6d21WgX8P1hE".base64DecodedBytes | ||
private val rawSKEncoded = rawSK.base64UrlEncoded | ||
private val rawPk = "6kXLIS4a3UAzHm/5XTcvjCTGoAQ+yqPTT0YsM76EeuQ".base64DecodedBytes | ||
private val rawPKEncoded = rawPk.base64UrlEncoded | ||
private val rawSig = "rQHC0fmOclPBFiPVJCK_WJB0NgTAxSqpggPwRotNdncKrhgM2eECtr3j7UBTBmDdPTmpXGwQvyhTRTG8cymeBA".base64UrlDecodedBytes | ||
|
||
@Test | ||
fun ed_signature_verify() { | ||
val message = "testing".encodeToByteArray() | ||
val edsk = KMMEdPublicKey("z+a8g8i/3yajE/QDIxIF7sP1m/aLKTOfygIuSJanRAg".base64DecodedBytes) | ||
val sig = "zZzeTBYjrpowc+skEMVQSVTzntzXvZGcbBbNY0gHKF6z+e40Q5G3o35lX4Mf0J8iRde/LAn77JdzIh6gQv7hAA".base64DecodedBytes | ||
val verify = edsk.verify(message, sig) | ||
assertTrue(verify) | ||
} | ||
|
||
@Test | ||
fun testGenerateKeyPair() { | ||
val keyPair = KMMEdKeyPair.generateKeyPair() | ||
assertNotNull(keyPair) | ||
assertNotNull(keyPair.privateKey) | ||
assertNotNull(keyPair.publicKey) | ||
} | ||
|
||
@Test | ||
fun testConstructorEncoded() { | ||
val key = KMMEdPrivateKey(rawSKEncoded.base64UrlDecodedBytes) | ||
assertTrue(key.raw contentEquals rawSK) | ||
} | ||
|
||
@Test | ||
fun testSignMessageKnownValue() { | ||
val privateKey = KMMEdPrivateKey(rawSK) | ||
val sig = privateKey.sign(rawMessage) | ||
assertNotNull(sig) | ||
assertTrue(sig contentEquals rawSig) | ||
} | ||
} |