-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parametrize issuance with rev reg (#491)
* Parametrize issuance with rev reg * Update rustc version * Expose get tails hash on rev reg * Add vcx_revocation_registry_publish_revocations * Remove callback argument to rev reg release Signed-off-by: Miroslav Kovar <[email protected]> Co-authored-by: Miroslav Kovar <[email protected]>
- Loading branch information
Showing
28 changed files
with
1,165 additions
and
53 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
39 changes: 39 additions & 0 deletions
39
agents/node/vcxagent-core/src/services/service-revocation-registry.js
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,39 @@ | ||
const { RevocationRegistry } = require('@hyperledger/node-vcx-wrapper') | ||
|
||
module.exports.createServiceLedgerRevocationRegistry = function createServiceLedgerRevocationRegistry ({ logger, saveRevReg, loadRevReg, listRevRegIds }) { | ||
async function createRevocationRegistry (issuerDid, credDefId, tag, tailsDir, maxCreds, tailsUrl = 'dummy.org') { | ||
const data = { | ||
issuerDid, | ||
credDefId, | ||
tag, | ||
tailsDir, | ||
maxCreds | ||
} | ||
const revReg = await RevocationRegistry.create(data) | ||
await revReg.publish(tailsUrl) | ||
const revRegId = await revReg.getRevRegId() | ||
await saveRevReg(revRegId, revReg) | ||
return { revReg, revRegId } | ||
} | ||
|
||
async function rotateRevocationRegistry (revRegId, maxCreds, tailsUrl = 'dummy.org') { | ||
logger.info(`Rotating revocation registry ${revRegId}, maxCreds ${maxCreds}`) | ||
const revReg = await loadRevReg(revRegId) | ||
let newRevReg | ||
try { | ||
newRevReg = await revReg.rotate(maxCreds) | ||
await newRevReg.publish(tailsUrl) | ||
} catch (err) { | ||
throw Error(`Error rotating revocation registry ${revRegId}: ${err}`) | ||
} | ||
const newRevRegId = await newRevReg.getRevRegId() | ||
await saveRevReg(newRevRegId, newRevReg) | ||
logger.info(`Revocation registry ${revRegId} rotated, new rev reg id ${newRevRegId}`) | ||
return { revReg: newRevReg, revRegId: newRevRegId } | ||
} | ||
|
||
return { | ||
createRevocationRegistry, | ||
rotateRevocationRegistry | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* eslint-env jest */ | ||
require('jest') | ||
const { createPairedAliceAndFaber } = require('./utils/utils') | ||
const { initRustapi } = require('../src/index') | ||
const { IssuerStateType, HolderStateType, ProverStateType, VerifierStateType } = require('@hyperledger/node-vcx-wrapper') | ||
const sleep = require('sleep-promise') | ||
|
||
beforeAll(async () => { | ||
jest.setTimeout(1000 * 60 * 4) | ||
try { | ||
await initRustapi(process.env.VCX_LOG_LEVEL || 'vcx=warn,aries_vcx=warn') | ||
} catch (err) { | ||
console.error(`ERROR: ${err}`) | ||
} | ||
}) | ||
|
||
describe('test send credential', () => { | ||
it('Faber should send valid credential to Alice', async () => { | ||
try { | ||
const { alice, faber } = await createPairedAliceAndFaber() | ||
const tailsDir = `${__dirname}/tmp/faber/tails` | ||
await faber.buildLedgerPrimitivesV2({ tailsDir, maxCreds: 5 }) | ||
await faber.rotateRevReg(5) | ||
await faber.sendCredentialOfferV2() | ||
await alice.acceptCredentialOffer() | ||
|
||
await faber.updateStateCredentialV2(IssuerStateType.RequestReceived) | ||
await faber.sendCredential() | ||
await alice.updateStateCredentialV2(HolderStateType.Finished) | ||
await faber.receiveCredentialAck() | ||
|
||
const request = await faber.requestProofFromAlice() | ||
await alice.sendHolderProof(JSON.parse(request), revRegId => tailsDir) | ||
await faber.updateStateVerifierProofV2(VerifierStateType.Finished) | ||
await alice.updateStateHolderProofV2(ProverStateType.Finished) | ||
} catch (err) { | ||
console.error(`err = ${err.message} stack = ${err.stack}`) | ||
await sleep(2000) | ||
throw Error(err) | ||
} | ||
}) | ||
}) |
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
Oops, something went wrong.