#iDIDit: What’s more important? …the name of something or the something?

Thoughts to think about:

  • What’s more important? …the name of something or the something?
  • Under what conditions might the relative importance change?
  • What is the difference between a name, an identifier (see below for a definition), and a label?

Here’s a few examples to ponder. The discussion follows at the end of this article.

Examples

Apple (A-p-p-l-e) and Apples

Name: apple (a-p-p-l-e)

 

 

Figure 1. Somethings: (a) real apple, (b) ceramic apple, (c) apple candle, and (d) a bad apple ūüėČ

House Numbers and Houses

Name: A specific house number

 

 

Figure 2. Somethings: (a) house with a specific numeric house number, and (b) house with script house number with a specific value

Addresses and Houses

Name: A specific address

 

 

Figure 3. Somethings: (a) house with specific numbered street address, (b) property with a specific numbered street address, and (c) house specific numeric house number and a specific numbered street address

Domain Names and DNS Resource Records

This (and the following) example are important because they represent 2 completely different, independent databases indexed/keyed by the same name: an Internet domain name.

Name: Domain name microsoft.com

DNSQUery-org3

 

DNSQUery-org0

 

DNSQUery-org1Figure 4. Somethings: DNS Resource Records for microsoft.com:
(top) single “A” record (default), (middle) all “A” records, and (bottom) all resource records

To learn more about DNS, read DNS (Domain Name Service): A Detailed, High-level Overview.

Domain Names and WHOIS Database Records

This (and the previous) example are important because they represent 2 completely different, independent databases indexed/keyed by the same name: an Internet domain name. Thank you goes to Daniel Hardman for suggesting this one.

Name: Domain name microsoft.com

whois

Figure 5. Somethings: WHOIS Database Record for microsoft.com

Github Project Respository Names

Name: https://github.com/mwherman2000/indy-arm.git

Read Git repository internal format explained  for a detailed explanation of the structure of the .git folder that is created in the local file system when a GitHub project repository is cloned using, for example:

git clone https://github.com/mwherman2000/indy-arm.git

Several additional references (links) are also included in the article.

dotgit-folder-contents

Figure 6. Somethings: GitHib Project Repository .git Local Folder

Discussion

TODO

Roles of a Name

  • noun: a-p-p-l-e
  • a partial identifier/address: a house number
  • a more complete identifier/address: the address of a house
  • a more complete identifier/address of a related entity: the address of a property that has house
  • a unique identifier: a domain name (although domain names can be used to index completely different collections – e.g. DNS Resource Records and WHOIS Database Records)

TODO

What a name is, what it is interpreted to be, and what it actually is can be are completely different things.

Possession of a something vs. control of something aren’t necessarily the same thing.

TODO

What is an “identifier”?

identifier

Figure 6. Identifier: Definition

 

 

2 Comments

Filed under Uncategorized

DNS (Domain Name Service): A Detailed, High-level Overview

How’s that for a confuding title?¬† In a recent email discussion, a colleague compared the Decentralized Identifier framework to DNS …suggesting they were similar.¬† I cautiously tended to agree but felt I had an overly simplistic understanding of DNS at a protocol level.¬† That email discussion led me to learn more about the deeper details of how DNS actually works – and hence, this article.

On the surface, I think most people understand DNS to be a service that you can pass a domain name to and have it resolved to an IP address (in the familiar nnn.ooo.ppp.qqq format).

domain name => nnn.ooo.ppp.qqq

Examples:

  1. If you click on Google DNS Query for microsoft.com, you’ll get a list of IP addresses associated with the Microsoft’s corporate domain name microsoft.com.
  2. If you click on Google DNS Query for www.microsoft.com, you’ll get a list of IP addresses associated with the Microsoft’s corporate web site¬†www.microsoft.com.

NOTE: The Google DNS Query page returns the DNS results in JSON format. This isn’t particular or specific to DNS. It’s just how the Google DNS Query page chooses to format and display the query results.

DNS is actually much more than a domain name to IP address mapping.¬† Read on…

DNS Resource Records

There is more to the DNS Service database than these simple (default) IP addresses.¬† The DNS database stores and is able to return many different types of service-specific IP addresses for a particular domain.¬† These are called DNS Resource Records. Here’s a partial list from http://dns-record-viewer.online-domain-tools.com:

Most APIs only support the retrieval of one Resource Record type at a time (which may return multiple IP addresses of that type). Some APIs default to returning A records; while some APIs will only return A records. Caveat emptor.

To see a complete set of DNS Resource Records for microsoft.com, click on DNSQuery.org query results for microsoft.com¬†and scroll down to the bottom of the results page …to see the complete response (aka authoritative result). It will look something like this:

DNSQUery-org1

Figure 1. DNS Resource Records for microsoft.com: Authoritative Result

NOTE: The Resource Record type is listed in the fourth column: TXT, SOA, NS, MX, A, AAAA, etc.

DNS Protocol

The most interesting new information/learnings is about the DNS protocol.¬† It’s request/response …nothing new here.¬† It’s entirely binary …to be expected given its age and the state of technology at that time. Given how frequently DNS is used by every computer on the planet, the efficientcy of a binary protocol also makes sense. The¬†IETF¬†published the original specifications in¬†RFC 882¬†and¬†RFC 883¬†in November 1983.

The new part (for me) is that an API typically doesn’t “download” the entire authoritative set of DNS Resource Records all at once for a particular domain, the most common API approach is to request the list of IP addresses (or relevant data) for a particular Resource Record type for a particular domain.

The format of a sample DNS request is illustrated in the following figure:

messages-requestFigure 2. Sample DNS Request [CODEPROJECT]

It’s binary. The QTYPE (purple cells on the right side) defines the type of query. In this case 0x0F is a request for an MX record; hence, this is a request for the data that describes microsoft.com’s external email server interface.

NOTE: The “relevant data” isn’t always an IP address or a list of IP addresses. For example, response may include another domain name, subdomain name, or, in some cases, simply some unstructured text (as far as the DNS specification is concerned).

Here is a typical response for the above sample request:

messages-responseFigure 3. Sample DNS Response [CODEPROJECT]

The response in turn is also binary. In this case, DNS has responded with 3 answers; that is, 3 subdomain names: mailc, maila, and mailb – each with a numerical preference (weight).

The ANY Resource Record Type

There is also a “meta” Resource Record Type called ANY that, as you might guess, requests a collection of all of the different Resource Record type records.¬† This is illustrated in Figure 1 above.

Best regards,
Michael Herman (Toronto/Calgary/Seattle)

2 Comments

Filed under Uncategorized

#iDIDit: Trusted Digital Web: Architecture Reference Model v0.4

Michael Herman (Toronto/Calgary/Seattle)
Hyperonomy Business Blockchain Project / Parallelspace Corporation
December 2018

Draft document for discussion purposes.
Update cycle: As required ‚Äď sometimes several times in a single day.

Trusted Digital Web: Architecture Reference Model

The key components of the Trusted Digital Web: Architecture Reference Model (TDW ARM) include:

  • Trusted Digital Assistant
  • Decentralized Identifiers (DIDs) and DID Resolution Protocols
  • DID Entities: Actors and Things
  • Wallet Subledgers
  • Cloud Wallets
  • Cloud Agents

Click the figure to enlarge it.

Trusted Digital Web 0.4

HBB-Trusted Digital Web v0.4

Trusted Digital Web 0.3

Trusted Digital Web v0.3.png

Trusted Digital Web 0.2

Trusted Digital Web v0.2.png

2 Comments

Filed under Uncategorized

#iDIDit: [OLD] Decentralized Identifiers (DIDs) Architecture Reference Model (ARM)

IMPORTANT:¬†Don‚Äôt read this version of this article about the ‚ÄúDID‚ÄĚ ARM.¬† This is an old article but it remains here as a tombstone for the many places where this URL has been posted.¬† Please read:¬†Hyperledger Indy/Sovrin Comprehensive Architecture Reference Model (ARM).¬†(click¬†here).

Michael Herman (Toronto/Calgary/Seattle)
Hyperonomy Business Blockchain Project / Parallelspace Corporation
December 2019

Draft Versions for Discussion Purposes Only

QUESTION: Are these diagrams precise, accurate, and complete? In particular, are the components and relationships in the Technology/Infrastructure Architecture layer precise, accurate, and complete? Please add a comment to the end of this article or email me at mwherman@parallelspace.net.

Context

The Decentralized Identifiers (DIDs) architecture reference model diagrams that follow were created to support the following discussion…

From: Michael Herman (Parallelspace)
Sent: December 20, 2018 10:01 AM
To: public-credentials@w3.org
Subject: Review of the current draft DID specification

I’ve recently started a detailed review of the current draft DID specification document and to be direct, I have found even the first few sections to be quite imprecise and confuding.

I’ve started creating a new GitHub issue every time I’ve encountered a problem. 11 issues so far and I’m barely into section 2.

I’m reviewing the draft spec from the perspectives of an Enterprise Architect and experienced blockchain developer. Most of the issues relate to a lack of precision in the use of key concepts and terminology …as well as unnecessary IMHO overloading of these key concepts/terms …things that should be prohibitive in a spec document.

That’s a bit of a brutal introduction… But those who have met me (in Basel for example) understand my proper passion around these topics.

I also understand there is a rush to advance this document from a Community draft specification to something with a more formal status. I honestly don’t think the document is ready …but I don’t know what the “bar” is.

What’s the best way to proceed? I’m not sure… …keep creating new issues? …write a lengthy position paper? … create a new PR?

Your thoughts?

Architecture Reference Model Diagrams

These diagrams are part of a larger effort to create an architecture reference model for the entire Hyperledger Indy software platform and Sovrin governance model.¬† The achieve this goal, a deep and precise of the draft Decentralized Identifiers (DIDs) specification is required.¬† I appreciate all of your help and input.¬† …Michael

p.s. These diagrams will be updated regularly – sometimes a couple times per day.

p.p.s. The Open Group’s ArchiMate 3.0 visual design notation for Enterprise Architecture was used to create these diagrams using Archi, the open source ArchiMate modeling tool.

Click on any of these diagrams to enlarge them.

Version 0.14 – January 1, 2019

Relative to version 0.11, version 0.14 recognizes Software Agents as Actors. Scroll down to Version 0.11 – December 30, 2018 for the most complete set of architectural principles.

DID Logical Architecture v0.14Figure 0.14 Decentralized Identifiers (DIDs) – Architecture Reference Model (ARM) v0.14 – January 1, 2019

Version 0.11 – December 30, 2018

The updates in version 0.11 of the Decentralized Identifiers (DIDs) ARM (architecture reference model) are limited to the Business Architecture Layer; more specifically, clarifying to roles and relationships between:

  • Actors (Persons and Organizations), and
  • Things (Pets, Cars, Houses, Business Documents, Products, Assemblies and Parts).

The role of Actor in the model is a key learning that came out of the Basel workshop.

I’ve taken the idea a step further to find a proper “place and set of relationships” for the Sovrin concept of “Things”.¬† I believe I’ve (successfully?) done that but am looking for feedback/consensus about these ideas.¬† They are presented visually in the diagram below.

The new Business Architecture basic principles are:

  1. An Actor is either a Person or an Organization.
  2. Each Person or Organization has one or more SS Digital Identities associated with it.
  3. Actors (Persons and Organizations) participate in Processes.
  4. A Process acts on/accesses Things (e.g. Pet, Car, House, Business Document, Product, Assembly, Part) to perform work.
  5. Business Documents, Products, Assemblies and Parts are different from the traditional or generic Sovrin concept of a Thing (e.g. Pet, Car, House).
  6. Each Thing has one or more SS Digital Identities associated with it.

To bridge from previous versions of the ARM (see below), the following Application Architecture basic principles also apply:

  1. A DID Document is a JSON-LD serialization of a DID Entity.
  2. A DID Entity is the in-memory, application-specific object that represents a de-serialized DID Document.
  3. A DID Entity is what application developers work with (program against) at the Application Architecture level of an app.
  4. DID Entities have a set of attributes such as the following:
    • id (DID)
    • service (endpoints)
    • authentication
    • publicKey
    • @context
    • etc.
  5. “id (DID)” exists as an attribute of a DID Entity (and by implication, as an attribute of DID Document, the JSON-LD serialization of the corresponding DID Entity).
  6. The “id (DID)” attribute is given the nickname “DID” (aka Decentralized Identifier) for convenience; but more importantly, to clarify what a DID specifically refers to (as well as to clarify what the term DID specifically does not refer to).¬† “DID” should only be used to refer to the “id (DID)” attribute of a DID Entity (or DID Document).
  7. DIDs are used to index, find, and retrieve DID Documents from the Technology/Infrastructure Architecture layer.
  8. DID Documents represent the primary object type that is exchanged between the Application Architecture layer and the Technology/Infrastructure layer.

DID Logical Architecture v0.11Figure 0.11 Decentralized Identifiers (DIDs) – Architecture Reference Model (ARM) v0.11 – December 30, 2018

 

Version 0.10 – December 21, 2018DID Logical Architecture v0.10Figure 0.10 Decentralized Identifiers (DIDs) – Architecture Reference Model (ARM) v0.10 – December 21, 2018

 

Version 0.9 – December 21, 2018

DID Logical Architecture v0.9.pngFigure 0.9 Decentralized Identifiers (DIDs) – Architecture Reference Model (ARM) v0.9 – December 21, 2018

 

Best regards,

Michael Herman (Toronto/Calgary/Seattle)

2 Comments

Filed under Uncategorized

Confuding, Confuded, and Confudsion

: synonyms confusing. Result of spreading fear, uncertainty and doubt in the minds of new project participants. “The specification was confuding to most new developers.”

: synonyms confused. An adjective describing the feelings of fear, uncertainty and doubt about a topic or concept. “The developers became confuded while trying to decipher the meaning, intent and practical application of the specification”.

: synonyms confusion. A state of mind resulting from having feelings of fear, uncertainty and doubt about a topic. “The document created a lot of confudsion with respect to the meaning, intent and practical application of the specification”.

 

3 Comments

Filed under Uncategorized

Refactoring UBL 2.2 business documents for enacting business processes on the blockchain [WIP]

Michael Herman (Toronto/Calgary/Seattle)
Hyperonomy Business Blockchain Project / Parallelspace Corporation
December 2018 (completed January 2019)

The purpose of this article is to describe the background and rationale for set of proposed extensions to the UBL 2.2 business document specification to make UBL schema better suited for  creating distributed business applications on the blockchain. The proposed set of extensions is referred to as the Universal UBL Extensions.

Hyperonomy Business Blockchain (HBB)

Hyperonomy Business Blockchain (HBB) is a horizontal software applications platform for supporting standards-based, end-to-end, general-purpose, trusted business processing on a global scale.

HBB Standards

A key characteristic of HBB is its reliance on prevailing standards for:

  1. Business document definitions (business document schema)
  2. Executable business process definitions (workflow template definitions)
  3. Digital identity
  4. General-purpose, programmable blockchain platforms
  5. Microsoft .NET Core Common Language Runtime (CLR) for virtual machine support

For business document schema, HBB is reliant on the UBL 2.2 (Universal Business Language) specification from the OASIS group.

