-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pollux): add support for sd-jwt
This commit adds support for sd-jwt. Receive issued credentials and present. Fixes ATL-7185 Signed-off-by: goncalo-frade-iohk <[email protected]>
- Loading branch information
1 parent
8e68386
commit afca01b
Showing
29 changed files
with
527 additions
and
258 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
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
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 |
---|---|---|
|
@@ -198,6 +198,8 @@ public extension EdgeAgent { | |
switch offerFormat { | ||
case "prism/jwt": | ||
format = "prism/jwt" | ||
case "vc+sd-jwt": | ||
format = "vc+sd-jwt" | ||
case "anoncreds/[email protected]": | ||
format = "anoncreds/[email protected]" | ||
default: | ||
|
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 |
---|---|---|
|
@@ -44,7 +44,7 @@ public extension EdgeAgent { | |
.linkSecret(id: "", secret: linkSecretString) | ||
] | ||
) | ||
case "prism/jwt", "dif/presentation-exchange/[email protected]": | ||
case "prism/jwt", "vc+sd-jwt", "dif/presentation-exchange/[email protected]": | ||
guard | ||
let subjectDIDString = credential.subject | ||
else { | ||
|
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
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
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 |
---|---|---|
|
@@ -31,7 +31,7 @@ extension JWTCredential: ProvableCredential { | |
switch attachment.format { | ||
case "dif/presentation-exchange/[email protected]": | ||
let requestData = try JSONDecoder.didComm().decode(PresentationExchangeRequest.self, from: jsonData) | ||
let payload = try JWT<DefaultJWTClaimsImpl>.getPayload(jwtString: jwtString) | ||
let payload: Data = try JWT.getPayload(jwtString: jwtString) | ||
do { | ||
try VerifyPresentationSubmission.verifyPresentationSubmissionClaims( | ||
request: requestData.presentationDefinition, credentials: [payload] | ||
|
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
21 changes: 21 additions & 0 deletions
21
EdgeAgentSDK/Pollux/Sources/Models/SDJWT/SDJWT+Codable.swift
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,21 @@ | ||
import Foundation | ||
|
||
extension SDJWTCredential: Codable { | ||
enum CodingKeys: String, CodingKey { | ||
case sdjwtString | ||
} | ||
|
||
func encode(to encoder: any Encoder) throws { | ||
var container = encoder.container(keyedBy: CodingKeys.self) | ||
|
||
try container.encode(sdjwtString, forKey: .sdjwtString) | ||
} | ||
|
||
init(from decoder: any Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
|
||
let sdjwtString = try container.decode(String.self, forKey: .sdjwtString) | ||
|
||
try self.init(sdjwtString: sdjwtString) | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
EdgeAgentSDK/Pollux/Sources/Models/SDJWT/SDJWT+ExportableCredential.swift
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 @@ | ||
import Domain | ||
import Foundation | ||
|
||
extension SDJWTCredential: ExportableCredential { | ||
public var exporting: Data { | ||
(try? sdjwtString.tryToData()) ?? Data() | ||
} | ||
|
||
public var restorationType: String { "sd-jwt" } | ||
} |
16 changes: 16 additions & 0 deletions
16
EdgeAgentSDK/Pollux/Sources/Models/SDJWT/SDJWT+ProvableCredential.swift
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,16 @@ | ||
import Domain | ||
import Foundation | ||
|
||
extension SDJWTCredential: ProvableCredential { | ||
func presentation(request: Domain.Message, options: [Domain.CredentialOperationsOptions]) throws -> String { | ||
try SDJWTPresentation().createPresentation( | ||
credential: self, | ||
request: request, | ||
options: options | ||
) | ||
} | ||
|
||
func isValidForPresentation(request: Domain.Message, options: [Domain.CredentialOperationsOptions]) throws -> Bool { | ||
request.attachments.first.map { $0.format == "vc+sd-jwt"} ?? true | ||
} | ||
} |
Oops, something went wrong.