Skip to content

Commit 213184c

Browse files
feat!: move to swift based framework for didcomm, jose and peer did
BREAKING CHANGE: Updated Pluto and Message public interface This changes are required to provide the following. - the old didcomm library didnt allow for extra headers that was essencial to prism mediator - this peer did library is updated with last specifications specs required by the agent and prism mediator - this jose library provides a full implementation of the jose capabilities we require The amount of changes is big because the peer did changes required a few changes on how we process keys and resolve secrets Besides that since the previous libraries were not build in swift, we are actually getting rid of 37MB of framework size
1 parent 392c52c commit 213184c

File tree

62 files changed

+747
-1181
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+747
-1181
lines changed

AtalaPrismSDK/Apollo/Sources/ApolloImpl+KeyRestoration.swift

+26-6
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,22 @@ extension ApolloImpl: KeyRestoration {
2020
guard let index = key.index else {
2121
throw ApolloError.restoratonFailedNoIdentifierOrInvalid
2222
}
23-
return Secp256k1PrivateKey(internalKey: .init(raw: key.storableData.toKotlinByteArray()), derivationPath: DerivationPath(index: index))
23+
return Secp256k1PrivateKey(
24+
identifier: key.identifier,
25+
internalKey: .init(raw: key.storableData.toKotlinByteArray()), derivationPath: DerivationPath(index: index)
26+
)
2427
case "x25519+priv":
25-
return try CreateX25519KeyPairOperation(logger: Self.logger).compute(fromPrivateKey: key.storableData)
28+
return try CreateX25519KeyPairOperation(logger: Self.logger)
29+
.compute(
30+
identifier: key.identifier,
31+
fromPrivateKey: key.storableData
32+
)
2633
case "ed25519+priv":
27-
return try CreateEd25519KeyPairOperation(logger: Self.logger).compute(fromPrivateKey: key.storableData)
34+
return try CreateEd25519KeyPairOperation(logger: Self.logger)
35+
.compute(
36+
identifier: key.identifier,
37+
fromPrivateKey: key.storableData
38+
)
2839
default:
2940
throw ApolloError.restoratonFailedNoIdentifierOrInvalid
3041
}
@@ -34,11 +45,20 @@ extension ApolloImpl: KeyRestoration {
3445
public func restorePublicKey(_ key: StorableKey) throws -> PublicKey {
3546
switch key.restorationIdentifier {
3647
case "secp256k1+pub":
37-
return Secp256k1PublicKey(internalKey: .init(raw: key.storableData.toKotlinByteArray()))
48+
return Secp256k1PublicKey(
49+
identifier: key.identifier,
50+
internalKey: .init(raw: key.storableData.toKotlinByteArray())
51+
)
3852
case "x25519+pub":
39-
return X25519PublicKey(internalKey: .init(raw: key.storableData.toKotlinByteArray()))
53+
return X25519PublicKey(
54+
identifier: key.identifier,
55+
internalKey: .init(raw: key.storableData.toKotlinByteArray())
56+
)
4057
case "ed25519+pub":
41-
return Ed25519PublicKey(internalKey: .init(raw: key.storableData.toKotlinByteArray()))
58+
return Ed25519PublicKey(
59+
identifier: key.identifier,
60+
internalKey: .init(raw: key.storableData.toKotlinByteArray())
61+
)
4262
default:
4363
throw ApolloError.restoratonFailedNoIdentifierOrInvalid
4464
}

AtalaPrismSDK/Apollo/Sources/Model/Ed25519Key.swift

+12-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@ struct Ed25519PrivateKey: PrivateKey {
99
let keySpecifications: [String : String] = [
1010
"curve" : "Ed25519"
1111
]
12+
var identifier: String
1213
var size: Int { raw.count }
1314
var raw: Data { internalKey.raw.toData() }
1415

15-
init(internalKey: ApolloLibrary.KMMEdPrivateKey) {
16+
init(
17+
identifier: String = UUID().uuidString,
18+
internalKey: ApolloLibrary.KMMEdPrivateKey
19+
) {
20+
self.identifier = identifier
1621
self.internalKey = internalKey
1722
}
1823

@@ -53,10 +58,15 @@ struct Ed25519PublicKey: PublicKey {
5358
let keySpecifications: [String : String] = [
5459
"curve" : "Ed25519"
5560
]
61+
var identifier: String
5662
var size: Int { raw.count }
5763
var raw: Data { internalKey.raw.toData() }
5864

59-
init(internalKey: ApolloLibrary.KMMEdPublicKey) {
65+
init(
66+
identifier: String = UUID().uuidString,
67+
internalKey: ApolloLibrary.KMMEdPublicKey
68+
) {
69+
self.identifier = identifier
6070
self.internalKey = internalKey
6171
}
6272

AtalaPrismSDK/Apollo/Sources/Model/LinkSecret.swift

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ struct LinkSecret: Key {
66
let keyType = "LinkSecret"
77
let keySpecifications = [String : String]()
88
let raw: Data
9+
var identifier = "linkSecret"
910
var size: Int { raw.count }
1011

1112
let anoncred: AnoncredsSwift.LinkSecret

AtalaPrismSDK/Apollo/Sources/Model/Secp256k1Key.swift

+14-5
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@ import Foundation
55

66
struct Secp256k1PrivateKey: PrivateKey {
77
private let internalKey: KMMECSecp256k1PrivateKey
8-
98
let keyType: String = "EC"
109
let keySpecifications: [String : String]
1110
let size: Int
1211
let raw: Data
1312
let derivationPath: Domain.DerivationPath
14-
15-
init(internalKey: KMMECSecp256k1PrivateKey, derivationPath: Domain.DerivationPath) {
13+
var identifier: String
14+
15+
init(
16+
identifier: String = UUID().uuidString,
17+
internalKey: KMMECSecp256k1PrivateKey,
18+
derivationPath: Domain.DerivationPath
19+
) {
20+
self.identifier = identifier
1621
self.internalKey = internalKey
1722
self.derivationPath = derivationPath
1823
self.keySpecifications = [
@@ -60,13 +65,17 @@ extension Secp256k1PrivateKey: KeychainStorableKey {
6065

6166
struct Secp256k1PublicKey: PublicKey {
6267
private let internalKey: ApolloLibrary.KMMECSecp256k1PublicKey
63-
6468
let keyType: String = "EC"
6569
let keySpecifications: [String : String]
6670
let size: Int
6771
let raw: Data
72+
var identifier = UUID().uuidString
6873

69-
init(internalKey: ApolloLibrary.KMMECSecp256k1PublicKey) {
74+
init(
75+
identifier: String = UUID().uuidString,
76+
internalKey: ApolloLibrary.KMMECSecp256k1PublicKey
77+
) {
78+
self.identifier = identifier
7079
self.internalKey = internalKey
7180
var specs: [String: String] = [
7281
KeyProperties.curve.rawValue: "secp256k1",

AtalaPrismSDK/Apollo/Sources/Model/X25519Key.swift

+12-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,15 @@ struct X25519PrivateKey: PrivateKey {
88
let keySpecifications: [String : String] = [
99
"curve" : "x25519"
1010
]
11+
var identifier:String
1112
var size: Int { raw.count }
1213
var raw: Data { internalKey.raw.toData() }
1314

14-
init(internalKey: ApolloLibrary.KMMX25519PrivateKey) {
15+
init(
16+
identifier: String = UUID().uuidString,
17+
internalKey: ApolloLibrary.KMMX25519PrivateKey
18+
) {
19+
self.identifier = identifier
1520
self.internalKey = internalKey
1621
}
1722

@@ -41,10 +46,15 @@ struct X25519PublicKey: PublicKey {
4146
let keySpecifications: [String : String] = [
4247
"curve" : "x25519"
4348
]
49+
var identifier: String
4450
var size: Int { raw.count }
4551
var raw: Data { internalKey.raw.toData() }
4652

47-
init(internalKey: ApolloLibrary.KMMX25519PublicKey) {
53+
init(
54+
identifier: String = UUID().uuidString,
55+
internalKey: ApolloLibrary.KMMX25519PublicKey
56+
) {
57+
self.identifier = identifier
4858
self.internalKey = internalKey
4959
}
5060

AtalaPrismSDK/Apollo/Sources/Operations/CreateEd25519KeyPairOperation.swift

+5-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ struct CreateEd25519KeyPairOperation {
1212

1313
}
1414

15-
func compute(fromPrivateKey: Data) throws -> PrivateKey {
16-
return Ed25519PrivateKey(internalKey: KMMEdPrivateKey(raw: fromPrivateKey.toKotlinByteArray()))
15+
func compute(identifier: String = UUID().uuidString, fromPrivateKey: Data) throws -> PrivateKey {
16+
return Ed25519PrivateKey(
17+
identifier: identifier,
18+
internalKey: KMMEdPrivateKey(raw: fromPrivateKey.toKotlinByteArray())
19+
)
1720
}
1821
}

AtalaPrismSDK/Apollo/Sources/Operations/CreateX25519KeyPairOperation.swift

+5-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ struct CreateX25519KeyPairOperation {
1313

1414
}
1515

16-
func compute(fromPrivateKey: Data) throws -> PrivateKey {
16+
func compute(identifier: String = UUID().uuidString, fromPrivateKey: Data) throws -> PrivateKey {
1717
let privateKey = KMMX25519PrivateKey(raw: fromPrivateKey.toKotlinByteArray())
18-
return X25519PrivateKey(internalKey: privateKey)
18+
return X25519PrivateKey(
19+
identifier: identifier,
20+
internalKey: privateKey
21+
)
1922
}
2023
}

AtalaPrismSDK/Castor/Sources/CastorImpl+Public.swift

-18
Original file line numberDiff line numberDiff line change
@@ -129,22 +129,4 @@ extension CastorImpl: Castor {
129129
}
130130
return try await resolver.resolve(did: did)
131131
}
132-
133-
/// getEcnumbasis generates a unique ECNUM basis string for a given DID and key pair. This function may throw an error if the DID or key pair are invalid.
134-
///
135-
/// - Parameters:
136-
/// - did: The DID associated with the key pair
137-
/// - keyPair: The key pair to use for generating the ECNUM basis
138-
/// - Returns: The ECNUM basis string
139-
/// - Throws: An error if the DID or key pair are invalid
140-
public func getEcnumbasis(did: DID, publicKey: PublicKey) throws -> String {
141-
logger.debug(message: "Getting ecnumbasis", metadata: [
142-
.maskedMetadataByLevel(key: "DID", value: did.string, level: .debug)
143-
])
144-
return try CreatePeerDIDOperation(
145-
autenticationPublicKey: publicKey,
146-
agreementPublicKey: publicKey,
147-
services: []
148-
).computeEcnumbasis(did: did, publicKey: publicKey)
149-
}
150132
}

AtalaPrismSDK/Castor/Sources/DID/PeerDID/PeerDID.swift

-65
This file was deleted.

AtalaPrismSDK/Castor/Sources/DID/PeerDID/Types.swift

-66
This file was deleted.

AtalaPrismSDK/Castor/Sources/Helpers/JWK+Helper.swift

-45
This file was deleted.

0 commit comments

Comments
 (0)