Skip to content

Commit

Permalink
Merge pull request #272 from docknetwork/bbs-revocation-fix
Browse files Browse the repository at this point in the history
fix: use new credential witness
  • Loading branch information
maycon-mello authored Jun 25, 2024
2 parents 3747bec + a2c5f36 commit d9fa824
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions packages/wasm/src/services/credential/bbs-revocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async function updateMembershipWitness({
credential,
membershipWitness,
registryId,
accumulator,
blockNo,
}) {
const revocationId = credential.credentialStatus.revocationId;
const member = Accumulator.encodePositiveNumberAsAccumulatorMember(
Expand All @@ -38,7 +38,7 @@ async function updateMembershipWitness({
try {
updates = await dock.accumulatorModule.getUpdatesFromBlock(
registryId,
accumulator.lastModified,
blockNo,
);
} catch (err) {
if (err.code === UnknownBlockErrorCode) {
Expand Down Expand Up @@ -80,6 +80,15 @@ async function updateMembershipWitness({
}

export const getWitnessDetails = async (credential, _membershipWitness) => {
let witness = _membershipWitness;
let blockNo;

try {
({blockNo, witness} = JSON.parse(_membershipWitness));
} catch (err) {
console.error(err);
}

const {credentialStatus} = credential;
const registryId = credentialStatus?.id.replace('dock:accumulator:', '');
const revocationIndex = credentialStatus.revocationId;
Expand Down Expand Up @@ -107,24 +116,24 @@ export const getWitnessDetails = async (credential, _membershipWitness) => {
const params = dockAccumulatorParams();
const pk = new AccumulatorPublicKey(hexToU8a(publicKey.bytes));

const membershipWitness = new VBMembershipWitness(
hexToU8a(_membershipWitness),
let membershipWitness = new VBMembershipWitness(
hexToU8a(witness),
);

// TODO: Currently working with Lovesh to fix this
// https://dock-team.atlassian.net/browse/DCKM-453
// try {
// const updatedWitness = await updateMembershipWitness({
// credential,
// membershipWitness: _membershipWitness,
// registryId,
// accumulator: queriedAccumulator,
// });
// membershipWitness = updatedWitness;

// } catch (err) {
// console.error(err);
// }
if(blockNo){
try {
const updatedWitness = await updateMembershipWitness({
credential,
membershipWitness: witness,
registryId,
blockNo,
});
membershipWitness = updatedWitness;

} catch (err) {
console.error(err);
}
}

return {
encodedRevId,
Expand Down

0 comments on commit d9fa824

Please sign in to comment.