For defining workflow templates, HBB is reliant on the BPMN 2.0 specification from the Object Management Group (OMG).

For digital identity support, HBB is leveraging:

Hyperledger Indy is a distributed ledger, purpose-built for decentralized identity. It provides tools, libraries, and reusable components for creating and using independent digital identities rooted on blockchains or other distributed ledgers so that they are interoperable across administrative domains, applications, and any other ‚Äúsilo.‚ÄĚ [INDY]

Sovrin is a decentralized, global public utility for self-sovereign identity.¬†Self-sovereign¬†means a lifetime portable identity for any person, organization, or thing. It‚Äôs a smart identity that everyone can use and feel good about. Having a self-sovereign identity allows the holder to present verifiable credentials in a privacy-safe way. These credentials can represent things as diverse as an airline ticket or a driver’s license. [SOVRIN]

Decentralized Identifiers (DIDs) are a new type of identifier for verifiable, “self-sovereign” digital identity. DIDs are fully under the control of the DID subject, independent from any centralized registry, identity provider, or certificate authority. DIDs are URLs that relate a DID subject to means for trustable interactions with that subject. DIDs resolve to DID Documents ‚ÄĒ simple documents that describe how to use that specific DID. Each DID Document contains at least three things: cryptographic material, authentication suites, and service endpoints. Cryptographic material combined with authentication suites provide a set of mechanisms to authenticate as the DID subject (e.g., public keys, pseudonymous biometric protocols, etc.). Service endpoints enable trusted interactions with the DID subject. [DID]

[Sovrin] DIDs are created, stored, and used with verifiable claims. [The Sovrin DID Method Specification] covers how these DIDs are managed. It also describes related features of Sovrin of particular interest to DID owners, guardians, and developers. [SOVRINREGISTRY]

For general-purpose, programmable blockchain platform support, HBB is reliant on:

  • Stratis Platform for creating highly composable, performant, reliable, and trustworthy custom blockchain platforms, and
  • .NET Core Common Language Runtime (CLR) for virtual machine support.

The Stratis Full Node is the engine that powers the Stratis blockchain network. A future-proof and environmentally sustainable consensus protocol, which uses a Proof-Of-Stake (PoS) algorithm, drives each Full Node in the network.

.NET Core¬†is an¬†open-source, general-purpose development platform maintained by Microsoft and the .NET community on¬†GitHub. It’s cross-platform (supporting Windows, macOS, and Linux) and can be used to build device, cloud, and IoT applications.

UBL (Univeral Business Language) Specification

UBL documents are conceived for the purpose of interchange between disparate systems to replace existing trade documents. [HOLMAN1]

UBL is an OASIS specification that defines schema for the 81 most common digital business documents used in supply chain or other online commerce scenarios. The current version of the UBL specification is known as OASIS Universal Business Language version 2.2.

The OASIS Universal Business Language (UBL) is intended to help solve these problems by defining a generic XML interchange format for business documents that can be restricted or extended to meet the requirements of particular industries. Specifically, UBL provides the following [UBL22]:

  • A suite of structured business objects and their associated semantics expressed as reusable data components and common business documents.
  • A library of XML schemas for reusable data components such as ‚ÄúAddress‚ÄĚ, ‚ÄúItem‚ÄĚ, and ‚ÄúPayment‚ÄĚ‚ÄĒthe common data elements of everyday business documents.
  • A set of XML schemas for common business documents such as ‚ÄúOrder‚ÄĚ, ‚ÄúDespatch Advice‚ÄĚ, and ‚ÄúInvoice‚ÄĚ that are constructed from the UBL library components and can be used in generic procurement and transportation contexts.

A key premise of a UBL business document schema is that is complete, standalone, physical representation of the underlying conceptual business or application object. The primary intended purpose of documents conformant with the UBL specification is: electronic document exchange and rendering/printing.

An example receiver application is a print facility that can print any instance of a given UBL document type without having to perform any calculations nor need even know the underlying calculation model.

For the purposes of this article, the following UBL Invoice schema serves as the primary use case. The first page of  the UBL Invoice schema looks like the following.

UBL-InvoiceFigure 1. UBL Invoice Schema Example (Partial)

Each one of the 81 UBL business document schema is a complete, holistic representation of a particular business document (e.g. Invoice, Business Card, Bill of Lading, Order, Request for Quotation, Forwarding Instructions, etc.).

Blockchain Requirements for UBL Business Documents

To represent UBL Business Documents more effectively and more efficiently for use in blockchain-based distributed business applications, the following requirements are important:

  1. Extremely compact and efficient binary serialization of each entity (and subentity)
  2. Refactoring/normalization/decomposition of large aggregated entities into small, separate, external subentities (e.g. 5-10 properties per entity) aggregated together by-reference (vs. by-value)
  3. Re-use of existing (non-fungible) subentities wherever and whenever possible to conserve space and eliminate replication and redundancy wherever and whenever possible
  4. Secure, permanent, immutable, and trusted (“trusted in a trust-less way”)

Detailed Requirements

Universal UBL (UUBL) is a set of extensions to (or superset of) the UBL 2.2 specification that provides enhanced support for storing and interacting with digital business documents on a digital identity/general-purpose blockchain hybrid applications platform.  The UUBL extensions are an answer to the 4 blockchain requirements outlined in the previous section.

Requirement 1. Compact and Efficient Binary Serialization

The requirement for extremely compact and efficient binary serialization of each entity (and subentity) can be fulfilled by various software serialization solutions including SerentityData Variable-byte, Statistically-based Entity Serialization. The SerentityData project can be found on Github. SerentityData is the author’s preferred solution.

Requirement 2. Refactoring/Normalization/Decomposition

By definition the UBL schema definitions are both complete and monolithic – they completely description a particular digital business document in its entirety.

For storage on a blockchain and for direct reference by (a) code running in a traditional smart contact or (b) a new generation of business process workflow templates running directly on a workflow-engine-based virtual machine, the potentially large size of a typical, monolithic UBL business document makes them prohibitively large and prohibitively expense to store, process, and manage on a typical general-purpose programmable blockchain.

A replicable solution for refactoring/normalizing/decomposing each UBL document schema into a collection of subentity schema is need.  A solution is proposed by the author in the section Universal UBL: Extensions for the Blockchain.

Requirement 3. Re-use of Subentities

Closely couple with Requirement 2, is the re-use of existing subentities wherever and whenever possible to conserve space and eliminate replication and redundancy wherever and whenever possible. Backing this requirements is the knowledge that most every-day business documents (i.e. those representable by the 81 UBL business document schema) are in fact permanent (subject an organization’s retention policies), immutable, constant-valued documents once they are created.¬† The simplest example is Waybill.¬† Once you have created your (Federal Express or DHL) Waybill, it is a permanent, immutable, constant-valued business document once it has been created and printed (and is not destroyed before it is used).

Given these characteristics of business document in general (and UBL business documents in particular), business documents represent a proper subset of a broader class of entities called Non-Fungible Entities (or NFEs).¬† Another significant class of NFEs are NFTs (Non-Fungible Tokens) …of which, the Ethereum-based CryptoKitties are the penultimate example.

The author’s thesis is that, given business documents stature as NFEs, business documents (and NFEs generally) can be implemented and best managed using the emerging digital identity, in particular the self-sovereign identity (SSI) platforms, that are “coming to market”.

The best platform, from amongst these, in the author’s opinion, is the Hyperledger Indy SSI software platform operated under the stewardship of the Sovrin SSI governance framework.

Requirement 4. Secure, Permanent, Immutable, Trusted and Friction-less

This set of adjectives, plus a few others, symbolize and capture the essence of the intersection between the world of digital business documents and the world (sometimes what I call the religion) of the blockchain.

It is in this intersection between digital business documents and the blockchain that the greatest opportunities lie for supporting friction-less, trusted, standards-based end-to-end business process on a global scale.

Universal UBL: Extensions for the Blockchain

The following sections detail the envisioned solution for each of the above 4 requirements.

Requirement 1. Compact and Efficient Binary Serialization

Solution: SerentityData Variable-Byte Entity Serialization

The goal of the serentitydata project is to provide support the design and development of enterprise and Internet class distributed applications using blockchain technologies. This includes tools and libraries (code), frameworks, how-to documentation, and best practices for enterprise distributed application development. The serentitydata project has a specific focus on the robust and efficient design and management of immutable, historized, and auditable data stored on a blockchain.

TODO

Requirement 2. Refactoring/Normalization/Decomposition

Solution: Refactoring/Normalization/Demposition of UBM 2.2 Schema into Subentities Supported by the W3C DID (Decentralized Identifiers) Specification.

TODO

UUBL-InvoiceFigure 2. UUBL Invoice Schema Example
<ucbc:DID>did:hbb:00AE77FF-13F5-4268-A8EE-BF62FE904F50</ucbc:DID>

TODO

UUBL-AccountingSupplierPartyFigure 3. UUBL Accounting Supplier Party Schema Example
<ucbc:DID>did:hbb:00AE77FF-13F5-4268-A8EE-BF62FE904F51</ucbc:DID>

 

TODO

UUBL-PartyFigure 4. UUBL Party Schema Example
<ucbc:DID>did:hbb:00AE77FF-13F5-4268-A8EE-BF62FE904F53</ucbc:DID>

TODO

UUBL-PostAddressFigure 5. UUBL Postal Address Schema Example
<ucbc:DID>did:hbb:00AE77FF-13F5-4268-A8EE-BF62FE904F54</ucbc:DID>

TODO

Requirement 3. Re-use of Subentities

TODO

Requirement 4. Secure, Permanent, Immutable, Trusted and Friction-less

TODO

TODO

References

Appendix A – Ken Holman – Personal Communication – December 2, 2018 6:38 PM

From: G. Ken Holman <g.ken.holman@gmail.com>
Sent: December 2, 2018 6:38 PM
To: Michael Herman (Parallelspace) <mwherman@parallelspace.net>; William Olders <wolders@xalgorithms.org>; stephenrowlison@gmail.com
Cc: Michael Blanchet <michael.blanchet@gmail.com>; Larry Strickland <lstrickland@dkl.com>
Subject: RE: Introduction by Ken between Michael and Bill – Business Document “Facts”

At 2018-12-02 14:13 +0000, Michael Herman (Parallelspace) wrote:
Ken, Bill and Stephen, I do have a question…

I’ll take on the answer … this is the area of my contribution to the project.¬†I’ve copied Michael and Larry just for their curiosity as I think they’ll find this discussion interesting.

In the¬†<http://docs.oasis-open.org/ubl/os-UBL-2.2/xml/UBL-Invoice-2.1-Example.xml>http://docs.oasis-open.org/ubl/os-UBL-2.2/xml/UBL-Invoice-2.1-Example.xml example, if the value of the <cac:AccountingSupplierParty. cac:PostalAddress component/subelement of an Invoice already exists as a “separate document” somewhere addressable by a URL (or indirectly locatable via a URN)…

* Is there a standard/recommended/off-the-wall way for a specific Invoice to specify the value of AccountingSupplierParty. PostAddress by reference …instead of “by value” (i.e. instead of the long-hand, replicated approach seen in the example)?

No. That isn’t the UBL way. In UBL all values must be manifest and redirecting selective components to copies found elsewhere in the document is not accommodated:

http://docs.oasis-open.org/ubl/os-UBL-2.2/UBL-2.2.html#S-MANIFEST-VALUES

Of course it is necessary to point out to other documents, but there is, say, no XPath or other addressing mechanism built into the UBL serialization to accommodate shared fragmentation.

The UBL committee has been standardizing a semantic library of the business documents and their business objects, and a number of syntactic serializations of those semantics have been specified, XML being the only normative one.
Others in ASN.1 and JSON are available, but they are not normative.

* What does/would an acceptable XML “syntax” look like/might look like?

I would use XPath for addressing a point into an XML document. XPointer would be used if you wanted to point to a range of items found in an XML document. Within an XML document I would use ID/IDREF, but those properties are not available in UBL.

Not many people realize that UBL was not built using XML/XSD, it was built using CCTS. CCTS doesn’t have ID/IDREF concepts.

* Is there standard terminology for referring generally to a subcomponent/subelement of an Invoice (or any other) UBL document? I’m currently using the term Fact to refer to each of the subcomponents (applied recursively if necessary)?

No such terminology is used within the committee … such a concept isn’t leveraged because the syntax is but a straightforward manifest serialization of the semantic components. This is best for interchange between independent platforms and also for things such as rendering.

A recipient of a UBL document should have everything they need without needing to calculate anything … the calculus of the values cannot be assumed to be known by the recipient.

UBL documents are conceived for the purpose of interchange between disparate systems to replace existing trade documents.

Appendix B – NEO-NATION and HYPERONOMY BUSINESS BLOCKCHAIN Infographic

TODO

NEO-NATION1

TODO

Appendix C – SerentityData Variable-byte, Statistically-based Entity Serialization

The SerentityData Entity Serialization and Field Encoding library fulfills Blockchain Requirement 1 for the Universal UBL (UUBL) extensions to the UBL 2.2 business document schema specification.

The SerentityData Entity Serialization and Field Encoding description has been moved to its own article located here: SerentityData Variable-byte, Statistically-based Entity Serialization & Field Encoding.

Best regards,

Michael Herman (Toronto/Calgary/Seattle)

1 Comment

Filed under Uncategorized

Are Canadian banks trafficking in the digital identities of millions of Canadians?

In light of the recent Zuckerberg testimony in front of the U.S. Congress, the May 2018 deadline for organizations to implement General Data Protection Regulation (GDPR) data privacy regulations[7], and the imminent release of the SecureKey verify.me digital identity system, an important question is:

Are Canadian banks guilty of trafficking in, monetizing, and profiting from the digital identities of millions of Canadians, with the support of IBM and SecureKey as their key technology partners?

On October 18, 2016, SecureKey Technologies Inc., a Toronto-based provider of identity and authentication solutions, announced that it has raised:

“$27 million CAD in growth capital to fund the commercial rollout of a privacy-enhancing digital identity network. Teaming up with SecureKey on this initiative and participating in the funding round are leading financial institutions: BMO Bank of Montreal, Bank of Nova Scotia, CIBC, Desjardins, Royal Bank of Canada and TD.”[1]

On March 20, 2017, IBM and SecureKey announced that they were:

“working together to enable a new digital identity and attribute sharing network based on IBM [Hyperledger Fabric] Blockchain.”[2]

Subsequently in early 2018, SecureKey released two additional documents[4][5] that describe both the business model and technology platform for the verify.me¬†digital identity system. Verify.me is SecureKey’s IBM Hyperledger distributed ledger (blockchain) based digital identity system supported by Canada’s largest 5 banks (as well as other institutions):

  • The Toronto-Dominion Bank (TD Bank)
  • Bank of Montreal (BMO)
  • Canadian Imperial Bank of Commerce (CIBC)
  • Bank of Nova Scotia (Scotiabank)
  • Royal Bank of Canada (RBC)

Additional details on the verify.me digital identity system were also presented at the Australian Payments Network conference in August, 2017[3].

The Business Model

