Skip to content

Commit

Permalink
Revocation registry
Browse files Browse the repository at this point in the history
Revocation support

Signed-off-by: Guilherme Funchal da Silva <[email protected]>
  • Loading branch information
guilherme-funchal committed Dec 18, 2024
1 parent 53e5d6a commit 3f540d2
Show file tree
Hide file tree
Showing 183 changed files with 7,850 additions and 1,012 deletions.
4 changes: 4 additions & 0 deletions examples/migration/src/holder.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2024 DSR Corporation, Denver, Colorado.
// https://www.dsr-corporation.com
// SPDX-License-Identifier: Apache-2.0

use crate::{
ledger::{BesuLedger, IndyLedger, Ledgers},
wallet::{BesuWallet, IndyWallet},
Expand Down
4 changes: 4 additions & 0 deletions examples/migration/src/issuer.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2024 DSR Corporation, Denver, Colorado.
// https://www.dsr-corporation.com
// SPDX-License-Identifier: Apache-2.0

use crate::{
ledger::{BesuLedger, IndyLedger, Ledgers},
wallet::{BesuWallet, IndyWallet},
Expand Down
4 changes: 4 additions & 0 deletions examples/migration/src/ledger.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2024 DSR Corporation, Denver, Colorado.
// https://www.dsr-corporation.com
// SPDX-License-Identifier: Apache-2.0

use crate::wallet::{BesuWallet, IndyWallet};
use indy_besu_vdr::{
credential_definition_registry::{
Expand Down
4 changes: 4 additions & 0 deletions examples/migration/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2024 DSR Corporation, Denver, Colorado.
// https://www.dsr-corporation.com
// SPDX-License-Identifier: Apache-2.0

mod holder;
mod issuer;
mod ledger;
Expand Down
4 changes: 4 additions & 0 deletions examples/migration/src/trustee.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2024 DSR Corporation, Denver, Colorado.
// https://www.dsr-corporation.com
// SPDX-License-Identifier: Apache-2.0

use crate::{
ledger::{BesuLedger, IndyLedger, Ledgers},
wallet::{BesuWallet, IndyWallet},
Expand Down
4 changes: 4 additions & 0 deletions examples/migration/src/verifier.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2024 DSR Corporation, Denver, Colorado.
// https://www.dsr-corporation.com
// SPDX-License-Identifier: Apache-2.0

use crate::ledger::{BesuLedger, IndyLedger, Ledgers};
use indy_credx::types::{
CredentialDefinition, CredentialDefinitionId, Presentation, PresentationRequest, Schema,
Expand Down
4 changes: 4 additions & 0 deletions examples/migration/src/wallet.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2024 DSR Corporation, Denver, Colorado.
// https://www.dsr-corporation.com
// SPDX-License-Identifier: Apache-2.0

use aries_askar::kms::{KeyAlg, LocalKey};
use indy_besu_vdr::{Address, BasicSigner};

Expand Down
90 changes: 47 additions & 43 deletions network/config.json
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"
}
}
}
2 changes: 1 addition & 1 deletion network/config/nodes/validator5/key
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0x40b6b9dc85d45b8bd1d8edc548ace4e5fd6c705bbf28a509f12791777b6b8843
0xe638e254e3d07ddc7a1332078f9ab1e41144b6c990149d5c882a50389b6e272a
6 changes: 6 additions & 0 deletions smart_contracts/contracts-ts/AccountControl.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* Copyright (c) 2024 DSR Corporation, Denver, Colorado.
* https://www.dsr-corporation.com
* SPDX-License-Identifier: Apache-2.0
*/

import { BigNumberish } from 'ethers'
import { BytesLike } from 'ethers/src.ts/utils'
import { Contract } from '../utils/contract'
Expand Down
6 changes: 6 additions & 0 deletions smart_contracts/contracts-ts/CredentialDefinitionRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* Copyright (c) 2024 DSR Corporation, Denver, Colorado.
* https://www.dsr-corporation.com
* SPDX-License-Identifier: Apache-2.0
*/

import { concat, getBytes, keccak256, Signature, toUtf8Bytes, toUtf8String } from 'ethers'
import { CredentialDefinitionMetadataStruct } from '../typechain-types/contracts/anoncreds/CredentialDefinitionRegistry'
import { Contract } from '../utils/contract'
Expand Down
6 changes: 6 additions & 0 deletions smart_contracts/contracts-ts/EthereumDidRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* Copyright (c) 2024 DSR Corporation, Denver, Colorado.
* https://www.dsr-corporation.com
* SPDX-License-Identifier: Apache-2.0
*/

import { encodeBytes32String, toUtf8Bytes } from 'ethers'
import { Contract } from '../utils/contract'

Expand Down
6 changes: 6 additions & 0 deletions smart_contracts/contracts-ts/IndyDidRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* Copyright (c) 2024 DSR Corporation, Denver, Colorado.
* https://www.dsr-corporation.com
* SPDX-License-Identifier: Apache-2.0
*/

import { concat, getBytes, Signature, toUtf8Bytes, toUtf8String } from 'ethers'
import { DidMetadataStruct } from '../typechain-types/contracts/did/IndyDidRegistry'
import { Contract } from '../utils/contract'
Expand Down
6 changes: 6 additions & 0 deletions smart_contracts/contracts-ts/LegacyMappingRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* Copyright (c) 2024 DSR Corporation, Denver, Colorado.
* https://www.dsr-corporation.com
* SPDX-License-Identifier: Apache-2.0
*/

import { concat, Signature, toUtf8Bytes } from 'ethers'
import { Contract } from '../utils/contract'

Expand Down
117 changes: 117 additions & 0 deletions smart_contracts/contracts-ts/RevocationRegistry.ts
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'),
]),
)
}
}
6 changes: 6 additions & 0 deletions smart_contracts/contracts-ts/RoleControl.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* Copyright (c) 2024 DSR Corporation, Denver, Colorado.
* https://www.dsr-corporation.com
* SPDX-License-Identifier: Apache-2.0
*/

