@startuml
skinparam ParticipantPadding 20
skinparam BoxPadding 20

title Libindy anoncreds
scale 0.9


box "Issuer" #LightBlue
participant "Walleted Issuer" as IW
actor Issuer as I
endbox

box "Prover"
actor Prover as P
participant "Walleted Prover" as PW
endbox

actor Verifier as V

participant "Ledger" as L


note over IW, L #white
    dashed arrows: a value from Ledger may be cached (in wallet?)
    <b>bold text</b>: anoncreds libindy API call
    <font color=red>red:</font> internal communication with walleted entity
    <font color=green>green:</font> submit/get to/from secure wallet
    <font color=blue>blue:</font> submit/get to/from Ledger
    black: communication between Issuer/Prover/Verifier

endnote


=== Create Claim Definition ==
I -> IW: <b>1. indy_issuer_create_and_store_claim_def
IW -[#green]> IW: store keys
IW -> I: <claim_def, claim_def_uuid>

I-[#blue]>L: send CLAIM_DEF txn
L-[#blue]>I: <claim definitions's seq_no>

I -> IW: <b>2. indy_wallet_set_seq_no_for_value
IW -[#green]> IW: update claim_def seq_no

=== Create Revocation Registry ==

I -> IW: <b>3. indy_issuer_create_and_store_revoc_reg
IW -[#green]> IW: get keys
IW -[#green]> IW: store revoc reg
IW -> I: <revoc_reg, revoc_reg_uuid>

I-[#blue]>L: send REVOC_REG txn
L-[#blue]>I: <revoc_reg's seq_no>

I -> IW: <b>4. indy_wallet_set_seq_no_for_value
IW -[#green]> IW: update revpc_reg seq_no

=== Create Master secret ==

P -> PW: <b>5.indy_prover_create_master_secret
PW -[#green]> PW: store master secret

=== Send Claim Offer ==

I -[#black]> P: send claim offer
P -> PW: <b> 6. indy_prover_store_claim_offer
PW -[#green]> PW: store claim offers

=== Show Claim Offers in UI ==

P -> PW: <b>7.indy_prover_get_claim_offers
PW -[#green]> PW: get claim offers
PW -> P: <claim_offers>
P -> P: show on UI

=== Request and Issue Claims ==
P -[#blue]-> L: send GET_CLAIM_DEF req
L -[#blue]-> P: <claim definition>

P -> PW: <b>8.indy_prover_create_and_store_claim_req
PW -[#green]> PW: get master secret
PW -[#green]> PW: store claim_req
PW -> P: <claim_req>

P -[#black]> I: send claim request

I -> IW: <b>9. indy_issuer_create_claim
IW -[#green]> IW: get keys
IW -[#green]> IW: get revoc reg
IW -> I: <update revoc reg>, <claim>

I -[#blue]> L: send REVOC_REG_UPDATE txn
I -[#black]> P: send claim

P -> PW: <b>10.indy_prover_store_claim
PW -[#green]> PW: get claim request
PW -[#green]> PW: store claim

=== Show Claims on UI ==
P -> PW: <b>11. indy_prover_get_claims
PW -[#green]> PW: get claims
PW -> P: <claims>
P -> P: show on UI

=== Present Claim to 3d Party (proof request)==

V -[#black]> P: send proof request
|||
P -> PW: <b>12.indy_prover_get_claims_for_proof_req
PW -> P: <claims for proof request>
P -> P: show on UI
P -> P: select claims for the proof
|||
P -[#blue]-> L: send GET_SCHEMA req
L -[#blue]-> P: <schema>
P -[#blue]-> L: send GET_CLAIM_DEF req
L -[#blue]-> P: <claim_def>
P -[#blue]-> L: send GET_REVOC_REG req
L -[#blue]-> P: <revoc_reg>
|||
P -> PW: <b>13.indy_prover_create_proof
PW -[#green]> PW: get claim
PW -> P: <proof>
|||
P -[#black]> V: send proof
|||
V -[#blue]-> L: send GET_SCHEMA req
L -[#blue]-> V: <schema>
V -[#blue]-> L: send GET_CLAIM_DEF req
L -[#blue]-> V: <claim_def>
V -[#blue]-> L: send GET_REVOC_REG req
L -[#blue]-> V: <revoc_reg>
|||
V -> V: <b>14. indy_verifier_verify_proof

=== Revoke Claims ==
I -> IW: <b>15. indy_issuer_revoke_claim
IW -[#green]> IW: get keys
IW -[#green]> IW: get revoc reg
IW -> I: <update revoc reg>
I -[#blue]> L: send REVOC_REG_UPDATE txn

@enduml
