openwallet-foundation / acapy

ACA-Py is a foundation for building decentralized identity applications and services running in non-mobile environments.
https://aca-py.org
Apache License 2.0
421 stars 515 forks source link

GET /credentials/{id} not working #163

Closed SmithSamuelM closed 5 years ago

SmithSamuelM commented 5 years ago

I successfully issued from Faber to Alice a credential and stored a credential on Alice. aca-py v 0.3.1

On Alice's Swagger interface

GET /credentials/ returns

{ "results": [ { "referent": "c45c1565-b8fb-479d-a6fa-5bdc1895f7d2", "attrs": { "name": "Alice Jones" }, "schema_id": "3avoBCqDMFHFaKUHug9s8W:2:fabername:0.1.0", "cred_def_id": "3avoBCqDMFHFaKUHug9s8W:3:CL:15:default", "rev_reg_id": null, "cred_rev_id": null } ] }

But GET /credentials/{id}

always returns 404

I tried 3avoBCqDMFHFaKUHug9s8W:3:CL:15:default

and also dug into the credential exchange record to get the cred-exchange-id
e05d6438-5d47-4360-a2ec-db7f920726e4

But neither of them work. So its undocumented what id it is looking for.

SmithSamuelM commented 5 years ago

Figured out the problem. The credential record returns 3 IDs related to a credential. These are

"cred_def_id": "3avoBCqDMFHFaKUHug9s8W:3:CL:13:default"

"credential_exchange_id": "e4abc052-1425-4a7f-a035-fbec52b77b51"

"credential_id": "64ea2e85-c70f-45ad-b609-68bc1ac89816"

In another issue I asked one of the BC Gov Devs which credential ID to use the answer was use the credential_exchange_id this is wrong. The correct ID to use is the credential_id.

This is highly confusing because GET /credentials does not return either the credential_exchange_id or the credential_id so the only way to use GET /credential/{id} is to find the appropriate credential exchange record and then dig into to find the credential_id which is not reported elsewhere. However this issue is now changed. It does work if use the correct credential_id from the exchange record.

SmithSamuelM commented 5 years ago

Exchange record with three different credential ids