import { Account } from '../utils/account'
import { Contract } from '../utils/contract'

Expand Down
6 changes: 6 additions & 0 deletions smart_contracts/contracts-ts/SchemaRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* Copyright (c) 2024 DSR Corporation, Denver, Colorado.
* https://www.dsr-corporation.com
* SPDX-License-Identifier: Apache-2.0
*/

import { concat, getBytes, keccak256, Signature, toUtf8Bytes, toUtf8String } from 'ethers'
import { SchemaMetadataStruct } from '../typechain-types/contracts/anoncreds/SchemaRegistry'
import { Contract } from '../utils/contract'
Expand Down
6 changes: 6 additions & 0 deletions smart_contracts/contracts-ts/UniversalDidReolver.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* Copyright (c) 2024 DSR Corporation, Denver, Colorado.
* https://www.dsr-corporation.com
* SPDX-License-Identifier: Apache-2.0
*/

import { getBytes, toUtf8String } from 'ethers'
import { DidMetadataStruct } from '../typechain-types/contracts/did/IndyDidRegistry'
import { Contract } from '../utils'
Expand Down
6 changes: 6 additions & 0 deletions smart_contracts/contracts-ts/UpgradeControl.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* Copyright (c) 2024 DSR Corporation, Denver, Colorado.
* https://www.dsr-corporation.com
* SPDX-License-Identifier: Apache-2.0
*/

import { Contract } from '../utils/contract'

export class UpgradeControl extends Contract {
Expand Down
6 changes: 6 additions & 0 deletions smart_contracts/contracts-ts/ValidatorControl.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* Copyright (c) 2024 DSR Corporation, Denver, Colorado.
* https://www.dsr-corporation.com
* SPDX-License-Identifier: Apache-2.0
*/

import { Contract } from '../utils/contract'

export class ValidatorControl extends Contract {
Expand Down
7 changes: 7 additions & 0 deletions smart_contracts/contracts-ts/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* Copyright (c) 2024 DSR Corporation, Denver, Colorado.
* https://www.dsr-corporation.com
* SPDX-License-Identifier: Apache-2.0
*/

export * from './AccountControl'
export * from './CredentialDefinitionRegistry'
export * from './IndyDidRegistry'
Expand All @@ -8,3 +14,4 @@ export * from './UniversalDidReolver'
export * from './UpgradeControl'
export * from './ValidatorControl'
export * from './LegacyMappingRegistry'
export * from './RevocationRegistry'
Loading

0 comments on commit 3f540d2

Please sign in to comment.