The most concerning part of this partnership between SecureKey, IBM, and the Canadian banks is the partnership’s intent to monetize and profit from the trafficking of digital identities of individual Canadians based on the following and similar excerpts from¬†[4][5]:

The Business Model-Healthcare

Figure 1. SecureKey verify.me Business Model

The SecureKey documents’ rationale for SecureKey and the Canadian banks to pursue this business model was driven by a perceived threat by the banks from many fronts including encroachment by non-banking businesses into the domain of the Canadian banks and pending new regulations (e.g. PSD2).

Monetization of data was clearly important

Figure 2. Banking industry rationale for monetizing customers’ digital identites

The Technology Platform

IBM is providing SecureKey with the Hyperledger products, technologies, services, and know-how to create what is, in effect, a digital identity dark web¬†[8] for the Canadian banking industry to engage in trade of their customers‚Äô digital identity information with SecureKey and SecureKey’s digital identity requester clients.

The primary technology platform is the open source Hyperledger Fabric v1.0 project Рan open-source distributed ledger project used almost exclusively for private and consortium applications[6].

The following diagram represents a consolidation of the information presented in the SecureKey references mentioned at the end of this article.

SecureKey-verify.me

Figure 3. SecureKey verify.me Digital Identity Dark Web

SecureKey brokers digital identity information requests (claims) from Digital Identity Information Requesters.  SecureKey satisfies these claims (requests for digital identity information) by using the SecureKey digital identity dark web it has implemented with its banking partners (Digital Identity Information Providers) using the Hyperledger technology.

Information and Privacy Risk

SecureKey’s February 2018 documents highlight initial set of digital identity information (digital assets) that will be provided by the Digital Identity Information Providers as illustrated in the following diagram[4][5].

SecureKey-Digital Assets

Figure 4. Information and Privacy Risk

Without adequate governance and government regulation, once in place, the verify.me digital identity system can be used to satisfy any digital identity claim from any requester including health information, additional financial information, and other personal data.  A lot is at stake for individual Canadians.

Conclusions

Why are the Canadian banks and SecureKey being allowed to monetize and profit from individual Canadians’ digital identity information? A person’s digital identity is like their digital heart and digital soul. Individual Canadians need to own and control both of these – all of their digital identity data.¬† The role of industry and government should be to act as validators of each person’s digital identity …and no more.¬† Who is watching out for the future of Canadians?

References

[1] SecureKey Technologies Inc., “Press Release: SecureKey Completes $27 Million Strategic Investment Round”,¬†https://securekey.com/press-releases/securekey-completes-27-million-strategic-investment-round/, October 18, 2016.

[2] SecureKey Technologie Inc., “Press Release: IBM and SecureKey Technologies to Deliver Blockchain-Based Digital Identity Network for Consumers”, https://securekey.com/press-releases/ibm-securekey-technologies-deliver-blockchain-based-digital-identity-network-consumers/, March 20, 2017.

[3] Australian Payments Network, “Digital Identity” Session, https://www.slideshare.net/AusPayNet/australian-payments-network-digital-id-session, slides 41-59, August 2017.

[4] SecureKey Technologies Inc., “Identity Now (Banking Edition)”,¬†http://securekey.com/wp-content/uploads/2017/07/SecureKey_Whitepaper_Banking_Final_Feb2018.pdf, February 2018.

[5] SecureKey Technologies Inc., “Identity Now (Telcom Edition)”,¬†http://securekey.com/wp-content/uploads/2017/07/SecureKey_Whitepaper_Telecom_FINAL_Feb2018.pdf,¬†¬†February 2018.

[6] Wikpedia, “Hyperledger”,¬†https://en.wikipedia.org/wiki/Hyperledger, Last edited on 12 April 2018, at 16:12.

[7] European Commission, “Data protection: Rules for the protection of personal data inside and outside the EU”, https://ec.europa.eu/info/law/law-topic/data-protection_en, January 2018.

[8] Wikipedia, “Dark Web”,¬†https://en.wikipedia.org/wiki/Dark_web, Last edited on 21 April 2018, at 15:12.

 

Leave a comment

Filed under Uncategorized

Tokenize Every Little Thing (ELT)

[Since first writing this article in January 2018, I’ve concluded that Ethereum is not capable of being a platform for Tokenizing Every Little Thing. Ethereum is a one-trick pony x 1500¬†when it comes to creating large-scale decentralized applications (i.e. Ethereum/Solidity smart contracts are best for creating single, simple entities like alt-coins). Checkout slide 56 of this presentation:¬†NEO Blockchain Vancouver 20180315 Meetup. The NEO Blockchain and NEO Smart Economy is the best available 3rd generation distributed application platform on the planet and improving every day. Michael Herman, March 17, 2018]

[Also checkout the webcast The NEO Smart Economy, Smart Processes, and Smart Data. Michael Herman, April 9, 2018]


 

Just over one year ago, I introduced the concept of graphitization and talked about #Graphitization of the Enterprise. I opened the article with the challenge:

Move beyond digitalization of the enterprise to graphitization of the enterprise.

For 2018 and beyond, the challenge is simpler but more difficult:

Tokenize Every Little Thing (ELT)

To provide more context, let me first quote from the introductory paragraphs of the #Graphitization article.

Here’s a great diagram that explains this concept [graphitization]. (click on the diagram to enlarge it)

graphitization-new-world-of-it
Figure 1. The New Model of IT

Graphitization of not only all of your corporate information assets across all of your constituencies and stakeholders ‚Äď at the data, application entity, and business object level ‚Äď but also the graphitization of all of the interconnections between every business process, application system, infrastructure component, cloud service, vendor/service provider, and business role that uses, manages, or stores corporate information (Crossing the EA Chasm: Automating Enterprise Architecture Modeling #2).

Use graphitization to make your existing corporate information more available, more usable, and more informative. Graphitization enables you to “Keep Calm and Have IT Your Way“.

What is #Graphitization?

#Graphitization is a data science and enterprise architecture-inspired framework and process model for modeling, ingesting, organizing, analyzing, and visualizing any domain of endeavor by using graphs ‚Äď networks of connected objects and relationships with each object and relationship annotated with additional descriptive information (metadata).

Why #Tokenization?

Given the burgeoning preoccupation of the world’s business, finance, government, and technology sectors with blockchain technologies, cryptocurrencies, and token-this and token-that, the buzzword for 2018 will be #Tokenization …the creation of tokens (multiple versions of tokens) to represent every thing on the planet …Every Little Thing (ELT).

While individuals, startups and larger organizations are trying to dream up the next big, one-off, token or crytocurrency, why not just admit that, “in the end”, everything will be represented by a token?

Why try to knock these off one at a time (e.g. Bitcoins, Ethers, altcoins, CryptoKitties, letters of credit, auctions, escrow agreements, electronic health records (EHR), electronic medical records (EMR), etc.) when the ultimate goal to to create a universal interconnected graph of ELT (Every Little Thing) in the universe?

Why #graphitize the enterprise when you can #tokenize the universe?

What is #Tokenization?

Let’s get a little computer-sciency for just a minute. A common task to to take an input stream (a string of characters, a stream of data, a data file or database table), analysis it, and convert it into a collection or sequence of¬†higher-level tokens for further analysis (a process that can be applied recursively).¬†Here’s an explanation from Wikipedia

In computer science, lexical analysis, lexing or tokenization is the process of converting a sequence of characters (such as in a computer program or web page) into a sequence of tokens (strings with an assigned and thus identified meaning). A program that performs lexical analysis may be termed a lexer, tokenizer, or scanner… [https://en.wikipedia.org/wiki/Lexical_analysis]

…and later in the same Wikipedia article…

Tokenization

Tokenization is the process of demarcating and possibly classifying sections of a string of input characters. The resulting tokens are then passed on to some other form of processing. [https://en.wikipedia.org/wiki/Lexical_analysis#Tokenization]

Coming up for air… Why not represent ELT that happens in the universe as a stream of blockchain transactions?

  • the events in your life?
  • everything that occurs during a Presidential election?
  • the 24-hour cycle of one day changing into the next?
  • the activity-by-activity and task-by-task execution of a business process?
  • a stream of events from your Internet-of-Things (IoT) enabled car, toaster or refrigerator?

Jim Gray and TerraServer

In one of his several presentations on Scalable Computing (circa 1999), Jim Gray (relational database pioneer and Turing Award winner) describes the TerraServer project in the following way:

[Users navigate] an ‚Äėalmost seamless‚Äô image of earth.

SkyServer was a similar project quarterbacked by Gray:

TerraServer allowed access to newly-available satellite imagery with resolution of 1.5 meters/pixel. SkyServer, a collaboration with Alexander Szalay and his colleagues at Johns Hopkins, allowed access to astronomical data from the Sloan Digital Sky Survey. SkyServer led to additional work with astronomical data, … [https://amturing.acm.org/award_winners/gray_3649936.cfm]

Tokenize Every Little Thing

With the advent of blockchain technologies (in particular, the Ethereum extensible blockchain platform), why can’t we embark on a grander mission to tokenize Every Little Thing? …and including all token-pair relationships (TPRs).

What will it take?

What needs to change in the Ethereum blockchain platform? Will Ethereum be able to scale to support modeling, ingesting, organizing, analyzing, and visualizing of Every Little Thing (ELT)?

On your mark, get set, …

Best regards,
Michael Herman (Toronto)

mwherman@parallelspace.net

Other Important References

  • Gordon Bell, MyLifeBits MSR Project (early 2000’s). I remember Jim Gray telling this story but I had trouble finding a proper reference because I thought it was Gray’s story instead of Bell’s.¬† I now know better but I’ve already finished the above article. A Wikipedia MyLifeBits reference can be found here. YouTube videos can be found here, here, and others¬†over here. Channel 9 videos: Part 1 and Part 2. Computerworld article¬†(2008). Business Inside article (2016).
  • Gordon Bell’s MSR web page.

 

2 Comments

Filed under Architecture Reference Models, blockchain, Business Value, Data Science, Enterprise Architecture, Ethereum, Every Little Thing, graph database, Graphitization, How do we think, Nethereum

Ethereum geth.exe Dashboard built with Nethereum

Here’s a screenshot of the current version of a dashboard that I’ve built for geth.exe using the Nethereum¬†.NET integration libraries for Ethereum. (click the image to enlarge it).

mwherman200-geth-dashboard1

Yes, it is a .NET desktop WinForms client.

The app uses a background task to update the Node State section of the form on a timed interval.  It also knows how to send Ether (with or without extra data) between two accounts. The send Ether integration assumes you have more than one account configured in your Rinkeby geth.exe node.  The app will prompt for your password the first time it is required.

It also has direct integration with an existing deployment of the Ballot contract.  The Ballot integration assumes the existing contract address is on the Rinkeby Ethereum network.

In terms of failover, the app tests to see if geth.exe is running and will automatically connect (and reconnect) if geth.exe isn’t already running on Rinkeby.¬† It also checks to see if the node is syncing and if so, the background task pauses until the sync completes.

Enjoy,

Michael Herman (Toronto)

Leave a comment

Filed under .NET Development, blockchain, Ethereum, Nethereum

Ethereum .NET Development Examples using the Nethereum Integration Libraries

This is an early version of an article that is intended to help developers who have a basic knowledge of the Ethereum blockchain platform and want to learn how to program against the Ethereum platform using the Nethereum .NET libraries.

I’ll add more to this article at a later date but, for now, I’m using it to publish a series of 10+ .NET C# examples of how to use the Nethereum libraries to perform the most common task against the Ethereum blockchain platform.

The list of most common tasks includes the following:

  1. Get Protocol Version
  2. Get Max Block Number
  3. Get Account Balance
  4. Send Ether
  5. Wait for Transaction Receipt
  6. Scan Blocks in Blockchain
  7. List Personal Accounts (and their Balances)
  8. Scan Transactions in Blockchain
  9. Interact with an Existing (Deployed) Contract
  10. Interact with an Existing (Deployed) Contract with Events
  11. Get All Event Changes
  12. Get Contract Values History

Here is the primary C# file:

  • TextExamples.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

using Nethereum.Hex.HexTypes;
using Nethereum.Web3;

namespace MWH.MyNethereum.QuickRef
{
 static public class TaskExamples
 {
 const int UNLOCK_TIMEOUT = 2 * 60; // 2 minutes (arbitrary)
 const int SLEEP_TIME = 5 * 1000; // 5 seconds (arbitrary)
 const int MAX_TIMEOUT = 2 * 60 * 1000; // 2 minutes (arbirtrary)

// These static public variables do not represent a recommended pattern
 static public string LastProtocolVersion = "";
 static public string LastTxHash = "";
 static public Nethereum.RPC.Eth.DTOs.TransactionReceipt LastTxReceipt = null;
 static public HexBigInteger LastMaxBlockNumber = new HexBigInteger(0);

static public async Task GetProtocolVersionExample(Web3 web3)
 {
 Console.WriteLine("GetProtocolVersionExample:");

var protocolVersion = await web3.Eth.ProtocolVersion.SendRequestAsync();
 Console.WriteLine("protocolVersion:\t" + protocolVersion.ToString());
 LastProtocolVersion = protocolVersion;
 }

static public async Task GetMaxBlockExample(Web3 web3)
 {
 Console.WriteLine("GetMaxBlockExample:");

var maxBlockNumber = await web3.Eth.Blocks.GetBlockNumber.SendRequestAsync();
 Console.WriteLine("maxBlockNumber:\t" + maxBlockNumber.Value.ToString());
 LastMaxBlockNumber = maxBlockNumber;
 }

static public async Task ScanBlocksExample(Web3 web3, ulong startBlockNumber, ulong endBlockNumber)
 {
 Console.WriteLine("ScanBlocksExample:");

long txTotalCount = 0;
 for (ulong blockNumber = startBlockNumber; blockNumber <= endBlockNumber; blockNumber++)
 {
 var blockParameter = new Nethereum.RPC.Eth.DTOs.BlockParameter(blockNumber);
 var block = await web3.Eth.Blocks.GetBlockWithTransactionsByNumber.SendRequestAsync(blockParameter);
 var trans = block.Transactions;
 int txCount = trans.Length;
 txTotalCount += txCount;
 if (blockNumber % 1000 == 0) Console.Write(".");
 if (blockNumber % 10000 == 0)
 {
 DateTime blockDateTime = Helpers.UnixTimeStampToDateTime((double)block.Timestamp.Value);
 Console.WriteLine(blockNumber.ToString() + " " + txTotalCount.ToString() + " " + blockDateTime.ToString());
 }
 }
 Console.WriteLine();
 }

static public async Task ScanTxExample(Web3 web3, ulong startBlockNumber, ulong endBlockNumber)
 {
 Console.WriteLine("ScanTxExample:");

long txTotalCount = 0;
 for (ulong blockNumber = startBlockNumber; blockNumber <= endBlockNumber; blockNumber++)
 {
 var blockParameter = new Nethereum.RPC.Eth.DTOs.BlockParameter(blockNumber);
 var block = await web3.Eth.Blocks.GetBlockWithTransactionsByNumber.SendRequestAsync(blockParameter);
 var trans = block.Transactions;
 int txCount = trans.Length;
 txTotalCount += txCount;
 foreach (var tx in trans)
 {
 try
 {
 var bn = tx.BlockNumber.Value;
 var th = tx.TransactionHash;
 var ti = tx.TransactionIndex.Value;

var rpt = await web3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync(th);
 var status = rpt.Status.Value;

var nc = tx.Nonce.Value;
 var from = tx.From;

Console.WriteLine(th.ToString() + " " + ti.ToString() + " " + from.ToString() + " " + status.ToString());

var to = tx.To;
 if (to == null) to = "to:NULL";
 var v = tx.Value.Value;
 var g = tx.Gas.Value;
 var gp = tx.GasPrice.Value;
 Console.WriteLine(th.ToString() + " " + ti.ToString() + " " + nc.ToString() + " " + from.ToString() + " " + to.ToString() + " " + v.ToString() + " " + g.ToString() + " " + gp.ToString());
 }
 catch (Exception ex)
 {
 Console.WriteLine("ScanTxExample.Tx:\t" + ex.ToString());
 if (ex.InnerException != null) Console.WriteLine("ScanTxExample.Tx:\t" + ex.InnerException.ToString());
 }
 }
 Console.WriteLine();
 }
 }

static public async Task GetAccountBalanceExample(Web3 web3, string accountAddress)
 {
 Console.WriteLine("GetAccountBalanceExample:");

var balanceWei = await web3.Eth.GetBalance.SendRequestAsync(accountAddress);
 var balanceEther = Web3.Convert.FromWei(balanceWei.Value);
 Console.WriteLine("accountAddress:\t" + accountAddress.ToString());
 Console.WriteLine("balanceEther:\t" + balanceEther.ToString());
 }

static public async Task ListPersonalAccountsExample(Web3 web3)
 {
 Console.WriteLine("ListPersonalAccountsExample:");

var accounts = await web3.Personal.ListAccounts.SendRequestAsync();
 foreach (var account in accounts)
 {
 var balanceWei = await web3.Eth.GetBalance.SendRequestAsync(account);
 var balanceEther = Web3.Convert.FromWei(balanceWei.Value);
 Console.WriteLine("account:\t" + account + " balanceEther:\t" + balanceEther.ToString());
 }
 }

static public async Task SendEtherExample(Web3 web3, string fromAddress, string fromPassword, string toAddress, long amountWei)
 {
 Console.WriteLine("SendEtherExample:");

var unlockResult = await web3.Personal.UnlockAccount.SendRequestAsync(fromAddress, fromPassword, UNLOCK_TIMEOUT);
 var sendTxHash = await web3.Eth.TransactionManager.SendTransactionAsync(fromAddress, toAddress, new HexBigInteger(amountWei));
 Console.WriteLine("fromAddress:\t" + fromAddress.ToString());
 Console.WriteLine("toAddress:\t" + toAddress.ToString());
 Console.WriteLine("amountWei:\t" + amountWei.ToString());
 Console.WriteLine("sendTxHash:\t" + sendTxHash.ToString());
 LastTxHash = sendTxHash;
 }

static public async Task WaitForTxReceiptExample(Web3 web3, string txHash)
 {
 Console.WriteLine("WaitForTxReceiptExample:");

int timeoutCount = 0;
 var txReceipt = await web3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync(txHash);
 while (txReceipt == null && timeoutCount < MAX_TIMEOUT)
 {
 Console.WriteLine("Sleeping...");
 Thread.Sleep(SLEEP_TIME);
 txReceipt = await web3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync(txHash);
 timeoutCount += SLEEP_TIME;
 }
 Console.WriteLine("timeoutCount " + timeoutCount.ToString());
 LastTxReceipt = txReceipt;
 }

static public async Task InteractWithExistingContractExample(Web3 web3, string fromAddress, string fromPassword, string contractAddress, string contractAbi)
 {
 Console.WriteLine("InteractWithExistingContractExample:");

var contract = web3.Eth.GetContract(contractAbi, contractAddress);

var setMessageFunction = contract.GetFunction("setMsg");
 var getMessageFunction = contract.GetFunction("getMsg");

string nowTimestamp = DateTime.UtcNow.ToString() + " UTC";
 Console.WriteLine("now:\t" + nowTimestamp);

var unlockResult = await web3.Personal.UnlockAccount.SendRequestAsync(fromAddress, fromPassword, UNLOCK_TIMEOUT);
 var txHash1 = await setMessageFunction.SendTransactionAsync(fromAddress, new HexBigInteger(900000), null, 1, "Hello World");
 Console.WriteLine("txHash1:\t" + txHash1.ToString());
 var txHash2 = await setMessageFunction.SendTransactionAsync(fromAddress, new HexBigInteger(900000), null, 2, nowTimestamp);
 Console.WriteLine("txHash2:\t" + txHash2.ToString());

var txReceipt2 = await web3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync(txHash2);
 int timeoutCount = 0;
 while (txReceipt2 == null && timeoutCount < MAX_TIMEOUT)
 {
 Console.WriteLine("Sleeping...");
 Thread.Sleep(SLEEP_TIME);
 txReceipt2 = await web3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync(txHash2);
 timeoutCount += SLEEP_TIME;
 }
 Console.WriteLine("timeoutCount:\t" + timeoutCount.ToString());

var txReceipt3 = await setMessageFunction.SendTransactionAndWaitForReceiptAsync(fromAddress, new HexBigInteger(900000), null, null, 2, nowTimestamp + " Wait");
 Console.WriteLine("txReceipt3:\t" + txReceipt3.TransactionHash.ToString());
 Console.WriteLine("txReceipt3:\t" + txReceipt3.CumulativeGasUsed.Value.ToString());

var getResult1 = await getMessageFunction.CallAsync<string>(1);
 Console.WriteLine("getResult1:\t" + getResult1.ToString());
 var getResult2 = await getMessageFunction.CallAsync<string>(2);
 Console.WriteLine("getResult2:\t" + getResult2.ToString());
 }

static public async Task InteractWithExistingContractWithEventsExample(Web3 web3, string fromAddress, string fromPassword, string contractAddress, string contractAbi)
 {
 Console.WriteLine("InteractWithExistingContractWithEventsExample:");

var contract = web3.Eth.GetContract(contractAbi, contractAddress);

var setMessageFunction = contract.GetFunction("setMsg");
 var getMessageFunction = contract.GetFunction("getMsg");
 var multipliedEvent = contract.GetEvent("MultipliedEvent");
 var newMessageEvent = contract.GetEvent("NewMessageEvent");

var filterAllMultipliedEvent = await multipliedEvent.CreateFilterAsync();
 var filterAllNewMessageEvent = await newMessageEvent.CreateFilterAsync();

string nowTimestamp = DateTime.UtcNow.ToString() + " UTC";
 Console.WriteLine("now:\t" + nowTimestamp);

var unlockResult = await web3.Personal.UnlockAccount.SendRequestAsync(fromAddress, fromPassword, UNLOCK_TIMEOUT);
 var txHash1 = await setMessageFunction.SendTransactionAsync(fromAddress, new HexBigInteger(900000), null, 1, "Hello World");
 Console.WriteLine("txHash1:\t" + txHash1.ToString());
 var txHash2 = await setMessageFunction.SendTransactionAsync(fromAddress, new HexBigInteger(900000), null, 2, nowTimestamp);
 Console.WriteLine("txHash2:\t" + txHash2.ToString());

var txReceipt2 = await web3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync(txHash2);
 int timeoutCount = 0;
 while (txReceipt2 == null && timeoutCount < MAX_TIMEOUT)
 {
 Console.WriteLine("Sleeping...");
 Thread.Sleep(SLEEP_TIME);
 txReceipt2 = await web3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync(txHash2);
 timeoutCount += SLEEP_TIME;
 }
 Console.WriteLine("timeoutCount:\t" + timeoutCount.ToString());

var txReceipt3 = await setMessageFunction.SendTransactionAndWaitForReceiptAsync(fromAddress, new HexBigInteger(900000), null, null, 2, nowTimestamp + " Wait");
 Console.WriteLine("txReceipt3:\t" + txReceipt3.TransactionHash.ToString());
 Console.WriteLine("txReceipt3:\t" + txReceipt3.CumulativeGasUsed.Value.ToString());

var getResult1 = await getMessageFunction.CallAsync<string>(1);
 Console.WriteLine("getResult1:\t" + getResult1.ToString());
 var getResult2 = await getMessageFunction.CallAsync<string>(2);
 Console.WriteLine("getResult2:\t" + getResult2.ToString());

var logMultipliedEvents = await multipliedEvent.GetFilterChanges<FunctionOutputHelpers.MultipliedEventArgs>(filterAllMultipliedEvent);
 foreach (var mea in logMultipliedEvents)
 {
 Console.WriteLine("multipliedEvent:\t" +
 mea.Event.sender + " " + mea.Event.oldProduct.ToString() + " " + mea.Event.value.ToString() + " " + mea.Event.newProduct.ToString());
 }

var logNewMessageEvents = await newMessageEvent.GetFilterChanges<FunctionOutputHelpers.NewMessageEventArgs>(filterAllNewMessageEvent);
 foreach (var mea in logNewMessageEvents)
 {
 Console.WriteLine("newMessageEvent:\t" +
 mea.Event.sender + " " + mea.Event.ind.ToString() + " " + mea.Event.msg.ToString());
 }
 }

static public async Task GetAllChangesExample(Web3 web3, string fromAddress, string fromPassword, string contractAddress, string contractAbi)
 {
 Console.WriteLine("GetAllChangesExample:");

var contract = web3.Eth.GetContract(contractAbi, contractAddress);
 var newMessageEvent = contract.GetEvent("NewMessageEvent");
 var filterAllNewMessageEvent = await newMessageEvent.CreateFilterAsync(fromAddress);
 var logNewMessageEvents = await newMessageEvent.GetAllChanges<FunctionOutputHelpers.NewMessageEventArgs>(filterAllNewMessageEvent);
 foreach (var mea in logNewMessageEvents)
 {
 Console.WriteLine("newMessageEvent:\t" +
 mea.Event.sender + " " + mea.Event.ind.ToString() + " " + mea.Event.msg.ToString());
 }
 }

static public async Task GetContractValuesHistoryUniqueOffsetValueExample(Web3 web3, string contractAddress, HexBigInteger recentBlockNumber, ulong numberBlocks, int offset)
 {
 Console.WriteLine("GetContractValuesHistoryUniqueOffsetValueExample:");

string previousValue = "";
 for (ulong blockNumber = (ulong)recentBlockNumber.Value; blockNumber > (ulong)recentBlockNumber.Value - numberBlocks; blockNumber--)
 {
 var blockNumberParameter = new Nethereum.RPC.Eth.DTOs.BlockParameter(blockNumber);
 var valueAtOffset = await web3.Eth.GetStorageAt.SendRequestAsync(contractAddress, new HexBigInteger(offset), blockNumberParameter);
 if (valueAtOffset != previousValue)
 {
 var block = await web3.Eth.Blocks.GetBlockWithTransactionsByNumber.SendRequestAsync(blockNumberParameter);
 DateTime blockDateTime = Helpers.UnixTimeStampToDateTime((double)block.Timestamp.Value);
 Console.WriteLine("blockDateTime:\t" + blockDateTime.ToString());

for (int storageOffset = 0; storageOffset < offset+2; storageOffset++)
 {
 var valueAt = await web3.Eth.GetStorageAt.SendRequestAsync(contractAddress, new HexBigInteger(storageOffset), blockNumberParameter);
 Console.WriteLine("value:\t" + blockNumber.ToString() + " " + storageOffset.ToString() + " " + valueAt + " " + Helpers.ConvertHex(valueAt.Substring(2)));
 }
 previousValue = valueAtOffset;
 }
 }
 }
 }
}

Here are some supporting files:

  • FunctionOutputHelpers.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Nethereum.Web3;
using Nethereum.ABI.FunctionEncoding.Attributes;

namespace MWH.MyNethereum.QuickRef
{
 static public class FunctionOutputHelpers
 {
 // event MultipliedEvent(
 // address indexed sender,
 // int oldProduct,
 // int value,
 // int newProduct
 // );

[FunctionOutput]
 public class MultipliedEventArgs
 {
 [Parameter("address", "sender", 1, true)]
 public string sender { get; set; }

[Parameter("int", "oldProduct", 2, false)]
 public int oldProduct { get; set; }

[Parameter("int", "value", 3, false)]
 public int value { get; set; }

[Parameter("int", "newProduct", 4, false)]
 public int newProduct { get; set; }

}

//event NewMessageEvent(
 // address indexed sender,
 // uint256 indexed ind,
 // string msg
 //);

[FunctionOutput]
 public class NewMessageEventArgs
 {
 [Parameter("address", "sender", 1, true)]
 public string sender { get; set; }

[Parameter("uint256", "ind", 2, true)]
 public int ind { get; set; }

[Parameter("string", "msg", 3, false)]
 public string msg { get; set; }
 }
 }
}
  • Helpers.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MWH.MyNethereum.QuickRef
{
 static public class Helpers
 {
 public static string ConvertHex(String hexString)
 {
 try
 {
 string ascii = string.Empty;

for (int i = 0; i < hexString.Length; i += 2)
 {
 String hs = string.Empty;

hs = hexString.Substring(i, 2);
 uint decval = System.Convert.ToUInt32(hs, 16);
 char character = System.Convert.ToChar(decval);
 ascii += character;

}

return ascii;
 }
 catch (Exception ex) { Console.WriteLine(ex.Message); }

return string.Empty;
 }

public static DateTime UnixTimeStampToDateTime(double unixTimeStamp)
 {
 // Unix timestamp is seconds past epoch
 System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
 dtDateTime = dtDateTime.AddSeconds(unixTimeStamp); // .ToLocalTime();
 return dtDateTime;
 }

public static DateTime JavaTimeStampToDateTime(double javaTimeStamp)
 {
 // Java timestamp is milliseconds past epoch
 System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
 dtDateTime = dtDateTime.AddMilliseconds(javaTimeStamp); // .ToLocalTime();
 return dtDateTime;
 }
 }
}

Here’s the Solidity code that is used to implement the Ethereum contract used in these examples:

  • Test3.sol
pragma solidity 0.4.19;

contract Test3 {

int public _product;
string[5] _msgs;
 
event MultipliedEvent(
address indexed sender,
int oldProduct,
int value,
int newProduct
);
 
event NewMessageEvent(
address indexed sender,
uint256 indexed ind,
string msg
);

function Test3() public {
_product = 1;
}

function multiply(int value) public returns(int product) {
int old = _product;
_product = value * _product;
MultipliedEvent( msg.sender, old, value, _product );
return _product;
}
 
function getProduct() public constant returns(int product) {
return _product;
}

function setMsg(uint256 i, string m) public returns(uint256 mi) {
_msgs[i] = m;
NewMessageEvent( msg.sender, i, m);
return -i;
}

function getMsg(uint256 index) public constant returns(string m) {
return _msgs[index];
}
}

I realize that this is a fairly crude way to publish code examples.  Any suggestions for a better approach will be appreciated.

Best regards,
Michael Herman (Toronto)

Leave a comment

Filed under .NET Development, blockchain, Ethereum, Nethereum