Skip to content
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

feat(prism-agent): Integrate Verification Flow - ATL-2117 #147

Merged
merged 91 commits into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from 86 commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
f4fcbcf
feat(prism-agent): API for prism-agent
FabioPinheiro Nov 21, 2022
34686ba
WIP
FabioPinheiro Nov 22, 2022
a8169bc
WIP
FabioPinheiro Nov 23, 2022
1b58997
Merge remote-tracking branch 'origin/main' into prism-agent/present-p…
FabioPinheiro Nov 23, 2022
39f7832
refactoring and removing unwanted fields
mineme0110 Nov 24, 2022
97e7f55
chore(castor): Reverte file castor/lib/version.sbt (#169)
FabioPinheiro Nov 24, 2022
fa1223f
Update shared (lib) to 0.2.0
FabioPinheiro Nov 24, 2022
882f168
WIP
FabioPinheiro Nov 24, 2022
d7e9070
remove the field validity_period
mineme0110 Nov 24, 2022
099046c
Merge branch 'prism-agent/present-proof' of iohk.github.com:input-out…
mineme0110 Nov 24, 2022
bb5047f
added OAS mapping
mineme0110 Nov 25, 2022
7635307
WIP
FabioPinheiro Nov 25, 2022
0425683
Compiling
FabioPinheiro Nov 25, 2022
cae3426
wip updated the methods
mineme0110 Nov 25, 2022
9926f1b
wip updated the method definitions with connectionid
mineme0110 Nov 25, 2022
c772dfa
Array
FabioPinheiro Nov 25, 2022
786f585
Fix getAllPresentation
FabioPinheiro Nov 25, 2022
a6aef31
WIP
FabioPinheiro Nov 28, 2022
9481cde
updated the presentation service
mineme0110 Nov 28, 2022
76f64c4
Merge branch 'prism-agent/present-proof' of iohk.github.com:input-out…
mineme0110 Nov 28, 2022
d18073b
WIP
FabioPinheiro Nov 28, 2022
1eec6b8
missing file
FabioPinheiro Nov 28, 2022
ef1dca4
remove oneOf
FabioPinheiro Nov 28, 2022
424464c
Merge remote-tracking branch 'origin/main' into prism-agent/present-p…
FabioPinheiro Nov 28, 2022
a885657
merge still a WIP
FabioPinheiro Nov 28, 2022
ae7a60b
chore(prism-agent): do not link DIDComm service port variable to DIDC…
bvoiturier Nov 29, 2022
cf16131
chore(infra): add docker-compose config for Connect + only expose th …
bvoiturier Nov 29, 2022
6f8c9c8
chore(infra): add HAProxy config for DIDComm service endpoint
bvoiturier Nov 29, 2022
d9ba69f
chore(prism-agent): bump version number to 0.6.0-SNAPSHOT
bvoiturier Nov 29, 2022
f160964
docs(prism-agent): add basic documentation on executing Connect and I…
bvoiturier Nov 29, 2022
ea2dd70
docs(prism-agent): add links in main README.md
bvoiturier Nov 29, 2022
bf30afc
compiling
FabioPinheiro Nov 29, 2022
ea82faf
added checks for did
mineme0110 Nov 29, 2022
be114ca
Merge remote-tracking branch 'origin/feature/issue-connect-doc' into …
mineme0110 Nov 29, 2022
ea8e1d7
added checks for did
mineme0110 Nov 29, 2022
511d268
Merge remote-tracking branch 'origin/main' into prism-agent/present-p…
FabioPinheiro Nov 29, 2022
00840cd
FIX
FabioPinheiro Nov 29, 2022
01af703
chore(prism-agent): fix presentation layer issue
bvoiturier Nov 29, 2022
75a2e1d
Fix
FabioPinheiro Nov 29, 2022
c1e6278
Fix Schema example
FabioPinheiro Nov 29, 2022
0c99f7c
added connectionId
mineme0110 Nov 29, 2022
6bf60fd
added the background jobs and added the fixed the presentation record
mineme0110 Nov 30, 2022
36b38d8
added the reject and accept actions for presentations
mineme0110 Nov 30, 2022
c8c501e
feat(mercury): Update protocol-present-proof to v3 and add our extens…
FabioPinheiro Nov 30, 2022
2a6a5a9
WIP
FabioPinheiro Nov 30, 2022
a5b9e48
TODO
FabioPinheiro Nov 30, 2022
70f7a42
Remove the Option type
FabioPinheiro Nov 30, 2022
dadaaf6
Fix type after update mercury
FabioPinheiro Nov 30, 2022
05643ec
WIP progress compilation issue
mineme0110 Dec 5, 2022
c95b461
Add missing files
FabioPinheiro Dec 5, 2022
e67b8a3
minor fixe
FabioPinheiro Dec 5, 2022
8cd183a
Fix
FabioPinheiro Dec 5, 2022
271406b
Merge remote-tracking branch 'origin/main' into prism-agent/present-p…
FabioPinheiro Dec 5, 2022
999bcfc
Update Dependencies.scala
FabioPinheiro Dec 5, 2022
72dc671
Update Dependencies.scala
FabioPinheiro Dec 5, 2022
00b8d2e
Update Dependencies.scala
FabioPinheiro Dec 5, 2022
673f6ff
Merge remote-tracking branch 'origin/main' into prism-agent/present-p…
FabioPinheiro Dec 6, 2022
9bae75c
feat(pollux): Added the column
mineme0110 Dec 6, 2022
15f314d
feat(pollux): Added the column
mineme0110 Dec 6, 2022
11c062e
Fix local api/http/prism-agent-openapi-spec.yaml
FabioPinheiro Dec 6, 2022
38973c2
Added the missing fields
mineme0110 Dec 6, 2022
60aa2bd
oops again
mineme0110 Dec 6, 2022
cd372f6
Update JdbcCredentialRepository.scala
FabioPinheiro Dec 6, 2022
28da4b6
Update JdbcCredentialRepository.scala
FabioPinheiro Dec 6, 2022
ed65f8b
Update mercury to 0.10.0
FabioPinheiro Dec 6, 2022
4488f52
prism-agent/service/present-proof.md
FabioPinheiro Dec 6, 2022
79a85aa
mapped the proofid
mineme0110 Dec 7, 2022
6d0af39
Merge branch 'prism-agent/present-proof' of iohk.github.com:input-out…
mineme0110 Dec 7, 2022
f7701ad
update prism-agent/service/present-proof.md
FabioPinheiro Dec 7, 2022
aa23649
updated the Present Proof readme
mineme0110 Dec 7, 2022
a504e1c
updated the Present Proof readme
mineme0110 Dec 7, 2022
8c842fd
updated the readme
mineme0110 Dec 8, 2022
e67d6fe
fix the the readme
mineme0110 Dec 8, 2022
e105e56
Merge remote-tracking branch 'origin/main' into prism-agent/present-p…
FabioPinheiro Dec 9, 2022
84c5ff2
Merge remote-tracking branch 'refs/remotes/origin/prism-agent/present…
FabioPinheiro Dec 9, 2022
3167321
cleanup
FabioPinheiro Dec 9, 2022
30b80fe
Fixes to make it compile
FabioPinheiro Dec 9, 2022
a5cbac5
revert infrastructure/local/.env
FabioPinheiro Dec 9, 2022
046c512
cleanup
FabioPinheiro Dec 9, 2022
7f7dd42
cleanup
FabioPinheiro Dec 9, 2022
fdf8f5b
cleanup /pollux/schemas.yaml
FabioPinheiro Dec 9, 2022
1e935c6
more cleanup
FabioPinheiro Dec 9, 2022
9b65951
updated the states and refactoreed the verification
mineme0110 Dec 9, 2022
0c6bead
Merge branch 'prism-agent/present-proof' of iohk.github.com:input-out…
mineme0110 Dec 9, 2022
9eead91
Updated the pollux lib version
mineme0110 Dec 12, 2022
ac9cfca
Merge branch 'main' into prism-agent/present-proof
mineme0110 Dec 12, 2022
6ec531b
Merge branch 'main' into prism-agent/present-proof
FabioPinheiro Dec 12, 2022
aa1218d
scalafmt
mineme0110 Dec 12, 2022
51bd178
fix the scalafmt
mineme0110 Dec 12, 2022
7950b85
fix the service endpoint
mineme0110 Dec 12, 2022
6c395d2
fix the service endpoint
mineme0110 Dec 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mercury/mercury-library/version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ThisBuild / version := "0.7.0-SNAPSHOT"
ThisBuild / version := "0.8.0-SNAPSHOT"
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ object PresentationRecord {
// Prover has "accepted" a Presentation request received from a Verifier (Prover DB)
case PresentationPending extends ProtocolState
// Prover has generated (signed) the VC and is now ready to send it to the Verifier (Prover DB)
case PresentationGenerated extends ProtocolState
// The Presentation has been sent to the Verifier (Prover DB)

//Prover has sent the Presentation (Prover DB)
case PresentationSent extends ProtocolState
// Verifier has received the presentation (Verifier DB)
case PresentationReceived extends ProtocolState
// Verifier has verified the presentation (proof) (Verifier DB)
case PresentationVerified extends ProtocolState
// Verifier has accepted the verified presentation (proof) (Verifier DB)
case PresentationAccepted extends ProtocolState
// Verifier has rejected the presentation (proof) (Verifier DB)
case PresentationRejected extends ProtocolState // TODO send problem report

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,14 @@ trait PresentationService {

def markProposePresentationSent(recordId: UUID): IO[PresentationError, Option[PresentationRecord]]

def markPresentationGenerated(
recordId: UUID,
presentation: Presentation
): IO[PresentationError, Option[PresentationRecord]]

def markPresentationSent(recordId: UUID): IO[PresentationError, Option[PresentationRecord]]

def markPresentationVerified(recordId: UUID): IO[PresentationError, Option[PresentationRecord]]

def markPresentationRejected(recordId: UUID): IO[PresentationError, Option[PresentationRecord]]

def markPresentationAccepted(recordId: UUID): IO[PresentationError, Option[PresentationRecord]]

}

object PresentationServiceImpl {
Expand Down Expand Up @@ -237,7 +234,7 @@ private class PresentationServiceImpl(
): IO[PresentationError, Option[PresentationRecord]] = {

for {
// crecentialsToUse

maybeRecord <- presentationRepository
.getPresentationRecord(recordId)
.mapError(RepositoryError.apply)
Expand All @@ -255,7 +252,6 @@ private class PresentationServiceImpl(
.mapError(RepositoryError.apply)

issuedRawCredentials = issuedValidCredentials.map(_.issuedCredentialRaw.map(IssuedCredentialRaw(_))).flatten
x = List(1)
issuedCredentials <- ZIO.fromEither(
Either.cond(
issuedRawCredentials.nonEmpty,
Expand Down Expand Up @@ -294,9 +290,8 @@ private class PresentationServiceImpl(
presentationRequest <- ZIO
.fromOption(record.presentationData)
.mapError(_ => InvalidFlowStateError(s"No request found for this record: $recordId"))
_ <- ZIO.log(s"************presentationRequest*************$presentationRequest")
_ <- verifyPresentation(presentationRequest) // TODO
recordUpdated <- markPresentationVerified(record.id)

recordUpdated <- markPresentationAccepted(record.id)

} yield recordUpdated
}
Expand Down Expand Up @@ -381,26 +376,13 @@ private class PresentationServiceImpl(
PresentationRecord.ProtocolState.PresentationVerified
)

override def markPresentationGenerated(
recordId: UUID,
presentation: Presentation
): IO[PresentationError, Option[PresentationRecord]] = {
for {
count <- presentationRepository
.updateWithPresentation(
recordId,
presentation,
PresentationRecord.ProtocolState.PresentationGenerated
)
.mapError(RepositoryError.apply)
_ <- count match
case 1 => ZIO.succeed(())
case n => ZIO.fail(RecordIdNotFound(recordId))
record <- presentationRepository
.getPresentationRecord(recordId)
.mapError(RepositoryError.apply)
} yield record
}
override def markPresentationAccepted(recordId: UUID): IO[PresentationError, Option[PresentationRecord]] =
updatePresentationRecordProtocolState(
recordId,
PresentationRecord.ProtocolState.PresentationVerified,
PresentationRecord.ProtocolState.PresentationAccepted
)


override def markPresentationSent(recordId: UUID): IO[PresentationError, Option[PresentationRecord]] =
updatePresentationRecordProtocolState(
Expand Down
3 changes: 2 additions & 1 deletion prism-agent/service/.scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
version = 3.5.9
runner.dialect = scala3

maxColumn = 120
maxColumn = 120
trailingCommas = preserve
8 changes: 6 additions & 2 deletions prism-agent/service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ Basic documentation on how to execute the Connect flow from command line can be
Basic documentation on how to execute the Issue flow from the command line can be found [here](./issue.md).

---
## DID lifecycle flow
Basic documentation on how to execute the basic DID lifecycle from command line can be found [here](./did.md)
## Presnt Proof flow
Basic documentation on how to execute the Present Proof flow from the command line can be found [here](./present-proof.md).


---
## Known limitations

---
204 changes: 190 additions & 14 deletions prism-agent/service/api/http/pollux/schemas.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
components:
schemas:
# Common
# Common
FabioPinheiro marked this conversation as resolved.
Show resolved Hide resolved
InternalServerError:
required:
- msg
Expand Down Expand Up @@ -28,8 +28,8 @@ components:
type: array
items:
type: string
# Schema Registry

# Schema Registry

Proof:
required:
Expand Down Expand Up @@ -224,8 +224,8 @@ components:
items:
$ref: '#/components/schemas/VerificationPolicy'

# Issue Credential Protocol
# Issue Credential Protocol

CreateIssueCredentialRecordRequest:
description: A request to create a new "issue credential record"
required:
Expand Down Expand Up @@ -304,7 +304,7 @@ components:
- Published
jwtCredential:
type: string

IssueCredentialRecordCollection:
description: A collection of issue credential records
required:
Expand All @@ -324,6 +324,126 @@ components:
count:
type: integer

#

W3CCredentialInput:
description: |-
Credential input object based on which the new instance of the verifiable credentials is created.
Object contains the minimal set of the fields required to create the credentials for the given subject.
All other required fields of the verifiable credential depend on the context of the cloud agent
required:
- subjectId
- claims
properties:
schemaId:
type: string
description: "Identity of the Verifiable Credentials Schema associated with this object"
example: "did:example:MDP8AsFhHzhwUvGNuYkX7T;id=06e126d1-fa44-4882-a243-1e326fbe21db;version=1.0"
subjectId:
type: string
description: "Subject DID of the verifiable credentials object"
example: "did:prism:subjectofverifiablecredentials"
validityPeriod:
type: number
description: "The validity period in seconds of the verifiable credential"
example: 3600
claims:
type: object
additionalProperties:
type: string
description: "Clams associated with given credentials object (for now it's just a key/value, later should be more complex"

W3CCredential:
description: "Verifiable Credential Object according to W3C specification"
required: ["id", "type", "issuer", "issuanceDate", "credentialSubject"]
properties:
id:
type: string
description: "Credential id or url that can be used to get the status of revoke the credential"
example: "http://example.edu/credentials/1872"
type:
type: string
description: "Credential type according to W3C specification. Must include VerifiableCredentials and type of concrete credentials"
example: '["VerifiableCredential", "AlumniCredential"]'
issuer:
type: string
description: "Issuer DID"
example: "did:prism:issuerdid"
issuanceDate:
type: string
description: "Datetime in ISO format that corresponds to the date of issuance"
example: "2010-01-01T19:23:24Z"
credentialSubject:
type: object
description: "Credentials subject DID and claims according to the schema object"
additionalProperties:
type: string
example:
id: "did:prism:subject12345"
alumni_of: "University"
degree: "master of openapi specification"
proof:
$ref: "#/components/schemas/W3CProof"

W3CCredentialsPaginated:
description: "Paginated response that contains an array of the credential objects"
properties:
data:
type: array
items:
$ref: "#/components/schemas/W3CCredential"
offset:
type: integer
limit:
type: integer
count:
type: integer

W3CIssuanceBatch:
description: "An issuance batch object that is associated with thelist of verifiable credentials"
properties:
id:
type: string
description: "Issuance batch id"
count:
type: integer
description: "Count of the verifiable credentials object in the batch"
actions:
type: array
items:
$ref: "#/components/schemas/W3CIssuanceBatchAction"

W3CIssuanceBatchAction:
description: "Action performed on the list of credentials associated with the issuance batch"
properties:
action:
description: "Action name"
type: string
enum: ["sign", "issue", "send"]
example: "issue"
id:
description: "Action id for tracking"
type: string
example: "uid"
status:
description: "Action status"
type: string
enum: ["scheduled", "pending", "completed", "failed"]

W3CIssuanceBatchPaginated:
description: "Paginated response that contains an array of the issuance-batch objects"
properties:
data:
type: array
items:
$ref: "#/components/schemas/W3CIssuanceBatch"
offset:
type: integer
limit:
type: integer
count:
type: integer

W3CCredentialStatus:
description: Verifiable Credential revocation status
required:
Expand Down Expand Up @@ -382,17 +502,73 @@ components:
- completed
- failed

W3CPresentationInput:
description: Verifiable Presentation input
ProofRequestAux:
required: [schemaId, trustIssuers]
properties:
schemas:
type: string # TODO: Define the schema for Presentation Input
schemaId:
description: Ex ID card or driving licence
type: string
example: "https://schema.org/Person"
trustIssuers:
description: Issuer that the verifier trust trust
example:
[
"did:web:atalaprism.io/users/testUser",
"did.prism:123",
"did:prism:...",
]
type: array
items:
type: string

W3CPresentation:
description: Verifiable Presentation object
RequestPresentationInput:
description: Request Presentation Input
required: [connectionId, proofs]
properties:
connectionId:
type: string
proofs:
type: array
items:
$ref: "#/components/schemas/ProofRequestAux"
RequestPresentationOutput:
description: Request Presentation Output
required: [presentationId]
properties:
schemas:
type: string # TODO: define the exactly schema for Presentation
presentationId:
description: Ref to the id on the presentation (db ref)
type: string
PresentationStatus:
description: Presentation Status
required: [presentationId, status, proofs]
properties:
presentationId:
type: string
status:
type: string
proofs:
type: array
items:
$ref: "#/components/schemas/ProofRequestAux"
connectionId:
type: string
RequestPresentationAction:
# RequestPresentationActionAccept:
description: Actions on presetations (to update)
required: [action]
properties:
action:
type: string
enum:
- request-accept
- request-reject
- presentation-accept
- presentation-reject
proofId:
description: This is to choose what VCs to use
type: array
items:
type: string

W3CPresentationPaginated:
description: "Paginated response that contains an array of the presentation objects"
Expand Down
Loading