-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: IndyVdrAnonCredsRegistry revocation methods (#1328)
Signed-off-by: Victor Anene <[email protected]>
- Loading branch information
1 parent
64e20f1
commit fb7ee50
Showing
3 changed files
with
390 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import type { AnonCredsRevocationStatusList, AnonCredsRevocationRegistryDefinition } from '@aries-framework/anoncreds' | ||
|
||
export function anonCredsRevocationStatusListFromIndyVdr( | ||
revocationRegistryDefinitionId: string, | ||
revocationRegistryDefinition: AnonCredsRevocationRegistryDefinition, | ||
delta: RevocRegDelta, | ||
timestamp: number, | ||
isIssuanceByDefault: boolean | ||
): AnonCredsRevocationStatusList { | ||
// 0 means unrevoked, 1 means revoked | ||
const defaultState = isIssuanceByDefault ? 0 : 1 | ||
|
||
// Fill with default value | ||
const revocationList = new Array(revocationRegistryDefinition.value.maxCredNum).fill(defaultState) | ||
|
||
// Set all `issuer` indexes to 0 (not revoked) | ||
for (const issued of delta.issued ?? []) { | ||
revocationList[issued] = 0 | ||
} | ||
|
||
// Set all `revoked` indexes to 1 (revoked) | ||
for (const revoked of delta.revoked ?? []) { | ||
revocationList[revoked] = 1 | ||
} | ||
|
||
return { | ||
issuerId: revocationRegistryDefinition.issuerId, | ||
currentAccumulator: delta.accum, | ||
revRegId: revocationRegistryDefinitionId, | ||
revocationList, | ||
timestamp, | ||
} | ||
} | ||
|
||
interface RevocRegDelta { | ||
accum: string | ||
issued: number[] | ||
revoked: number[] | ||
} |
Oops, something went wrong.