"results": [
    {
      "created_at": "2019-09-09 21:00:08.467886Z",
      "initiator": "external",
      "credential_exchange_id": "e4abc052-1425-4a7f-a035-fbec52b77b51",
      "credential_request_metadata": {
        "master_secret_blinding_data": {
          "v_prime": "25580734226007719690285673224089715210947756454044468005737391256019498565142900277828263161970182996186273934377468144224418589280534476273301002644723537098259996256214980832953033949208365501976663459087111181218226637532787988416486499994639860563284311361784449952636393479872497215003734667873752681289070725092642969303401464732738277243727348239540903402172112946977399574137004144935286618322490493797841870557760202264035690413808953085389886500399195658320315401651498694433204579401762787752112947921749283570170992743412969155300039316506176676970768595131884581398769852610962798494323860958534023360231914463108896217631928135",
          "vr_prime": null
        },
        "nonce": "1019073401153768641589280",
        "master_secret_name": "agent_alice"
      },
      "credential_offer": {
        "schema_id": "3avoBCqDMFHFaKUHug9s8W:2:fabername:0.1.0",
        "cred_def_id": "3avoBCqDMFHFaKUHug9s8W:3:CL:13:default",
        "key_correctness_proof": {
          "c": "50452586530256478209972482632580110767479945289195765941464134003203365225451",
          "xz_cap": "973607954881487358409273087321964720746871162072952177510913234187297225927280855876252151723441411119320043048834816731831213118923767295637785328896761927231897869714139924181121139716060647124476293702710706626713799680288189135217694772391294355295763398519489385683269095653779169047626089990592755512215817359873006828466715349337571162497294317947442321981271120472080778408559215113359921045399188842541820233947817032831827915582902344344113362431152901202437219941785842401853044415888944100501504066520446792648451374624708105995874072359559009927906066114973451692139131088613711167263382544913691523935665743016758255693298414556640012103903148236259339227939350769101437637339140",
          "xr_cap": [
            [
              "name",
              "26798455675766069403184519115903594233992716212390730441572334433630608847896249485252296730702038931435627546540714507061238374324995645094446260826095074517365040323439514918204835166482957607417116126966553798324055153249769285654857636816258873005585623042169792981119262363012857359507934735548766219977295748915134655218695198942004631766425410067003935605224740460854512670653015604445145614014551609498842622890192201205706550469635689759240808145135676280461601163143742246459867239052757867404968369610163351718544659474531578450004192827803415123454459870270520025980739847419930404938771331496356860988931747715442841020191891338025636243657408236839319190943456415728472643849222"
            ],
            [
              "master_secret",
              "1181475898038686351837196807352260845792801338560348802225149492527896370695252704287349701511167948567961120880288320355270212294577996090842505479923199773604638919023308885419067358554139319016902725173490988742266251681275571874764738771274669216077561313806226538433115375187404580921408396690027380571192225608915216168283518249134259952479687900295750395850822109513325985713237268408564593531388801813955320980120456025785676224929876080389189419540921270896707582831627571936551494271264820451553633290732259448481250779194466644089572566611376313515729142299957059058342156963583647683569160567389665882663010526927571779729628949366807560576357915012024388090512433850067178423500543"
            ]
          ]
        },
        "nonce": "759715947375168567892402"
      },
      "credential_definition_id": "3avoBCqDMFHFaKUHug9s8W:3:CL:13:default",
      "raw_credential": {
        "schema_id": "3avoBCqDMFHFaKUHug9s8W:2:fabername:0.1.0",
        "cred_def_id": "3avoBCqDMFHFaKUHug9s8W:3:CL:13:default",
        "rev_reg_id": null,
        "values": {
          "name": {
            "raw": "Alice Jones",
            "encoded": "72896232743708443677449555551687504476536417389324439453514323796296385992918"
          }
        },
        "signature": {
          "p_credential": {
            "m_2": "57832835556928742723946725004638238236382427793876617639158517726445069815397",
            "a": "20335594316731334597758816443885619716281946894071547670112874227353349613733788033617671091848119624077343554670947282810485774124636153228333825818186760397527729892806528284243491342499262911619541896964620427749043381625203893661466943880747122017539322865930800203806065857795584699623987557173946111100450130555197585324032975907705976283592876161733661021481170756352943172201881541765527633833412431874555779986196454199886878078859992928382512010526711165717317294021035408585595567390933051546616905350933492259317172537982279278238456869493798937355032304448696707549688520575565393297998400926856935054785",
            "e": "259344723055062059907025491480697571938277889515152306249728583105665800713306759149981690559193987143012367913206299323899696942213235956742930114221280625468933785621106476195767",
            "v": "6264315754962089362691677910875768714719628097173834826942639456162861264780209679632476338104728648674666095282910717315628966174111516324733617604883927936031834134944562245348356595475949760140820205017843765225176947252534891385340037654527825604373031641665762232119470199172203915071879260274922482308419475927587898260844045340005759709509719230224917577081434498505999519246994431019808643717455525020238858900077950802493426663298211783820016830018445034267920428147219321200498121844471986156393710041532347890155773933440967485292509669092990420513062430659637641764166558511575862600071368439136343180394499313466692464923385392375334511727761876368691568580574716011747008456027092663180661749027223129454567715456876258225945998241007751462618767907499044716919115655029979467845162863204339002632523083819"
          },
          "r_credential": null
        },
        "signature_correctness_proof": {
          "se": "16380378819766384687299800964395104347426132415600670073499502988403571039552426989440730562439872799389359320216622430122149635890650280073919616970308875713611769602805907315796100888051513191790990723115153015179238215201014858697020476301190889292739142646098613335687696678474499610035829049097552703970387216872374849734708764603376911608392816067509505173513379900549958002287975424637744258982508227210821445545063280589183914569333870632968595659796744088289167771635644102920825749994200219186110532662348311959247565066406030309945998501282244986323336410628720691577720308242032279888024250179409222261839",
          "c": "54687071895183924055442269144489786903186459631877792294627879136747836413523"
        },
        "rev_reg": null,
        "witness": null
      },
      "credential": {
        "referent": "64ea2e85-c70f-45ad-b609-68bc1ac89816",
        "attrs": {
          "name": "Alice Jones"
        },
        "schema_id": "3avoBCqDMFHFaKUHug9s8W:2:fabername:0.1.0",
        "cred_def_id": "3avoBCqDMFHFaKUHug9s8W:3:CL:13:default",
        "rev_reg_id": null,
        "cred_rev_id": null
      },
      "state": "stored",
      "updated_at": "2019-09-09 21:00:10.688590Z",
      "connection_id": "2d67c0a7-3c07-426c-b28f-89fec182f308",
      "schema_id": "3avoBCqDMFHFaKUHug9s8W:2:fabername:0.1.0",
      "credential_request": {
        "prover_did": "USz54LX588nXZzvJZaaauo",
        "cred_def_id": "3avoBCqDMFHFaKUHug9s8W:3:CL:13:default",
        "blinded_ms": {
          "u": "99368895797536005994311578723189357674473888721194302817275899605659815579082776035889727937509149843902587581396694097380001137952451816178530770768521813901129081437176205941944065200271520024859963251064451377398768846912432396109867523131209543363488226760277539406928453777223625182259241308969628882540671093876658006934832956644288049409819530272004889072620189012294592330334635260630961922620635703716969003181853188178982291121888203909561688206211503826185916253632379861409156552241548354871543971458468129569412836309227637169916178695946550538097767138914450365505044802717690371144577045034596177069218",
          "ur": null,
          "hidden_attributes": [
            "master_secret"
          ],
          "committed_attributes": {}
        },
        "blinded_ms_correctness_proof": {
          "c": "82814368957593600542678573704265961728440515441532250993783760615697056042766",
          "v_dash_cap": "2118452362398745861280226057596824191481494477242721958942324742953084725675464959425613275439996307006090128873526174900550688825200704332952595267412793247827461612669522329485045242589005220163235341676269260760388476609945675148280360463542384583398853903862359134202158782311554154739994184363677101683603079599084416381670111627232980638055599465177598913645868266764089443449862992176864925745186449013730471429866771461184116930725948848731317657299234761870227355190066369188033430582072763347201781851825566140580053014392699389990683680999169805660350968648440532935808946668533750546941833754340355282870786638599282983773855233579000116239048351315802722580655134903452234145646701421420006720424362392380",
          "m_caps": {
            "master_secret": "24225459579209831479420816101972689886146719984334583846534574626255831902742393762937117009729103049145090884891989587187027426846285733606614192343459832623110571090085221331919"
          },
          "r_caps": {}
        },
        "nonce": "1019073401153768641589280"
      },
      "thread_id": "db475c51-0630-4fbd-9ddb-28c7676f1fad",
      "auto_issue": false,
      "credential_id": "64ea2e85-c70f-45ad-b609-68bc1ac89816"
    }
  ]
}
swcurran commented 5 years ago

Thanks @SmithSamuelM - sorry I didn't push to get this looked at. I knew that you wanted credential_id, but didn't realize it doesn't get returned in GET /credentials. That does seem odd. Thanks for creating an issue.

I'll ask @andrewwhitehead to take a look.

swcurran commented 5 years ago

@SmithSamuelM - mystery solved. The field "referent" is the credential_id. The endpoint returns the data structure directly from indy-sdk and that's what it calls it.

Given that Aries agents are supposed to be ledger/verifiable credential model agnostic, this is incorrect in the long term, and we should probably be handling this the same way as is done in 0036/0037, with some metadata (including credential_id) and then an attachment that is the credential in it's native format. However, I'd like to see this done after we have another implementation, so we're not just guessing.

I'll look for a place to add this to the documentation, but for now, that's all we'll do.

FYI @andrewwhitehead - let me know if you have any other thoughts on this, but I think good enough for now.