-
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.
feat(ios): removed cocoapods and made all the ios libs as static
This change was needed because ios requires a dependency manager for any dependency. Using cocoapods for internal xcode projects would not work quite right when trying to use Apollo as a framework.
- Loading branch information
1 parent
3e636be
commit d8b1be5
Showing
42 changed files
with
1,123 additions
and
599 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
File renamed without changes.
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
30 changes: 9 additions & 21 deletions
30
...mmetric-encryption/src/iosMain/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,33 +1,21 @@ | ||
package io.iohk.atala.prism.apollo.utils | ||
|
||
import cocoapods.IOHKCryptoKit.Ed25519 | ||
import kotlinx.cinterop.ObjCObjectVar | ||
import kotlinx.cinterop.alloc | ||
import kotlinx.cinterop.memScoped | ||
import kotlinx.cinterop.ptr | ||
import kotlinx.cinterop.value | ||
import platform.Foundation.NSError | ||
import swift.cryptoKit.Ed25519 | ||
|
||
public actual class KMMEdPrivateKey(val raw: ByteArray = Ed25519.createPrivateKey().toByteArray()) { | ||
public actual class KMMEdPrivateKey(val raw: ByteArray = ByteArray(0)) { | ||
|
||
@Throws(RuntimeException::class) | ||
actual fun sign(message: ByteArray): ByteArray { | ||
memScoped { | ||
val errorRef = alloc<ObjCObjectVar<NSError?>>() | ||
val result = Ed25519.signWithPrivateKey(raw.toNSData(), message.toNSData(), errorRef.ptr) | ||
errorRef.value?.let { throw RuntimeException(it.localizedDescription()) } | ||
return result?.toByteArray() ?: throw RuntimeException("Null result") | ||
} | ||
val result = Ed25519.signWithPrivateKey(raw.toNSData(), message.toNSData()) | ||
result.failure()?.let { throw RuntimeException(it.localizedDescription()) } | ||
return result.success()?.toByteArray() ?: throw RuntimeException("Null result") | ||
} | ||
|
||
@Throws(RuntimeException::class) | ||
public fun publicKey(): KMMEdPublicKey { | ||
memScoped { | ||
val errorRef = alloc<ObjCObjectVar<NSError?>>() | ||
val result = Ed25519.publicKeyWithPrivateKey(raw.toNSData(), errorRef.ptr) | ||
errorRef.value?.let { throw RuntimeException(it.localizedDescription()) } | ||
val publicRaw = result?.toByteArray() ?: throw RuntimeException("Null result") | ||
return KMMEdPublicKey(publicRaw) | ||
} | ||
val result = Ed25519.publicKeyWithPrivateKey(raw.toNSData()) | ||
result.failure()?.let { throw RuntimeException(it.localizedDescription()) } | ||
val publicRaw = result.success()?.toByteArray() ?: throw RuntimeException("Null result") | ||
return KMMEdPublicKey(publicRaw) | ||
} | ||
} |
Oops, something went wrong.