-
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.
fix: Invalid signature integer: negative on JS platform (#158)
Signed-off-by: Francisco Javier Ribó Labrador <[email protected]> Co-authored-by: Ahmed Moussa <[email protected]>
- Loading branch information
1 parent
8180fa8
commit 08f8516
Showing
2 changed files
with
35 additions
and
3 deletions.
There are no files selected for viewing
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
24 changes: 24 additions & 0 deletions
24
apollo/src/jsTest/kotlin/io/iohk/atala/prism/apollo/utils/Secp256k1LibTestJS.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,24 @@ | ||
package io.iohk.atala.prism.apollo.utils | ||
|
||
import io.iohk.atala.prism.apollo.derivation.Mnemonic | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
class Secp256k1LibTestJS { | ||
|
||
@Test | ||
fun testCreateApolloSignatureAndVerify() { | ||
val mnemonics = Mnemonic.Companion.createRandomMnemonics() | ||
val seed = Mnemonic.Companion.createSeed(mnemonics) | ||
val secret = seed.slice(0..31).toTypedArray() | ||
val sk = KMMECSecp256k1PrivateKey.Companion.secp256k1FromByteArray(secret.toByteArray()) | ||
val pk = sk.getPublicKey() | ||
val data = "Data 0002".encodeToByteArray() | ||
val signature = sk.sign(data) | ||
val verified = pk.verify(signature, data) | ||
assertEquals( | ||
verified, | ||
true | ||
) | ||
} | ||
} |