-
Notifications
You must be signed in to change notification settings - Fork 5
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
Showing
7 changed files
with
119 additions
and
15 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
34 changes: 34 additions & 0 deletions
34
apollo/src/androidMain/kotlin/io/iohk/atala/prism/walletsdk/apollo/helpers/X25519.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,34 @@ | ||
package io.iohk.atala.prism.walletsdk.apollo.helpers | ||
|
||
import io.iohk.atala.prism.walletsdk.domain.models.Curve | ||
import io.iohk.atala.prism.walletsdk.domain.models.KeyCurve | ||
import io.iohk.atala.prism.walletsdk.domain.models.KeyPair | ||
import io.iohk.atala.prism.walletsdk.domain.models.PrivateKey | ||
import io.iohk.atala.prism.walletsdk.domain.models.PublicKey | ||
import org.bouncycastle.jcajce.spec.XDHParameterSpec | ||
import org.bouncycastle.jce.provider.BouncyCastleProvider | ||
import java.security.KeyPairGenerator | ||
|
||
/** | ||
* X25519 | ||
*/ | ||
actual object X25519 { | ||
|
||
actual fun createKeyPair(): KeyPair { | ||
val provider = BouncyCastleProvider() | ||
val kpg = KeyPairGenerator.getInstance("X25519", provider) | ||
kpg.initialize(XDHParameterSpec(XDHParameterSpec.X25519)) | ||
val javaKeyPair = kpg.generateKeyPair() | ||
return KeyPair( | ||
KeyCurve(Curve.X25519), | ||
PrivateKey( | ||
KeyCurve(Curve.X25519), | ||
javaKeyPair.private.encoded | ||
), | ||
PublicKey( | ||
KeyCurve(Curve.X25519), | ||
javaKeyPair.public.encoded | ||
) | ||
) | ||
} | ||
} |
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.walletsdk.apollo/helpers/X25519.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,10 @@ | ||
package io.iohk.atala.prism.walletsdk.apollo.helpers | ||
|
||
import io.iohk.atala.prism.walletsdk.domain.models.KeyPair | ||
|
||
/** | ||
* X25519 | ||
*/ | ||
expect object X25519 { | ||
fun createKeyPair(): KeyPair | ||
} |
12 changes: 12 additions & 0 deletions
12
apollo/src/jsMain/kotlin/io/iohk/atala/prism/walletsdk/apollo/helpers/X25519.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,12 @@ | ||
package io.iohk.atala.prism.walletsdk.apollo.helpers | ||
|
||
import io.iohk.atala.prism.walletsdk.domain.models.KeyPair | ||
|
||
/** | ||
* X25519 | ||
*/ | ||
actual object X25519 { | ||
actual fun createKeyPair(): KeyPair { | ||
throw NotImplementedError() | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
apollo/src/jvmMain/kotlin/io/iohk/atala/prism/walletsdk/apollo/helpers/X25519.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,34 @@ | ||
package io.iohk.atala.prism.walletsdk.apollo.helpers | ||
|
||
import io.iohk.atala.prism.walletsdk.domain.models.Curve | ||
import io.iohk.atala.prism.walletsdk.domain.models.KeyCurve | ||
import io.iohk.atala.prism.walletsdk.domain.models.KeyPair | ||
import io.iohk.atala.prism.walletsdk.domain.models.PrivateKey | ||
import io.iohk.atala.prism.walletsdk.domain.models.PublicKey | ||
import org.bouncycastle.jcajce.spec.XDHParameterSpec | ||
import org.bouncycastle.jce.provider.BouncyCastleProvider | ||
import java.security.KeyPairGenerator | ||
|
||
/** | ||
* X25519 | ||
*/ | ||
actual object X25519 { | ||
|
||
actual fun createKeyPair(): KeyPair { | ||
val provider = BouncyCastleProvider() | ||
val kpg = KeyPairGenerator.getInstance("X25519", provider) | ||
kpg.initialize(XDHParameterSpec(XDHParameterSpec.X25519)) | ||
val javaKeyPair = kpg.generateKeyPair() | ||
return KeyPair( | ||
KeyCurve(Curve.X25519), | ||
PrivateKey( | ||
KeyCurve(Curve.X25519), | ||
javaKeyPair.private.encoded | ||
), | ||
PublicKey( | ||
KeyCurve(Curve.X25519), | ||
javaKeyPair.public.encoded | ||
) | ||
) | ||
} | ||
} |