Skip to content

Commit

Permalink
refactor: remove dependency leaks (#177)
Browse files Browse the repository at this point in the history
Signed-off-by: Cristian G <[email protected]>
  • Loading branch information
cristianIOHK authored Jul 30, 2024
1 parent 6df6a61 commit 6b1e7b9
Show file tree
Hide file tree
Showing 40 changed files with 388 additions and 491 deletions.

Large diffs are not rendered by default.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ import org.hyperledger.identus.walletsdk.domain.models.keyManagement.PublicKey
import org.hyperledger.identus.walletsdk.domain.models.keyManagement.RawKey
import org.hyperledger.identus.walletsdk.domain.models.keyManagement.SeedKey
import org.hyperledger.identus.walletsdk.domain.models.keyManagement.StorableKey
import org.hyperledger.identus.walletsdk.domain.models.keyManagement.StorablePrivateKey
import org.hyperledger.identus.walletsdk.domain.models.keyManagement.TypeKey
import org.hyperledger.identus.walletsdk.pluto.StorablePrivateKey

/**
* Apollo defines the set of cryptographic operations that are used in the Atala PRISM.
Expand Down Expand Up @@ -462,6 +462,11 @@ class ApolloImpl : Apollo {
* @param storablePrivateKey The StorablePrivateKey to restore the key from.
* @return The restored Key object.
*/
@Deprecated(
"This method has been deprecated and should no longer be used.",
ReplaceWith("restorePrivateKey(restoreIdentifier, privateKeyData)"),
DeprecationLevel.ERROR
)
override fun restorePrivateKey(storablePrivateKey: StorablePrivateKey): PrivateKey {
return when (storablePrivateKey.restorationIdentifier) {
"secp256k1+priv" -> {
Expand All @@ -481,4 +486,31 @@ class ApolloImpl : Apollo {
}
}
}

/**
* Restores a private key from StorablePrivateKey.
*
* @param restorationIdentifier The restoration identifier to know which type of key it is.
* @param privateKeyData The private key data encoded in bas64 to restore a private key.
* @return The restored Key object.
*/
override fun restorePrivateKey(restorationIdentifier: String, privateKeyData: String): PrivateKey {
return when (restorationIdentifier) {
"secp256k1+priv" -> {
Secp256k1PrivateKey(privateKeyData.base64UrlDecodedBytes)
}

"ed25519+priv" -> {
Ed25519PrivateKey(privateKeyData.base64UrlDecodedBytes)
}

"x25519+priv" -> {
X25519PrivateKey(privateKeyData.base64UrlDecodedBytes)
}

else -> {
throw PlutoError.InvalidRestorationIdentifier()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import org.hyperledger.identus.walletsdk.domain.models.DID
import org.hyperledger.identus.walletsdk.domain.models.DIDDocument
import org.hyperledger.identus.walletsdk.domain.models.DIDDocumentCoreProperty
import org.hyperledger.identus.walletsdk.domain.models.DIDResolver
import org.hyperledger.identus.walletsdk.domain.models.KeyValue
import org.hyperledger.identus.walletsdk.domain.models.httpClient
import org.hyperledger.identus.walletsdk.edgeagent.shared.KeyValue

class PrismDIDApiResolver(
private val apollo: Apollo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ const val NBF = "nbf"
const val EXP = "exp"
const val JTI = "jti"
const val OKP = "OKP"
const val DIDCOMM_MESSAGING = "DIDCommMessaging"
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import org.hyperledger.identus.walletsdk.domain.models.PeerDID
import org.hyperledger.identus.walletsdk.domain.models.PrismDIDInfo
import org.hyperledger.identus.walletsdk.domain.models.StorableCredential
import org.hyperledger.identus.walletsdk.domain.models.keyManagement.StorableKey
import org.hyperledger.identus.walletsdk.domain.models.keyManagement.StorablePrivateKey
import org.hyperledger.identus.walletsdk.pluto.CredentialRecovery
import org.hyperledger.identus.walletsdk.pluto.StorablePrivateKey
import org.hyperledger.identus.walletsdk.pluto.backup.models.BackupV0_0_1
import org.hyperledger.identus.walletsdk.pluto.data.AvailableClaims
import org.hyperledger.identus.walletsdk.pollux.models.CredentialRequestMeta
Expand Down Expand Up @@ -109,25 +109,24 @@ interface Pluto {
/**
* Stores the metadata associated with a credential request.
*
* @param name the unique name used to retrieve the stored metadata.
* @param metadata The metadata to store. It must be an instance of [CredentialRequestMeta].
*
* @deprecated This method has been deprecated and should no longer be used.
* @see storeCredentialMetadata("", metadata) for the replacement method that should be used.
*/
@Deprecated(
"This method has been deprecated and should no longer be used.",
ReplaceWith("storeCredentialMetadata(\"\", metadata)"),
ReplaceWith("storeCredentialMetadata(name, linkSecretName, json)"),
DeprecationLevel.ERROR
)
fun storeCredentialMetadata(metadata: CredentialRequestMeta)
fun storeCredentialMetadata(name: String, metadata: CredentialRequestMeta)

/**
* Stores the metadata associated with a credential request.
*
* @param name the unique name used to retrieve the stored metadata.
* @param metadata The metadata to store. It must be an instance of [CredentialRequestMeta].
* @param linkSecretName The link secret name as String.
* @param json The json string.
*/
fun storeCredentialMetadata(name: String, metadata: CredentialRequestMeta)
fun storeCredentialMetadata(name: String, linkSecretName: String, json: String)

/**
* Retrieves all PrismDIDs and their associated information.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import org.hyperledger.identus.walletsdk.domain.models.DIDDocumentCoreProperty
import org.hyperledger.identus.walletsdk.domain.models.PresentationClaims
import org.hyperledger.identus.walletsdk.domain.models.StorableCredential
import org.hyperledger.identus.walletsdk.domain.models.keyManagement.PrivateKey
import org.hyperledger.identus.walletsdk.edgeagent.protocols.proofOfPresentation.PresentationDefinitionRequest
import org.hyperledger.identus.walletsdk.edgeagent.protocols.proofOfPresentation.PresentationOptions
import org.hyperledger.identus.walletsdk.edgeagent.protocols.proofOfPresentation.PresentationSubmission
import org.hyperledger.identus.walletsdk.edgeagent.protocols.proofOfPresentation.PresentationSubmissionOptions
import java.security.interfaces.ECPublicKey

Expand Down Expand Up @@ -153,16 +151,16 @@ interface Pollux {
type: CredentialType,
presentationClaims: PresentationClaims,
options: PresentationOptions
): PresentationDefinitionRequest
): String

suspend fun createPresentationSubmission(
presentationDefinitionRequest: PresentationDefinitionRequest,
presentationDefinitionRequestString: String,
credential: Credential,
privateKey: PrivateKey
): PresentationSubmission
): String

suspend fun verifyPresentationSubmission(
presentationSubmission: PresentationSubmission,
presentationSubmissionString: String,
options: PresentationSubmissionOptions
): Boolean

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.hyperledger.identus.walletsdk.domain.models

import org.hyperledger.identus.walletsdk.edgeagent.shared.KeyValue
import io.ktor.client.HttpClient as KtorClient

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import io.ktor.client.request.request
import io.ktor.client.statement.bodyAsText
import io.ktor.http.HttpMethod
import io.ktor.http.Url
import org.hyperledger.identus.walletsdk.edgeagent.shared.KeyValue
import org.hyperledger.identus.walletsdk.edgeagent.shared.PrismShared

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.hyperledger.identus.walletsdk.edgeagent.shared
package org.hyperledger.identus.walletsdk.domain.models

import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.hyperledger.identus.walletsdk.domain.models.keyManagement

import org.hyperledger.identus.walletsdk.pluto.StorablePrivateKey

/**
* This interface defines the functionality to verify and restore cryptographic keys
*/
Expand Down Expand Up @@ -52,5 +50,19 @@ interface KeyRestoration {
* @param storablePrivateKey The StorablePrivateKey to restore the key from.
* @return The restored Key object.
*/
@Deprecated(
"This method has been deprecated and should no longer be used.",
ReplaceWith("restorePrivateKey(restoreIdentifier, privateKeyData)"),
DeprecationLevel.ERROR
)
fun restorePrivateKey(storablePrivateKey: StorablePrivateKey): PrivateKey

/**
* Restores a private key using a restoration identifier and private key data encoded in base 64.
*
* @param restorationIdentifier The restoration identifier to know which type of key it is.
* @param privateKeyData The private key data encoded in bas64 to restore a private key.
* @return The restored Key object.
*/
fun restorePrivateKey(restorationIdentifier: String, privateKeyData: String): PrivateKey
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.hyperledger.identus.walletsdk.pluto
package org.hyperledger.identus.walletsdk.domain.models.keyManagement

data class StorablePrivateKey(
val id: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.hyperledger.identus.walletsdk.edgeagent

const val DIDCOMM1 = "#didcomm-1"
const val DIDCOMM_MESSAGING = "DIDCommMessaging"
const val PRISM = "prism"
const val JWT_MEDIA_TYPE = "prism/jwt"
const val SDJWT_MEDIA_TYPE = "vc+sd-jwt"
Expand Down
Loading

0 comments on commit 6b1e7b9

Please sign in to comment.