Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

interlockledger/interlockledger-rest-client-python

Repository files navigation

InterlockLedger REST Client in Python

This package is a python client to the InterlockLedger Node REST API. It connects to InterlockLedger nodes, allowing the creation of chains, interlocks, and storage of records and documents.

This project is now deprecated in favor of the new py-interlockledger-rest-client.

The InterlockLedger

An InterlockLedger network is a peer-to-peer network of nodes. Each node runs the InterlockLedger software. All communication between nodes is point-to-point and digitally signed, but not mandatorily encrypted. This means that data is shared either publicly or on a need-to-know basis, depending on the application.

In the InterlockLedger, the ledger is composed of myriads of independently permissioned chains, comprised of blockchained records of data, under the control of their owners, but that are tied by Interlockings, that avoid them having their content/history being rewritten even by their owners. For each network the ledger is the sum of all chains in the participating nodes.

A chain is a sequential list of records, back chained with signatures/hashes to the previous records, so that no changes in them can go undetected. A record is tied to some enabled Application, that defines the metadata associate with it, and the constraints defined in this public metadata, forcibly stored in the network genesis chain, is akin to validation that each correct implementation of the node software is able to enforce, but more importantly, any external logic can validate the multiple dimensions of validity for records/chains/interlockings/the ledger.

Usage

To use the il2_rest package, you can add the interlockledger_rest folder to your project.

Dependencies

  • Python 3.6.9:
    • colour (0.1.5)
    • packaging (19.2)
    • pyOpenSSL (19.1.0)
    • requests (2.22.0)
    • pyilint (0.2.2)
    • pyiltags (0.1.1)
  • InterlockLedger :
    • API 7.5.0

To build the documentation:

  • Sphinx (3.5.3)

Installation

The package can also be installed by running the following command on the setup.py folder:

pip3 install .

Example

How to use the interlockledger rest client to store a JSON document:

>>> import il2_rest
>>>
>>> address = 'your.node.url.address'
>>> port = 32020 # change this value to your node API port number
>>> node = il2_rest.RestNode(
        cert_file='documenter.pfx',
        cert_pass='password',
        address=address,
        port=port
    )
>>> print(node.details)

Node 'Node for il2test Database on Minerva' Node!-vRv_TeFEv...<REDACTED>...Km9r85A
Running il2 node#5.6.52 with Peer2Peer#6.4.0
Network Minerva
Color #d53c07
Owner il2test Database #Owner!-ozg6...<REDACTED>...sqKc
Roles: Interlocking,Mirror,PeerRegistry,User
Versions {
    "coreLibs": "9.8.6",
    "main": "5.6.52",
    "peer2peer": "6.4.0",
    "tags": "9.4.0"
}
Chains: UHtrQ...<REDACTED>...XRY, or7lz...<REDACTED>...DxI

>>> chain = node.chain_by_id('UHtrQ...<REDACTED>...XRY')
>>> json_body = {"attribute_1":"value_1", "number_1": 1}
>>> doc_resp = chain.store_json_document(json_body)
>>> print(doc_resp)

{
    "applicationId": 8,
    "chainId": "UHtrQ...<REDACTED>...XRY",
    "createdAt": "2021-04-01T01:04:59.989000+00:00",
    "hash": "bGewIc...<REDACTED>...Ck#SHA256",
    "payloadTagId": 2100,
    "serial": 11,
    "type": "Data",
    "version": 3,
    "jsonText": "",
    "network": "Minerva",
    "reference": "Minerva:UHtr...<REDACTED>...",
    "encryptedJson": {
        "cipher": "AES256",
        "cipherText": "/IKpN0pb...<REDACTED>...s8V9",
        "readingKeys": [
            {
                "encryptedIV": "G4/xdfi4F...<REDACTED>...QY18m",
                "encryptedKey": "rifETUkx...<REDACTED>...D+2GDp",
                "publicKeyHash": "QVxUC2T...<REDACTED>...lE#SHA256"
            },
            {
                "encryptedIV": "ZD8nzLt...<REDACTED>...xeE+",
                "encryptedKey": "q/9UqXpA...<REDACTED>...4xn4Zx",
                "publicKeyHash": "QVxUC2T2B...<REDACTED>...lE#SHA256"
            }
        ]
    }
}

About

Our python client to the InterlockLedger node REST API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages