findy

package module
v0.24.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2021 License: Apache-2.0 Imports: 1 Imported by: 7

README

findy-wrapper-go

lint test

This is a Go wrapper for indy-sdk. It wraps most of the libindy's functions and data types, but it doesn't try to be complete. We have written it incrementally and wrapped only those functions that we need at the moment.

We haven't extended this wrapper with helper classes. It only tries to offer Go programming interface above the existing libindy API. findy-agent extends this API with SSI/DID abstractions and offers more high-level API for SSI/DID development. For the most applications findy-agent is the suitable framework to start.

Get Started

  1. Install libindy-dev.
  2. Clone the repo: git clone https://github.com/findy-network/findy-go
  3. Build the package: make build

If build system cannot find indy libs and headers, set following environment variables:

export CGO_CFLAGS="-I/<path_to_>/indy-sdk/libindy/include"
export CGO_LDFLAGS="-L/<path_to_>/indy-sdk/libindy/target/debug"

Development Without The Ledger

The findy-go package includes memory implementation of the ledger transaction interface. If pool names are FINDY_MEM_LEDGER or FINDY_ECHO_LEGDER the package uses its internal implementation of the ledger pool and lets you perform all of its functions.

	r := <-pool.OpenLedger("FINDY_MEM_LEDGER")
	if r.Err() != nil {
		return r.Err()
	}
	pool := r.Handle()

Run Tests With Indy Ledger

  1. Install and start ledger

  2. Create a ledger pool with indy CLI on VON Network or if findy-agent is installed

    findy-agent create cnx -pool <pool_name> -txn genesis.txt

  3. Set environment variable: export FINDY_POOL=<pool_name>

  4. Run tests: make test

Documentation

The wrapper includes minimal Go documentation. If you need more information about indy SDK, we suggest that you would read the original indy SDK documentation.

Naming Conventions

It follows the same sub-package structure as libindy. Also, function names are the same, but it respects Go idioms.

Original indy SDK function calls in C:

indy_key_for_did(...)
...
indy_key_for_local_did(..)

Same functions but with Go wrapper:

r := <-did.Key(pool, wallet, didStr)
...
r = <-did.LocalKey(wallet, didStr)

As you can see, the subjects that would exist in the function names aren't repeated if they are in the package names already.

Return Types

The return type is Channel, which transfers dto.Result Go structures. These structures work similarly to C unions, which means that we can use one type for all of the wrapper functions. To access the actual data, you have to know the actual type. pool.OpenLedger() returns Handle type.

	r = <-pool.OpenLedger("FINDY_MEM_LEDGER")
	assert.NoError(t, r.Err())
	h2 := r.Handle()
	assert.Equal(t, h2, -1)

did.CreateAndStore() returns two strings: did and verkey. Please note the use of did.Did struct instead of the JSON string.

	r := <-did.CreateAndStore(w, did.Did{Seed: ""})
	assert.NoError(t, r.Err())
	did := r.Str1()
	vk := r.Str2()

When a null string is needed for an argument, the predefined type must be used.

	r = <-annoncreds.IssuerCreateAndStoreCredentialDef(w1, w1DID, scJSON,
		"MY_FIRMS_CRED_DEF", findy.NullString, findy.NullString)

Error Values

The Go error value can be retrieved with dto.Result.Err() which returns Go error.

Publishing new version

Release script will tag the current version and push the tag to remote. This will trigger e2e-tests in CI automatically and if they succeed, the tag is merged to master.

Release script assumes it is triggered from dev branch. It takes one parameter, the next working version. E.g. if current working version is 0.1.0, following will release version 0.1.0 and update working version to 0.2.0:

git checkout dev
./release 0.2.0

Documentation

Overview

Package findy is a Go wrapper for libindy, indy SDK. It follows libindy's naming and sub package structure. The callback mechanism of the indy is changed to Go's channel. All of the wrapper functions return the Channel. The input parameters of the wrapper functions follow the libindy as well. They use same JSON objects. However, you doesn't need to give JSON strings as an input arguments but similar Go structures.

About The Documentation

The Go documentation is minimal. We considered to paste libindy's documentation from Rust source files but thought that was not necessary. We suggest you to read indy SKD's documentation in cases the documentation in this wrapper is not enough.

Return Types

The return type is Channel, which transfers dto.Result Go structures. These structures work similarly to C unions, which means that we can use one type for all of the wrapper functions. To access the actual data, you have to know the actual type. pool.OpenLedger() returns Handle type.

r = <-pool.OpenLedger("FINDY_MEM_LEDGER")
assert.NoError(t, r.Err())
h2 := r.Handle()
assert.Equal(t, h2, -1)

did.CreateAndStore() returns two strings: did and verkey. Please note the use of did.Did struct instead of the JSON string.

r := <-did.CreateAndStore(w, did.Did{Seed: ""})
assert.NoError(t, r.Err())
did := r.Str1()
vk := r.Str2()

When a null string is needed for an argument, the predefined type must be used.

r = <-annoncreds.IssuerCreateAndStoreCredentialDef(w1, w1DID, scJSON,
	"MY_FIRMS_CRED_DEF", findy.NullString, findy.NullString)

Index

Constants

View Source
const NullHandle = -1

NullHandle is constant to pass null handles to the packet.

View Source
const NullString = "\xff"

NullString is constant to pass null strings to the packet.

Variables

This section is empty.

Functions

func SetTrace

func SetTrace(_ bool) bool

SetTrace enables or disables the trace output. It's disabled as default. Note, this is obsolete, use logging V style parameter, level 10

Types

type Channel

type Channel = ctx.Channel

Channel is channel type for findy API. Instead of callbacks findy API returns channels for async functions.

Directories

Path Synopsis
Package addons includes ledger addons.
Package addons includes ledger addons.
Package anoncreds is corresponding Go package for libindy's anoncreds namespace.
Package anoncreds is corresponding Go package for libindy's anoncreds namespace.
Package config includes configurations to setup libindy properly.
Package config includes configurations to setup libindy properly.
Package crypto is corresponding Go package for libindy's anoncreds namespace.
Package crypto is corresponding Go package for libindy's anoncreds namespace.
Package did is corresponding Go package for libindy's anoncreds namespace.
Package did is corresponding Go package for libindy's anoncreds namespace.
internal
ctx
Package ledger is corresponding Go package for libindy's ledger namespace.
Package ledger is corresponding Go package for libindy's ledger namespace.
Package pairwise is corresponding Go package for libindy's pairwise namespace.
Package pairwise is corresponding Go package for libindy's pairwise namespace.
Package plugin is an interface package for ledger addons.
Package plugin is an interface package for ledger addons.
Package pool is corresponding Go package for libindy's pool namespace.
Package pool is corresponding Go package for libindy's pool namespace.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL