Skip to content

Dart SDK for IoP DAC and Fort Applications (project Morpheus and Prometheus)

License

Notifications You must be signed in to change notification settings

Internet-of-People/iop-dart

Repository files navigation

IOP SDK

This package contains Dart tools needed to interact with IOP SSI (project Morpheus) and DNS (project Coeus) and create awesome decentralized apps. For more info please visit the IOP Developer Portal.

This SDK is a work in progress and its convenience improves over time.

Table of Contents

Prerequisites

  • Dart 2.12.0+
  • Linux / MacOS

Install

Add this to your package's pubspec.yaml file:

dependencies:
  iop_sdk: ^5.0.0

Architecture

Dynamic Libraries and OS Support

Most of the codebase is implemented in Rust and this Dart library uses Dart FFI to communicate with a shared dynamic library generated from Rust using its C bindings. The native library binary is loaded dynamically on demand.

Currently, we support only Linux, MacOS and Android, but we are also preparing iOS and Windows support as well.

Memory Management

As Dart finalizers are not ready yet, only manual memory management is available. Consequently, some classes of this package are extended from Disposable and you have to manually dispose their instances when not using those objects anymore. This is common for Android developers, but might not be that evident for others.

Modules

Crypto

Cryptographic primitives mostly for creating a vault and generating a large set of purpose-specified private keys for Hydra addresses, SSI DIDs, etc. It also contains tools to sign and validate signatures based on DIDs with a managable keyset and easily handle JWT tokens.

Entities

Authority

All interfaces and types that are needed to communicate with an Authority endpoint. Authorities have a public and a private API as described below.

See more about the Authorities API here

Public API

The Public API is available without authentication, mostly used by clients of the given authority's services.

Private API

The Private API is available with authentication only and used mostly by internal entities (e.g. clerks) of an authority.

Inspector

All interfaces and types needed to communicate with an Inspector endpoint. See more about the Inspector API here.

Verifier

All interfaces and types needed to communicate with a Verifier endpoint. See more about the Verifier API here.

Layer1

SSI's API consists of two main parts. Layer-1 and layer-2. Layer-1 performs write operations that change the blockchain's state, while layer-2 executes queries (i.e. read operations without touching the state).

This module contains all Dart classes and utils needed to interact with the SSI Layer-1 API.

For more detailed examples please visit our tutorial center.

Layer2

This module contains all Dart classes and utils needed to interact with the Layer-2 API.

For more detailed examples please visit our tutorial center.

SSI

Contains all interfaces needed to use the SSI (project Morpheus) protocol including all entities defined in the specification.

Development

# Build json converters
$ pub run build_runner build --delete-conflicting-outputs
# Run tests
$ pub run test --concurrency=1 # note: the test must run on a single thread becaus of nonce generation
# Run Analyzer
$ dartanalyzer .

Resource Finalizers

A relevant part of this Dart library is implemented in Rust and exported through a shared library (C ABI) that is called using Dart FFI. Related Dart objects are just wrappers around external pointers allocated on the C heap (i.e. outside the Dart VM) and thus has to be deallocated the same way.

The convenient way for automated deallocation of underlying FFI resources during garbage collection would be using Dart finalizers. Unfortunately they are still very much work in progress and yet unreleased.

As a temporary solution, classes wrapping FFI-allocated resources all implement a custom Disposable interface. The owner of such object instances has to explicitly free their underlying resources calling obj.dispose() when the object is not needed anymore. We understand that this is very inconvenient and error-prone, thus we plan to add support for automated finalizers as soon as the Dart feature gets stabilized.

Contributing

Feel free to open issues and pull requests in this repository. By contributing you agree to transfer all intellectual property from your changes to the Decentralized Society Foundation, Panama, copyright owner of this code. To avoid losing precious time you spend on coding, you could open an issue first and discuss what you are up to before forking and sending us a PR.

Small note: If editing the README, please conform to the standard-readme specification.

License

LGPL-3.0 or later © 2020 Decentralized Society Foundation, PA

About

Dart SDK for IoP DAC and Fort Applications (project Morpheus and Prometheus)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •