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

[pull] main from hyperledger:main #193

Merged
merged 49 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
8cda03b
Add support for revocable credentials in vc_di handler
EmadAnwer May 24, 2024
65b9a9a
Merge branch 'hyperledger:main' into vcdi-revocation
EmadAnwer May 24, 2024
513b712
Merge branch 'hyperledger:main' into vcdi-revocation
EmadAnwer Jun 1, 2024
cff8b99
feat: Refactor revocation module and improve credential handling
EmadAnwer Jun 2, 2024
ecc0f46
update demo dependencies
PatStLouis Jun 3, 2024
6a75185
revert prompt_toolkit version in demo/requirements.txt
PatStLouis Jun 3, 2024
e10c8b4
feat: soft binding for plugin flexibility
dbluhm May 30, 2024
d609360
Merge remote-tracking branch 'upstream/main' into w3c-revocation
ianco Jun 3, 2024
6c4f6f4
test: soft binding
dbluhm Jun 3, 2024
974f9ae
Merge branch 'main' into pstlouis/dependabot-merger-demo
PatStLouis Jun 3, 2024
42ac9c3
Merge pull request #3008 from OpSecId/pstlouis/dependabot-merger-demo
dbluhm Jun 3, 2024
eb9f96d
Merge branch 'main' into vcdi-revocation
ianco Jun 3, 2024
3442c07
Integration tests for vc_di cred revocation
ianco Jun 3, 2024
d88fb8f
Merge pull request #43 from ianco/w3c-revocation
EmadAnwer Jun 3, 2024
2840ac1
Merge branch 'main' into feature/soft-binding
swcurran Jun 4, 2024
d232e60
Switch from pytz to dateutil (#3012)
jamshale Jun 5, 2024
a53dc65
Merge branch 'main' into feature/soft-binding
jamshale Jun 5, 2024
03efc31
Add sonarcloud badges (#3014)
jamshale Jun 5, 2024
4c49252
chore(deps): Bump actions/checkout from 3 to 4 in the all-actions gro…
dependabot[bot] Jun 5, 2024
44eb25b
Merge branch 'main' into feature/soft-binding
jamshale Jun 5, 2024
44555f9
Merge pull request #3010 from dbluhm/feature/soft-binding
dbluhm Jun 6, 2024
1da9872
Use a published version of aiohttp-apispec (#3019)
jamshale Jun 6, 2024
aff4b18
refactor: remove duplicated code
EmadAnwer Jun 4, 2024
630830e
ADD: tests for VCDI handler
EmadAnwer Jun 9, 2024
9d01fd7
Merge branch 'main' into vcdi-revocation
ianco Jun 9, 2024
85359ec
Merge pull request #2967 from Whats-Cookin/vcdi-revocation
ianco Jun 10, 2024
b2e87f3
chore(deps): Bump pydid from 0.5.0 to 0.5.1 (#3024)
dependabot[bot] Jun 10, 2024
a4506b8
chore(deps-dev): Bump pytest from 8.2.1 to 8.2.2 (#3025)
dependabot[bot] Jun 10, 2024
3c2f06e
docs: added section on environment variables
Executioner1939 Jun 11, 2024
2b94f68
chore(deps): Update prompt-toolkit requirement in /demo (#3026)
dependabot[bot] Jun 11, 2024
d0f447f
chore(deps): Bump sphinx from 1.8.4 to 1.8.6 (#3021)
dependabot[bot] Jun 11, 2024
40d212d
Merge branch 'main' into feature/docs-env-vars-signed
ianco Jun 11, 2024
db54bf7
Merge pull request #3028 from Executioner1939/feature/docs-env-vars-s…
WadeBarnes Jun 11, 2024
586a30d
:sparkles: Adds support for paginated storage queries, and implements…
ff137 Jun 11, 2024
393a7e8
chore(deps): Bump dawidd6/action-download-artifact
dependabot[bot] Jun 11, 2024
5ad52c1
Merge pull request #3027 from hyperledger/dependabot/github_actions/a…
swcurran Jun 11, 2024
f927b21
chore(deps): Bump uuid-utils from 0.7.0 to 0.8.0 (#3034)
dependabot[bot] Jun 17, 2024
6106657
chore(deps): Bump configargparse from 1.5.5 to 1.7 (#3035)
dependabot[bot] Jun 17, 2024
21b6ba7
Prevent getting stuck with no active registry
jamshale Jun 13, 2024
a363184
Refactor with more efficient queries
jamshale Jun 17, 2024
f8e82f8
chore(deps): Bump mkdocs-material from 9.5.10 to 9.5.27 (#3036)
dependabot[bot] Jun 17, 2024
c4308a5
chore(deps): Bump packaging from 23.1 to 23.2 (#3037)
dependabot[bot] Jun 17, 2024
9d39d15
Add unit tests
jamshale Jun 17, 2024
10f27b1
chore(deps): Bump marshmallow from 3.20.2 to 3.21.3 (#3038)
dependabot[bot] Jun 17, 2024
921a73e
chore(deps): Bump urllib3 in /demo/playground/examples in the pip gro…
dependabot[bot] Jun 17, 2024
d5f70e1
Fix - only run integration tests on opened PR's (#3042)
jamshale Jun 18, 2024
cf2d34b
Fix and refactor anoncreds revocation recovery (#3029)
jamshale Jun 18, 2024
fec98bf
Merge branch 'main' into feat/3017
dbluhm Jun 18, 2024
75f6c53
Merge pull request #3032 from jamshale/feat/3017
dbluhm Jun 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/integrationtests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
pull_request:
branches:
- main
types: [opened, synchronize, reopened, ready_for_review]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -19,7 +20,7 @@ defaults:
jobs:
test:
runs-on: ubuntu-latest
if: (github.event_name == 'pull_request' && github.repository == 'hyperledger/aries-cloudagent-python') || (github.event_name != 'pull_request')
if: (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.repository == 'hyperledger/aries-cloudagent-python') || (github.event_name != 'pull_request')
outputs:
is_release: ${{ steps.check_if_release.outputs.is_release }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sonar-merge-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
name: SonarCloud
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Tests
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/sonar-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download PR number artifact
uses: dawidd6/action-download-artifact@v3
uses: dawidd6/action-download-artifact@v5
with:
workflow: Tests
run_id: ${{ github.event.workflow_run.id }}
Expand All @@ -26,7 +26,7 @@ jobs:
with:
path: ./PR_NUMBER
- name: Download Test Coverage
uses: dawidd6/action-download-artifact@v3
uses: dawidd6/action-download-artifact@v5
with:
workflow: Tests
run_id: ${{ github.event.workflow_run.id }}
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# Hyperledger Aries Cloud Agent - Python <!-- omit in toc -->

[![pypi releases](https://img.shields.io/pypi/v/aries_cloudagent)](https://pypi.org/project/aries-cloudagent/)

<!-- ![logo](/doc/assets/aries-cloudagent-python-logo-bw.png) -->
<p float="left">
<a href="https://pypi.org/project/aries-cloudagent/"><img src="https://img.shields.io/pypi/v/aries_cloudagent" width="100" height="20" />
<img src="https://sonarcloud.io/images/project_badges/sonarcloud-white.svg" width="120" height="20" />
<img src="https://sonarcloud.io/api/project_badges/measure?project=hyperledger_aries-cloudagent-python&metric=coverage" width="120" height="20" />
&nbsp;<img src="https://sonarcloud.io/api/project_badges/measure?project=hyperledger_aries-cloudagent-python&metric=security_rating" width="100" height="20" />
&nbsp;<img src="https://sonarcloud.io/api/project_badges/measure?project=hyperledger_aries-cloudagent-python&metric=vulnerabilities" width="120" height="20" />
&nbsp;<img src="https://sonarcloud.io/api/project_badges/measure?project=hyperledger_aries-cloudagent-python&metric=ncloc" width="120" height="20" />
</p>

> An easy to use Aries agent for building SSI services using any language that supports sending/receiving HTTP requests.

Expand Down
126 changes: 126 additions & 0 deletions aries_cloudagent/anoncreds/default/legacy_indy/recover.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
"""Recover a revocation registry."""

import hashlib
import logging
import time

import aiohttp
import base58
import indy_vdr
from anoncreds import (
RevocationRegistry,
RevocationRegistryDefinition,
)

from ...models.anoncreds_revocation import RevList

LOGGER = logging.getLogger(__name__)


"""
This module calculates a new ledger accumulator, based on the revocation status
on the ledger vs revocations recorded in the wallet.
The calculated transaction can be written to the ledger to get the ledger back
in sync with the wallet.
This function can be used if there were previous revocation errors (i.e. the
credential revocation was successfully written to the wallet but the ledger write
failed.)
"""


class RevocRecoveryException(Exception):
"""Raise exception generating the recovery transaction."""


async def _check_tails_hash_for_inconsistency(tails_location: str, tails_hash: str):
async with aiohttp.ClientSession() as session:
LOGGER.debug("Tails URL: %s", tails_location)
tails_data_http_response = await session.get(tails_location)
tails_data = await tails_data_http_response.read()
remote_tails_hash = base58.b58encode(
hashlib.sha256(tails_data).digest()
).decode("utf-8")
if remote_tails_hash != tails_hash:
raise RevocRecoveryException(
f"Tails hash mismatch {remote_tails_hash} {tails_hash}"
)
else:
LOGGER.debug(f"Checked tails hash: {tails_hash}")


async def fetch_txns(genesis_txns: str, registry_id: str, issuer_id: str) -> tuple[
dict,
set[int],
]:
"""Fetch tails file and revocation registry information."""

LOGGER.debug(f"Fetch revocation registry def {registry_id} from ledger")
revoc_reg_delta_request = indy_vdr.ledger.build_get_revoc_reg_def_request(
None, registry_id
)

pool = await indy_vdr.open_pool(transactions=genesis_txns)
result = await pool.submit_request(revoc_reg_delta_request)
if not result["data"]:
raise RevocRecoveryException(f"Registry definition not found for {registry_id}")

# Load the anoncreds revocation registry definition
rev_reg_def_raw = result["data"]
rev_reg_def_raw["ver"] = "1.0"
rev_reg_def_raw["issuerId"] = issuer_id
revoc_reg_def = RevocationRegistryDefinition.load(rev_reg_def_raw)

await _check_tails_hash_for_inconsistency(
revoc_reg_def.tails_location, revoc_reg_def.tails_hash
)

LOGGER.debug(f"Fetch revocation registry delta {registry_id} from ledger")
to_timestamp = int(time.time())
revoc_reg_delta_request = indy_vdr.ledger.build_get_revoc_reg_delta_request(
None, registry_id, None, to_timestamp
)
result = await pool.submit_request(revoc_reg_delta_request)
if not result["data"]:
raise RevocRecoveryException("Error fetching delta from ledger")

registry_from_ledger = result["data"]["value"]["accum_to"]
registry_from_ledger["ver"] = "1.0"
revoked = set(result["data"]["value"]["revoked"])
LOGGER.debug("Ledger revoked indexes: %s", revoked)

return registry_from_ledger, revoked


async def generate_ledger_rrrecovery_txn(genesis_txns: str, rev_list: RevList):
"""Generate a new ledger accum entry, using the wallet value if revocations ahead of ledger.""" # noqa: E501

registry_from_ledger, prev_revoked = await fetch_txns(
genesis_txns, rev_list.rev_reg_def_id, rev_list.issuer_id
)

set_revoked = {
index for index, value in enumerate(rev_list.revocation_list) if value == 1
}
mismatch = prev_revoked - set_revoked
if mismatch:
LOGGER.warning(
"Credential index(es) revoked on the ledger, but not in wallet: %s",
mismatch,
)

updates = set_revoked - prev_revoked
if not updates:
LOGGER.debug("No updates to perform")
return {}
else:
LOGGER.debug("New revoked indexes: %s", updates)

# Prepare the transaction to write to the ledger
registry = RevocationRegistry.load(registry_from_ledger)
registry = registry.to_dict()
registry["ver"] = "1.0"
registry["value"]["prevAccum"] = registry_from_ledger["value"]["accum"]
registry["value"]["accum"] = rev_list.current_accumulator
registry["value"]["issued"] = []
registry["value"]["revoked"] = list(updates)
return registry
Loading
Loading