-
Notifications
You must be signed in to change notification settings - Fork 374
VDR upgrade #1711
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
VDR upgrade #1711
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import base58 | ||
import json | ||
|
||
from indy_vdr import ledger, open_pool | ||
from aries_askar import Store, Key, KeyAlg, AskarError, AskarErrorCode | ||
from indy_credx import Schema, CredentialDefinition, RevocationRegistryDefinition | ||
from indy_vdr.error import VdrError | ||
|
||
# TODO: This code is copied from indy-test-automation, we should move it to a common place | ||
# and use it from there in both places | ||
|
||
|
||
def key_helper(seed=None): | ||
""" | ||
Generate a new keypair and DID | ||
""" | ||
alg = KeyAlg.ED25519 | ||
if seed: | ||
keypair = Key.from_secret_bytes(alg, seed) | ||
else: | ||
keypair = Key.generate(alg) | ||
verkey_bytes = keypair.get_public_bytes() | ||
verkey = base58.b58encode(verkey_bytes).decode("ascii") | ||
did = base58.b58encode(verkey_bytes[:16]).decode("ascii") | ||
return keypair, did, verkey | ||
|
||
|
||
async def key_insert_helper(wallet_handle, keypair, did, verkey): | ||
''' | ||
Insert a keypair into the wallet | ||
''' | ||
try: | ||
await wallet_handle.insert_key(verkey, keypair, metadata=json.dumps({})) | ||
except AskarError as err: | ||
if err.code == AskarErrorCode.DUPLICATE: | ||
pass | ||
else: | ||
raise err | ||
item = await wallet_handle.fetch("did", did, for_update=True) | ||
if item: | ||
did_info = item.value_json | ||
if did_info.get("verkey") != verkey: | ||
raise Exception("DID already present in wallet") | ||
did_info["metadata"] = {} | ||
await wallet_handle.replace("did", did, value_json=did_info, tags=item.tags) | ||
else: | ||
await wallet_handle.insert( | ||
"did", | ||
did, | ||
value_json={ | ||
"did": did, | ||
"method": "sov", | ||
"verkey": verkey, | ||
"verkey_type": "ed25519", | ||
"metadata": {}, | ||
}, | ||
tags={ | ||
"method": "sov", | ||
"verkey": verkey, | ||
"verkey_type": "ed25519", | ||
}, | ||
) | ||
|
||
|
||
async def create_and_store_did(wallet_handle, seed=None): | ||
''' | ||
Create a new DID and store it in the wallet | ||
''' | ||
keypair, did, verkey = key_helper(seed=seed) | ||
await key_insert_helper(wallet_handle, keypair, did, verkey) | ||
return did, verkey | ||
|
||
async def wallet_helper(wallet_key='', wallet_key_derivation_method='kdf:argon2i:mod'): | ||
wuri = "sqlite://:memory:" | ||
wallet_h = await Store.provision(wuri, wallet_key_derivation_method, wallet_key, recreate=False) | ||
session_handle = await wallet_h.session() | ||
wallet_config = json.dumps({"id": wuri}) | ||
wallet_credentials = json.dumps({"key": wallet_key, "key_derivation_method": wallet_key_derivation_method}) | ||
|
||
return session_handle, wallet_config, wallet_credentials |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ | |
exec(f.read(), metadata) | ||
|
||
tests_require = ['attrs==20.3.0', 'pytest==6.2.5', 'pytest-xdist==2.2.1', 'pytest-forked==1.3.0', | ||
'python3-indy==1.16.0.post236', 'pytest-asyncio==0.14.0'] | ||
'pytest-asyncio==0.14.0', 'indy_vdr==0.4.0.dev5', 'aries-askar==0.2.7', 'indy-credx==0.3.1'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ERROR: Could not find a version that satisfies the requirement indy_vdr==0.4.3 (from indy-node[tests]) (from versions: 0.2.0, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.3.4, 0.4.0.dev1, 0.4.0.dev2, 0.4.0.dev3, 0.4.0.dev4, 0.4.0.dev5, 0.4.0.dev10, 0.4.0.dev11, 0.4.0.dev12, 0.4.0.dev13, 0.4.0.dev14, 0.4.0.dev15, 0.4.0.dev16, 0.4.0, 0.4.1, 0.4.2) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created an issue for the publishing issue here; hyperledger/indy-vdr#335 |
||
|
||
|
||
class PyZMQCommand(distutils.cmd.Command): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Latest releases are:
indy-vdr: 0.4.3
askar: 0.4.3
indy-credx: 1.1.1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dont we drop the dev-setup directory ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we keep it should we change the ubuntu-2204 file instead of the ubuntu-2004
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sorry, I was not paying attention to the location of the file, just the changes