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

Revocation registry #108

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

guilherme-funchal
Copy link

As part of our POC using the indy-besu VDR and credo-ts (with the credo-rest extension), we needed and therefore are trying to develop a revocation solution, as it seems it is missing in the current version of this repository.

We have only started testing it, and probably there will be modifications and improvements, but if you could take the time to give us your feedback and suggestions, it would surely be appreciated!

We tried to model our implementation having the credo-ts implementation of anoncreds in mind, and the credo-vdr interaction was based on on the indy-vdr package. We have also attempted to keep within the standards used in this repository.
Our initial design idea consists of a smart contract (RevocationRegistry.sol) that stores, for a given RevocationRegistryDefinitionId, an object following this specification. It also stores onchain a reference to the issuerId and the current accumulator for comparison when trying to update the registry.
The Revocation Status List would be built by blockchain events (RevocationRegistryEntry) emitted for a given RevocationRegistryId. The RevocationRegistryEntry contains the indexes of newly issued/revoked credentials, the new accumulator, the previous accumulator for comparison, and a timestamp.

For building the complete RevocationStatusList, one would fetch and accumulate all events up to a given timestamp, this is done offchain.

We updated the genesis generation scripts, the 'flow-with-did-ethr' demo and created some basic tests for now.

We are also working on the Rust VDR implementation, including the wasm integration with credo, with some superficial tests for now.

@Toktar
Copy link
Contributor

Toktar commented Dec 18, 2024

Hello @guilherme-funchal !
That's a huge great job, thank you! Could you please fix DCO and merge conflict issues to let us start a technical review?

@guilherme-funchal
Copy link
Author

Hello Renata, I think I solved the problem. Could you please check if everything is correct?

@Toktar
Copy link
Contributor

Toktar commented Dec 18, 2024

Thank you, we started reviewing the code.
Could you also add signature for commit ec14579 Update key ?
https://github.com/hyperledger/indy-besu/pull/108/checks?check_run_id=34597775054

@guilherme-funchal
Copy link
Author

I put a developer from my team to look at the problem.

mapping(bytes32 id => RevocationRegistryDefinitionRecord revocationRegistryDefinitionRecord) private _revRegDefs;

/**
* Checks that the schema exist
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in the comment. Must be credential definition instead schema

_revRegDefs[_revRegDefId].metadata.currentAccumulator.length != 0 &&
keccak256(abi.encodePacked(_revRegDefs[_revRegDefId].metadata.currentAccumulator)) !=
keccak256(abi.encodePacked(initialRevRegEntry.prevAccumulator))
) revert AccumulatorMismatch(initialRevRegEntry.prevAccumulator);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the gas point of view, I think it will be more efficient just to compare each element in the array rather doing hashing.

        if (a.length != b.length) {
            return false;
        }
        for (uint256 i = 0; i < a.length; i++) {
            if (a[i] != b[i]) {
                return false;
            }
        }
        return true;
        ``` 

/**
* Checks wether Credential Definition Exists
*/
modifier _credDefExists(bytes32 credDefId) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this modifier looks like a duplicate of _credentialDefinitionExists

) external override {
_createRevocationRegistryEntry(identity, msg.sender, revRegDefId, issuerId, revRegEntry);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe createRevocationRegistryEntrymethod also require adding endorsing (Signed) version.

if (
keccak256(abi.encodePacked(_revRegDefs[revRegDefId].metadata.issuerId)) !=
keccak256(abi.encodePacked(issuerId))
) revert NotRevocationRegistryDefinitionIssuer(issuerId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just use StringUtils.equals method to compare issuerId

revocationRegistryEntryStruct
)

console.log(`Revocation Registry Entry created for Revocation Registry Definition id ${revocationRegistryId}. Receipt: ${JSON.stringify(receipt)}`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add registry resolving step

storage[slots['1']] = padLeft(data.universalDidResolverAddress, 64)
// address of Role control contact stored in slot 3
storage[slots['2']] = padLeft(data.roleControlContractAddress, 64)
// address of schema registry contact stored in slot 2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: schema -> credentialDefinition

// Set all `issuer` indexes to 0 (not revoked)
for issue in delta.issued {
revocation_list[issue as usize] = RevocationState::Active as u32
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this loop does nothing because let mut revocation_list: Vec<u32> = vec![0; rev_reg_def.value.max_cred_num.try_into().unwrap()]; already create an array where all elements are 0

return Ok(None);
}

//TODO: sets? vectors?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with using hashset

Some(previous_delta) => {
previous_delta.validate(revocation_registry_status_list.len() as u32 - 1)?;
// Check whether the revocationStatusList entry is not included in the previous delta issued indices
for (index, entry) in (0u32..).zip(revocation_registry_status_list.iter()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems, can be replaced with: revocation_registry_status_list.iter().enumerate()

@Artemkaaas
Copy link
Contributor

Artemkaaas commented Dec 19, 2024

Thank @guilherme-funchal for the great contribution.
In general, I agree with your design and implementation of supporting revocation data on the ledger. Looks good. We are not really far from getting this merged.
I started doing the code review and posting comments, what can be changed and improved (too many file to complete at once)

@guilherme-funchal
Copy link
Author

@Artemkaaas

Will you make the corrections or do you want me to try to do them?

@Artemkaaas
Copy link
Contributor

@guilherme-funchal It would be better if you or your team process them.

@guilherme-funchal
Copy link
Author

We have already started reviewing your observations and will submit them as soon as possible.

guilherme-funchal added a commit to guilherme-funchal/indy-besu that referenced this pull request Jan 7, 2025
Revocation support

Signed-off-by: Guilherme Funchal da Silva <[email protected]>
@guilherme-funchal
Copy link
Author

guilherme-funchal commented Jan 7, 2025

@Artemkaaas

I just saw some more of your comments that we haven't addressed yet, if you can wait for the new commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants