-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revocation support Signed-off-by: Guilherme Funchal da Silva <[email protected]>
- Loading branch information
1 parent
bd23063
commit 72585be
Showing
38 changed files
with
6,946 additions
and
957 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,50 @@ | ||
{ | ||
"chainId": 1337, | ||
"nodeAddress": "http://127.0.0.1:8545", | ||
"contracts": { | ||
"validatorControl": { | ||
"specPath": "smart_contracts/artifacts/contracts/network/ValidatorControl.sol/ValidatorControl.json", | ||
"address": "0x0000000000000000000000000000000000007777" | ||
}, | ||
"accountControl": { | ||
"specPath": "smart_contracts/artifacts/contracts/auth/AccountControl.sol/AccountControl.json", | ||
"address": "0x0000000000000000000000000000000000008888" | ||
}, | ||
"roleControl": { | ||
"specPath": "smart_contracts/artifacts/contracts/auth/RoleControl.sol/RoleControl.json", | ||
"address": "0x0000000000000000000000000000000000006666" | ||
}, | ||
"upgradeControl": { | ||
"specPath": "smart_contracts/artifacts/contracts/upgrade/UpgradeControl.sol/UpgradeControl.json", | ||
"address": "0x0000000000000000000000000000000000009999" | ||
}, | ||
"ethereumDidRegistry": { | ||
"specPath": "smart_contracts/artifacts/contracts/did/EthereumExtDidRegistry.sol/EthereumExtDidRegistry.json", | ||
"address": "0x0000000000000000000000000000000000018888" | ||
}, | ||
"indyDidRegistry": { | ||
"specPath": "smart_contracts/artifacts/contracts/did/IndyDidRegistry.sol/IndyDidRegistry.json", | ||
"address": "0x0000000000000000000000000000000000003333" | ||
}, | ||
"schemaRegistry": { | ||
"specPath": "smart_contracts/artifacts/contracts/anoncreds/SchemaRegistry.sol/SchemaRegistry.json", | ||
"address": "0x0000000000000000000000000000000000005555" | ||
}, | ||
"credDefRegistry": { | ||
"specPath": "smart_contracts/artifacts/contracts/anoncreds/CredentialDefinitionRegistry.sol/CredentialDefinitionRegistry.json", | ||
"address": "0x0000000000000000000000000000000000004444" | ||
}, | ||
"legacyMappingRegistry": { | ||
"specPath": "smart_contracts/artifacts/contracts/migration/LegacyMappingRegistry.sol/LegacyMappingRegistry.json", | ||
"address": "0x0000000000000000000000000000000000017777" | ||
}, | ||
"universalDidResolver": { | ||
"specPath": "smart_contracts/artifacts/contracts/migration/UniversalDidResolver.sol/UniversalDidResolver.json", | ||
"address": "0x000000000000000000000000000000000019999" | ||
} | ||
"chainId": 1337, | ||
"nodeAddress": "http://127.0.0.1:8545", | ||
"contracts": { | ||
"validatorControl": { | ||
"specPath": "smart_contracts/artifacts/contracts/network/ValidatorControl.sol/ValidatorControl.json", | ||
"address": "0x0000000000000000000000000000000000007777" | ||
}, | ||
"accountControl": { | ||
"specPath": "smart_contracts/artifacts/contracts/auth/AccountControl.sol/AccountControl.json", | ||
"address": "0x0000000000000000000000000000000000008888" | ||
}, | ||
"roleControl": { | ||
"specPath": "smart_contracts/artifacts/contracts/auth/RoleControl.sol/RoleControl.json", | ||
"address": "0x0000000000000000000000000000000000006666" | ||
}, | ||
"upgradeControl": { | ||
"specPath": "smart_contracts/artifacts/contracts/upgrade/UpgradeControl.sol/UpgradeControl.json", | ||
"address": "0x0000000000000000000000000000000000009999" | ||
}, | ||
"ethereumDidRegistry": { | ||
"specPath": "smart_contracts/artifacts/contracts/did/EthereumExtDidRegistry.sol/EthereumExtDidRegistry.json", | ||
"address": "0x0000000000000000000000000000000000018888" | ||
}, | ||
"indyDidRegistry": { | ||
"specPath": "smart_contracts/artifacts/contracts/did/IndyDidRegistry.sol/IndyDidRegistry.json", | ||
"address": "0x0000000000000000000000000000000000003333" | ||
}, | ||
"schemaRegistry": { | ||
"specPath": "smart_contracts/artifacts/contracts/anoncreds/SchemaRegistry.sol/SchemaRegistry.json", | ||
"address": "0x0000000000000000000000000000000000005555" | ||
}, | ||
"credDefRegistry": { | ||
"specPath": "smart_contracts/artifacts/contracts/anoncreds/CredentialDefinitionRegistry.sol/CredentialDefinitionRegistry.json", | ||
"address": "0x0000000000000000000000000000000000004444" | ||
}, | ||
"legacyMappingRegistry": { | ||
"specPath": "smart_contracts/artifacts/contracts/migration/LegacyMappingRegistry.sol/LegacyMappingRegistry.json", | ||
"address": "0x0000000000000000000000000000000000017777" | ||
}, | ||
"universalDidResolver": { | ||
"specPath": "smart_contracts/artifacts/contracts/migration/UniversalDidResolver.sol/UniversalDidResolver.json", | ||
"address": "0x000000000000000000000000000000000019999" | ||
}, | ||
"revocationRegistry": { | ||
"specPath": "smart_contracts/artifacts/contracts/anoncreds/RevocationRegistry.sol/RevocationRegistry.json", | ||
"address": "0x0000000000000000000000000000000000002222" | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1 +1 @@ | ||
0x40b6b9dc85d45b8bd1d8edc548ace4e5fd6c705bbf28a509f12791777b6b8843 | ||
0xe638e254e3d07ddc7a1332078f9ab1e41144b6c990149d5c882a50389b6e272a |
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,117 @@ | ||
/** | ||
* Copyright (c) 2024 DSR Corporation, Denver, Colorado. | ||
* https://www.dsr-corporation.com | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { AbiCoder, concat, getBytes, keccak256, Signature, solidityPacked, toUtf8Bytes, toUtf8String } from 'ethers' | ||
import { | ||
RevocationRegistryDefinitionMetadataStruct, | ||
RevocationRegistryEntryStruct, | ||
} from '../typechain-types/contracts/anoncreds/RevocationRegistry' | ||
import { Contract } from '../utils/contract' | ||
|
||
export type RevocationRegistryDefinitionRecord = { | ||
revRegDef: string | ||
metadata: RevocationRegistryDefinitionMetadataStruct | ||
} | ||
|
||
export class RevocationRegistry extends Contract { | ||
constructor(sender?: any) { | ||
super(RevocationRegistry.name, sender) | ||
} | ||
|
||
public async createRevocationRegistryDefinition( | ||
identity: string, | ||
id: string, | ||
credDefId: string, | ||
issuerId: string, | ||
revRegDef: string, | ||
) { | ||
const tx = await this.instance.createRevocationRegistryDefinition( | ||
identity, | ||
keccak256(toUtf8Bytes(id)), | ||
keccak256(toUtf8Bytes(credDefId)), | ||
issuerId, | ||
toUtf8Bytes(revRegDef), | ||
) | ||
return tx.wait() | ||
} | ||
|
||
public async createRevocationRegistryDefinitionSigned( | ||
identity: string, | ||
id: string, | ||
credDefId: string, | ||
issuerId: string, | ||
revRegDef: string, | ||
signature: Signature, | ||
) { | ||
const tx = await this.instance.createRevocationRegistryDefinitionSigned( | ||
identity, | ||
signature.v, | ||
signature.r, | ||
signature.s, | ||
keccak256(toUtf8Bytes(id)), | ||
keccak256(toUtf8Bytes(credDefId)), | ||
issuerId, | ||
toUtf8Bytes(revRegDef), | ||
) | ||
return tx.wait() | ||
} | ||
|
||
public async createRevocationRegistryEntry( | ||
identity: string, | ||
revRegId: string, | ||
issuerId: string, | ||
revRegEntry: RevocationRegistryEntryStruct, | ||
) { | ||
const tx = await this.instance.createRevocationRegistryEntry( | ||
identity, | ||
keccak256(toUtf8Bytes(revRegId)), | ||
issuerId, | ||
revRegEntry, | ||
) | ||
return tx.wait() | ||
} | ||
|
||
public async resolveRevocationRegistryDefinition(id: string): Promise<RevocationRegistryDefinitionRecord> { | ||
const record = await this.instance.resolveRevocationRegistryDefinition(keccak256(toUtf8Bytes(id))) | ||
return { | ||
revRegDef: toUtf8String(getBytes(record.revRegDef)), | ||
metadata: { | ||
created: record.metadata.created, | ||
issuerId: record.metadata.issuerId, | ||
currentAccumulator: record.metadata.currentAccumulator, | ||
}, | ||
} | ||
} | ||
|
||
public async fetchAllRevocationEntries(id: string): Promise<RevocationRegistryEntryStruct[]> { | ||
const eventLogs = await this.instance.queryFilter( | ||
this.instance.filters.RevocationRegistryEntryCreated(keccak256(toUtf8Bytes(id))), | ||
) | ||
const revRegEntries = eventLogs.map((log) => log.args.revRegEntry.toObject(true)) | ||
return revRegEntries | ||
} | ||
|
||
public signCreateRevRegDefEndorsementData( | ||
identity: string, | ||
privateKey: Uint8Array, | ||
id: string, | ||
credDefId: string, | ||
issuerId: string, | ||
revRegDef: string, | ||
) { | ||
return this.signEndorsementData( | ||
privateKey, | ||
concat([ | ||
identity, | ||
toUtf8Bytes('createRevocationRegistryDefinition'), | ||
getBytes(keccak256(toUtf8Bytes(id)), 'hex'), | ||
getBytes(keccak256(toUtf8Bytes(credDefId)), 'hex'), | ||
toUtf8Bytes(issuerId), | ||
getBytes(toUtf8Bytes(revRegDef), 'hex'), | ||
]), | ||
) | ||
} | ||
} |
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
Oops, something went wrong.