-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ATL-5386: Remove cocoapods so it works on the iOS #87
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need to add this? I don't think it makes a difference :) also I tried doing this and it was giving me an error when I add an If like so inside the
plugins {...}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I've update the code snippet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated to code. This version should work inside the
plugins
block now.