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

integration with Cheqd accumulators #319

Merged
merged 7 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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 integration-tests/data/credentials/cheqd-credentials.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

60 changes: 60 additions & 0 deletions integration-tests/verification-flow/cheqd-revocation.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import {IWallet} from '@docknetwork/wallet-sdk-core/lib/types';
import {
closeWallet,
getCredentialProvider,
getWallet,
} from '../helpers/wallet-helpers';
import {createVerificationController} from '@docknetwork/wallet-sdk-core/src/verification-controller';
import {ProofTemplateIds, createProofRequest} from '../helpers/certs-helpers';
import { cheqdRevocationCredential } from './bbs-plus-revocation-credentials';

describe('BBS+ revocation cheqd', () => {
it('should verify a revokable bbs+ credential issued on cheqd', async () => {
const wallet: IWallet = await getWallet();

getCredentialProvider().addCredential(cheqdRevocationCredential);

const proofRequest = await createProofRequest(
ProofTemplateIds.ANY_CREDENTIAL,
);

const result: any = await getCredentialProvider().isValid(cheqdRevocationCredential);

expect(result.status).toBe('verified');

const controller = await createVerificationController({
wallet,
});

await controller.start({
template: proofRequest,
});

let attributesToReveal = ['credentialSubject.name'];

controller.selectedCredentials.set(cheqdRevocationCredential.id, {
credential: cheqdRevocationCredential,
attributesToReveal,
});

const presentation = await controller.createPresentation();
console.log('Presentation generated');
console.log(JSON.stringify(presentation, null, 2));
console.log('Sending presentation to Certs API');

let certsResponse;
try {
certsResponse = await controller.submitPresentation(presentation);
console.log('CERTS response');
console.log(JSON.stringify(certsResponse, null, 2));
} catch (err) {
certsResponse = err.response.data;
console.log('Certs API returned an error');
console.log(JSON.stringify(certsResponse, null, 2));
}

expect(certsResponse.verified).toBe(true);
});

afterAll(() => closeWallet());
});
2 changes: 1 addition & 1 deletion packages/cli/src/bbs-revocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ const trimHexID = id => {

export const getWitnessDetails = async (credential, _membershipWitness) => {
const {credentialStatus} = credential;
const registryId = credentialStatus?.id.replace('dock:accumulator:', '');
const registryId = credentialStatus?.id;
const revocationIndex = credentialStatus.revocationId;

const queriedAccumulator = await dock.accumulatorModule.getAccumulator(
Expand Down
2 changes: 1 addition & 1 deletion packages/wasm/src/services/blockchain/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class BlockchainService {
this.didModule = new DockDIDModule(this.dock);
this.dockModules = new DockCoreModules(this.dock);
this.cheqdModules = new CheqdCoreModules(this.cheqdApi);
this.modules = new MultiApiCoreModules([this.dockModules]);
this.modules = new MultiApiCoreModules([this.dockModules, this.cheqdModules]);
this.emitter = new EventEmitter();
this.resolver = this.createDIDResolver();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/wasm/src/services/credential/bbs-revocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const getWitnessDetails = async (credential, _membershipWitness) => {
}

const {credentialStatus} = credential;
const registryId = credentialStatus?.id.replace('dock:accumulator:', '');
const registryId = credentialStatus?.id
const revocationIndex = credentialStatus.revocationId;

const queriedAccumulator = await blockchainService.modules.accumulator.getAccumulator(
Expand Down
2 changes: 1 addition & 1 deletion packages/wasm/src/services/credential/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ describe('Credential Service', () => {
},
}),
).toBe(
'0xa632a41f2fbdb681c14b33daae4fcc46af41661b90b35c4ac1545c9bebf0d7cc',
'dock:accumulator:0xa632a41f2fbdb681c14b33daae4fcc46af41661b90b35c4ac1545c9bebf0d7cc',
mike-parkhill marked this conversation as resolved.
Show resolved Hide resolved
);
});
});
Expand Down
4 changes: 2 additions & 2 deletions packages/wasm/src/services/credential/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class CredentialService {
return null;
}

return credential?.credentialStatus.id.replace('dock:accumulator:', '');
return credential?.credentialStatus.id;
}

async getAccumulatorData({credential}) {
Expand Down Expand Up @@ -405,7 +405,7 @@ class CredentialService {
if (witness) {
const details = await getWitnessDetails(credential, witness);
const chainModule =
credential.credentialStatus.id.indexOf('accumulator:dock:') === 0
credential.credentialStatus.id.indexOf('dock:accumulator') === 0
mike-parkhill marked this conversation as resolved.
Show resolved Hide resolved
? blockchainService.modules.accumulator.modules[0]
: blockchainService.modules.accumulator.modules[1];
const accumulatorModuleClass = chainModule.constructor;
Expand Down
Loading