-
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.
- Loading branch information
1 parent
6b8299b
commit 7f16819
Showing
14 changed files
with
167 additions
and
0 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
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
45 changes: 45 additions & 0 deletions
45
apollo/src/commonMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Lib.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 |
---|---|---|
@@ -1,15 +1,60 @@ | ||
package io.iohk.atala.prism.apollo.secp256k1 | ||
|
||
/** | ||
* This class provides various Secp256k1 cryptographic functionalities such as creating public keys, signing data, | ||
* verifying signatures, and compressing or decompressing public keys. | ||
*/ | ||
expect class Secp256k1Lib constructor() { | ||
/** | ||
* Creates a public key from a given private key. | ||
* | ||
* @param privateKey The private key in byte array format. | ||
* @param compressed A boolean indicating whether the public key should be compressed. | ||
* @return A byte array representing the public key. | ||
*/ | ||
fun createPublicKey(privateKey: ByteArray, compressed: Boolean): ByteArray | ||
|
||
/** | ||
* Derives a new private key from an existing private key and derived bytes. | ||
* | ||
* @param privateKeyBytes The original private key in byte array format. | ||
* @param derivedPrivateKeyBytes The byte array used for deriving the new private key. | ||
* @return A byte array representing the derived private key, or null if derivation fails. | ||
*/ | ||
fun derivePrivateKey(privateKeyBytes: ByteArray, derivedPrivateKeyBytes: ByteArray): ByteArray? | ||
|
||
/** | ||
* Signs data using a given private key. | ||
* | ||
* @param privateKey The private key used for signing, in byte array format. | ||
* @param data The data to be signed, in byte array format. | ||
* @return A byte array representing the signature. | ||
*/ | ||
fun sign(privateKey: ByteArray, data: ByteArray): ByteArray | ||
|
||
/** | ||
* Verifies a signature against a public key and data. | ||
* | ||
* @param publicKey The public key in byte array format. | ||
* @param signature The signature to be verified, in byte array format. | ||
* @param data The data against which the signature will be verified, in byte array format. | ||
* @return A boolean indicating whether the signature is valid. | ||
*/ | ||
fun verify(publicKey: ByteArray, signature: ByteArray, data: ByteArray): Boolean | ||
|
||
/** | ||
* Decompresses a compressed public key. | ||
* | ||
* @param compressed The compressed public key in byte array format. | ||
* @return A byte array representing the uncompressed public key. | ||
*/ | ||
fun uncompressPublicKey(compressed: ByteArray): ByteArray | ||
|
||
/** | ||
* Compresses an uncompressed public key. | ||
* | ||
* @param uncompressed The uncompressed public key in byte array format. | ||
* @return A byte array representing the compressed public key. | ||
*/ | ||
fun compressPublicKey(uncompressed: ByteArray): ByteArray | ||
} |
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
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
10 changes: 10 additions & 0 deletions
10
apollo/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPrivateKey.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 |
---|---|---|
@@ -1,5 +1,15 @@ | ||
package io.iohk.atala.prism.apollo.utils | ||
|
||
/** | ||
* Definition of the KMMEdPrivateKey functionality | ||
*/ | ||
public expect class KMMEdPrivateKey { | ||
|
||
/** | ||
* Method to sign a message using this KMMEdPrivateKey | ||
* | ||
* @param message ByteArray representing the message to be signed | ||
* @return ByteArray representing the signed message | ||
*/ | ||
fun sign(message: ByteArray): ByteArray | ||
} |
11 changes: 11 additions & 0 deletions
11
apollo/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPublicKey.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 |
---|---|---|
@@ -1,5 +1,16 @@ | ||
package io.iohk.atala.prism.apollo.utils | ||
|
||
/** | ||
* Definition of the KMMEdPublicKey functionality | ||
*/ | ||
public expect class KMMEdPublicKey { | ||
|
||
/** | ||
* Method to verify a signature against the original message | ||
* | ||
* @param message ByteArray representing the original message | ||
* @param sig ByteArray representing the signed message | ||
* @return Boolean that tell us if the signature matches the original message | ||
*/ | ||
fun verify(message: ByteArray, sig: ByteArray): Boolean | ||
} |
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
3 changes: 3 additions & 0 deletions
3
apollo/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PrivateKey.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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
package io.iohk.atala.prism.apollo.utils | ||
|
||
/** | ||
* Definition of the KMMX25519PrivateKey functionality | ||
*/ | ||
expect class KMMX25519PrivateKey |
3 changes: 3 additions & 0 deletions
3
apollo/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PublicKey.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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
package io.iohk.atala.prism.apollo.utils | ||
|
||
/** | ||
* Definition of the KMMX25519PublicKey functionality | ||
*/ | ||
expect class KMMX25519PublicKey |
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