Package: rkvst-simplehash
RKVST Simplehash in pythonPrescribed python code that defines the hashing algorithm for DLT Anchoring.SupportThis package currently is tested against Python versions 3.7,3.8,3.9, 3.10 and 3.11.The current default version is 3.7 - this means that this package will not
use any features specific to versions 3.8 and later.After End of Life of a particular Python version, support is offered on a best effort
basis. We may ask you to update your Python version to help solve the problem,
if it cannot be reasonably resolved in your current version.InstallationUse standard python pip utility:python3-mpipinstallrkvst-simplehashIf your version of python3 is too old an error of this type or similar will be emitted:NoteERROR: Could not find a version that satisfies the requirement rkvst-simplehash (from versions: none)
ERROR: No matching distribution found for rkvst-simplehashWhich VersionTo Determine which version of the simple hash script to use, i.e. simplehashv1 or simplehashv2,
look at the response from thev1alpha2/blockchainlist api and correlate the version with thehash_schema_versionin thesimple_hash_detailssection.Alternatively look for the SimpleHashInfo section in the rkvst app, found on the transaction page
of a simple hash event, and correlate the version withschema_version.ExamplesYou can then use the code to recreate the simple hash of a list of SIMPLE_HASH events from RKVST.Importing in own codePermissioned Assets V1"""From a list of events.
"""fromrkvst_simplehash.v1import(anchor_events,SimpleHashError,)withopen("credentials/token",mode="r",encoding="utf-8")astokenfile:auth_token=tokenfile.read().strip()# SimpleHashClientAuthError is raised if the auth token is invalid or expired.# if any pending events a SimpleHashPendingEventFound error will be thrown# if any of the events do not contain the required field then a SimpleHashFieldMissing error will be thrownapi_query=("https://app.rkvst.io""/archivist/v2/assets/-/events""?proof_mechanism=SIMPLE_HASH""&timestamp_accepted_since=2022-10-07T07:01:34Z""&timestamp_accepted_before=2022-10-16T13:14:56Z""&order_by=SIMPLEHASHV1")try:simplehash=anchor_events(api_query,auth=auth_token)exceptSimpleHashErrorasex:print("Error",ex)else:print("simplehash=",simplehash)Permissioned Assets V2"""From a list of events.
"""fromrkvst_simplehash.v2import(anchor_events,SimpleHashError,)withopen("credentials/token",mode="r",encoding="utf-8")astokenfile:auth_token=tokenfile.read().strip()# SimpleHashClientAuthError is raised if the auth token is invalid or expired.# if any pending events a SimpleHashPendingEventFound error will be thrown# if any of the events do not contain the required field then a SimpleHashFieldMissing error will be thrownapi_query=("https://app.rkvst.io""/archivist/v2/assets/-/events""?proof_mechanism=SIMPLE_HASH""&timestamp_accepted_since=2022-10-07T07:01:34Z""&timestamp_accepted_before=2022-10-16T13:14:56Z""&order_by=SIMPLEHASHV1")try:simplehash=anchor_events(api_query,auth=auth_token)exceptSimpleHashErrorasex:print("Error",ex)else:print("simplehash=",simplehash)Public Assets V1"""From a list of events.
"""fromrkvst_simplehash.v1import(anchor_events,SimpleHashError,)# SimpleHashClientAuthError is raised if the auth token is invalid or expired.# if any pending events a SimpleHashPendingEventFound error will be thrown# if any of the events do not contain the required field then a SimpleHashFieldMissing error will be thrownapi_query=("https://app.rkvst.io""/archivist/v2/publicassets/-/events""?proof_mechanism=SIMPLE_HASH""&timestamp_accepted_since=2022-10-07T07:01:34Z""&timestamp_accepted_before=2022-10-16T13:14:56Z""&order_by=SIMPLEHASHV1")try:simplehash=anchor_events(api_query)exceptSimpleHashErrorasex:print("Error",ex)else:print("simplehash=",simplehash)Public Assets V2"""From a list of events.
"""fromrkvst_simplehash.v2import(anchor_events,SimpleHashError,)# SimpleHashClientAuthError is raised if the auth token is invalid or expired.# if any pending events a SimpleHashPendingEventFound error will be thrown# if any of the events do not contain the required field then a SimpleHashFieldMissing error will be thrownapi_query=("https://app.rkvst.io""/archivist/v2/publicassets/-/events""?proof_mechanism=SIMPLE_HASH""&timestamp_accepted_since=2022-10-07T07:01:34Z""&timestamp_accepted_before=2022-10-16T13:14:56Z""&order_by=SIMPLEHASHV1")try:simplehash=anchor_events(api_query)exceptSimpleHashErrorasex:print("Error",ex)else:print("simplehash=",simplehash)Command LineThis functionality is also available on the cmdline.Using a virtual env and published wheelThis can be executed anywhere using a virtualenv and published wheel.
Credentials are stored in files in credentials directory.Using an auth token directly and for permissioned assets#!/usr/bin/env bash#python3-mvenvsimplehash-venvsourcesimplehash-venv/bin/activatepython3-mpipinstall-qrkvst_simplehashapi_query="https://app.rkvst.io"api_query+="/archivist/v2/assets/-/events"api_query+="?proof_mechanism=SIMPLE_HASH"api_query+="&timestamp_accepted_since=2022-10-07T07:01:34Z"api_query+="&timestamp_accepted_before=2022-10-16T13:14:56Z"api_query+="&order_by=SIMPLEHASHV1"rkvst_simplehashv1\--auth-token-file"credentials/token"\"${api_query}"deactivaterm-rfsimplehash-venvOr for schema version 2:#!/usr/bin/env bash#python3-mvenvsimplehash-venvsourcesimplehash-venv/bin/activatepython3-mpipinstall-qrkvst_simplehashapi_query="https://app.rkvst.io"api_query+="/archivist/v2/assets/-/events"api_query+="?proof_mechanism=SIMPLE_HASH"api_query+="&timestamp_accepted_since=2022-10-07T07:01:34Z"api_query+="&timestamp_accepted_before=2022-10-16T13:14:56Z"api_query+="&order_by=SIMPLEHASHV1"rkvst_simplehashv2\--auth-token-file"credentials/token"\"${api_query}"deactivaterm-rfsimplehash-venvUsing a client id and secret and for permissioned assets#!/usr/bin/env bash#python3-mvenvsimplehash-venvsourcesimplehash-venv/bin/activatepython3-mpipinstall-qrkvst_simplehashapi_query="https://app.rkvst.io"api_query+="/archivist/v2/assets/-/events"api_query+="?proof_mechanism=SIMPLE_HASH"api_query+="&timestamp_accepted_since=2022-10-07T07:01:34Z"api_query+="&timestamp_accepted_before=2022-10-16T13:14:56Z"api_query+="&order_by=SIMPLEHASHV1"CLIENT_ID=$(catcredentials/client_id)rkvst_simplehashv1\--client-id"${CLIENT_ID}"\--client-secret-file"credentials/client_secret"\"${api_query}"deactivaterm-rfsimplehash-venvOr for schema version 2:#!/usr/bin/env bash#python3-mvenvsimplehash-venvsourcesimplehash-venv/bin/activatepython3-mpipinstall-qrkvst_simplehashapi_query="https://app.rkvst.io"api_query+="/archivist/v2/assets/-/events"api_query+="?proof_mechanism=SIMPLE_HASH"api_query+="&timestamp_accepted_since=2022-10-07T07:01:34Z"api_query+="&timestamp_accepted_before=2022-10-16T13:14:56Z"api_query+="&order_by=SIMPLEHASHV1"CLIENT_ID=$(catcredentials/client_id)rkvst_simplehashv2\--client-id"${CLIENT_ID}"\--client-secret-file"credentials/client_secret"\"${api_query}"deactivaterm-rfsimplehash-venvQuerying the public assets (does not require authentication)#!/usr/bin/env bash#python3-mvenvsimplehash-venvsourcesimplehash-venv/bin/activatepython3-mpipinstall-qrkvst_simplehashstart_time="2022-11-16T00:00:00Z"end_time="2022-11-17T00:00:00Z"rkvst_url="https://app.rkvst.io"endpoint="archivist/v2/publicassets/-/events"api_query="https://app.rkvst.io"api_query+="/archivist/v2/publicassets/-/events"api_query+="?proof_mechanism=SIMPLE_HASH"api_query+="&timestamp_accepted_since=2022-10-07T07:01:34Z"api_query+="&timestamp_accepted_before=2022-10-16T13:14:56Z"api_query+="&order_by=SIMPLEHASHV1"rkvst_simplehashv1"${api_query}"deactivaterm-rfsimplehash-venvOr for schema version 2:#!/usr/bin/env bash#python3-mvenvsimplehash-venvsourcesimplehash-venv/bin/activatepython3-mpipinstall-qrkvst_simplehashstart_time="2022-11-16T00:00:00Z"end_time="2022-11-17T00:00:00Z"rkvst_url="https://app.rkvst.io"endpoint="archivist/v2/publicassets/-/events"api_query="https://app.rkvst.io"api_query+="/archivist/v2/publicassets/-/events"api_query+="?proof_mechanism=SIMPLE_HASH"api_query+="&timestamp_accepted_since=2022-10-07T07:01:34Z"api_query+="&timestamp_accepted_before=2022-10-16T13:14:56Z"api_query+="&order_by=SIMPLEHASHV1"rkvst_simplehashv2"${api_query}"deactivaterm-rfsimplehash-venv