I am currently trying to write a revocation registry definition (revRegDef) to a Hyperledger Indy pool as shown in the Indy Getting Started. The workflow is like this:
Since I need to use Java, i added the appropriate requests to the ledger to the Java Sample, i uploaded my modified version here.
Creating the schema and credDef works fine, but when I send the last request, i get the following error message:
reason -> client request invalid: InvalidClientRequest("Format of credDefId field is not acceptable.
Expected: 'did:marker:signature_type:schema_ref' or 'did:marker:signature_type:schema_ref:tag'",)
At this point, the mentioned credDefId looks like this: Th7MpTaRZVRYnPiabds81Y:3:CL:Th7MpTaRZVRYnPiabds81Y:2:gvt:1.0:Tag1
while the schemaId is Th7MpTaRZVRYnPiabds81Y:2:gvt:1.0
Obviously the mentioned pattern is not met, but the Ledger.buildCredDefReq()
function returns the credDefId
like this, so i would expect it to be correct.
Edit: while my old answer worked, it only was a workaround and complete bs.. the following should be the correct way of creating credential schema, credential definition and revocation registry definition.
// Create Credential Schema
String name = "schema_name";
String schemaAttrs = new JSONArray().put("name").put("age").toString();
AnoncredsResults.IssuerCreateSchemaResult schema =
Anoncreds.issuerCreateSchema(verinym, name, "1.0", schemaAttrs).get();
String schemaId = schema.getSchemaId();
String schemaJson = schema.getSchemaJson();
JSONObject schemaRes = new JSONObject(Ledger.signAndSubmitRequest(PoolUtils.getInstance(), wallet, verinym,
Ledger.buildSchemaRequest(verinym, schemaJson).get()
).get());
int schemaSeqNo = schemaRes.getJSONObject("result").getJSONObject("txnMetadata").getInt("seqNo");
schemaJson = new JSONObject(schemaJson).put("seqNo", schemaSeqNo).toString();
// Create Credential Definition
AnoncredsResults.IssuerCreateAndStoreCredentialDefResult credDef =
Anoncreds.issuerCreateAndStoreCredentialDef(
wallet, verinym, schemaJson, "tag", null,
new JSONObject().put("support_revocation", true).toString()
).get();
// creating credDef req and sending it to the ledger
JSONObject credDefRes = new JSONObject(
Ledger.signAndSubmitRequest(
PoolUtils.getInstance(), wallet, verinym,
Ledger.buildCredDefRequest(verinym, credDef.getCredDefJson()).get()
).get()
);
int credSeqNo = credDefRes.getJSONObject("result").getJSONObject("txnMetadata").getInt("seqNo");
// Create Revocation Registry Definition
String tailsWriterConfig = new JSONObject().put("base_dir", "/tmp/indy_tails").put("uri_pattern", "").toString();
BlobStorageWriter tails = BlobStorageWriter.openWriter("default", tailsWriterConfig).get();
AnoncredsResults.IssuerCreateAndStoreRevocRegResult revocRegDef = Anoncreds.issuerCreateAndStoreRevocReg(
wallet, verinym, null, "contractDef", credDefId,
"{}", tails
).get();
JSONObject revocRegDefRes = new JSONObject(
Ledger.signAndSubmitRequest(PoolUtils.getInstance(), wallet, verinym,
Ledger.buildRevocRegDefRequest(verinym, revocRegDef.getRevRegDefJson()).get()
).get());
revocRegDefSeqNo = revocRegDefRes.getJSONObject("result").getJSONObject("txnMetadata").getInt("seqNo");
The learning is that the ledger returns important values for the creation of definition
Furthermore, nowhere was mentioned that you need to create an initial revocation registry entry:
// Create initial revocation entry
JSONObject revocRegEntryRes = new JSONObject(Ledger.signAndSubmitRequest(PoolUtils.getInstance(), wallet, verinym,
Ledger.buildRevocRegEntryRequest(verinym, revocRegDef.getRevRegId(),
"CL_ACCUM", revocRegDef.getRevRegEntryJson()).get()).get());