Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge did:indy support #166

Merged
merged 93 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from 77 commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
ee17368
Integrated txn_signature into indy-vdr
berendsliedrecht Jan 3, 2023
c6f1608
Added base64 and base58 inside the package
berendsliedrecht Jan 3, 2023
7e98584
Removed features from indy-utils
berendsliedrecht Jan 4, 2023
247c24f
Merge branch 'main' into integrate-indy-utils
berendsliedrecht Jan 5, 2023
76c5d7d
did:indy resolver
domwoe Feb 21, 2022
a9a14d7
new nym request
domwoe Feb 21, 2022
72dd984
do not add resolver in legacy mode
domwoe Feb 21, 2022
d03fc82
sync with IDunion/indy-did-resolver
domwoe Mar 8, 2022
2695ed8
renaming Value to SJsonValue
domwoe Mar 8, 2022
e9de63c
invert feature flag logic: legacy -> did_indy
domwoe Mar 8, 2022
08494bb
format
domwoe Mar 8, 2022
6482b99
small fix in test dependencies
domwoe Mar 8, 2022
40815b5
nym and get_nym + proxy. No wrappers
domwoe Mar 8, 2022
57e8aba
adapt python wrapper
domwoe Mar 8, 2022
0e7dd06
remove feature
domwoe Mar 8, 2022
470ab1a
minimal changes to go wrapper
domwoe Mar 8, 2022
5dc2ff8
test build
domwoe Mar 8, 2022
89642d1
format
domwoe Mar 8, 2022
f134fc8
fix nym builder in tests and try to fix go wrapper
domwoe Mar 8, 2022
2a5ff3d
another attempt to fix go wrapper
domwoe Mar 8, 2022
cb0c404
not working due to lifetimes
domwoe Mar 11, 2022
55d819c
run tests
domwoe Mar 11, 2022
266df85
ffi resolver working for single request
domwoe Mar 14, 2022
e3a95ab
optional parameters in get_nym
domwoe Mar 15, 2022
c109868
started clean up of ffi resolver
domwoe Mar 15, 2022
a20a7b3
remove chrono dependency and use time-rs instead
domwoe Mar 15, 2022
6450e16
simplifying module imports
domwoe Mar 15, 2022
a240037
format
domwoe Mar 15, 2022
e9c3e01
ffi without fetching legacy endpoint working
domwoe Mar 15, 2022
8779928
fix query params in proxy
domwoe Mar 15, 2022
bc932c9
format..
domwoe Mar 15, 2022
63c4464
remove some unecessary code
domwoe Mar 15, 2022
4116426
removed unecessary enum
domwoe Mar 15, 2022
fb07bb2
add self-certification version. Try to fix wrappers
domwoe Mar 15, 2022
63f441f
fix integration tests
domwoe Mar 15, 2022
d00e14c
fmt
domwoe Mar 15, 2022
bd121f0
nym with diddoc_Content integration test
domwoe Mar 15, 2022
8523d33
refactor
domwoe Mar 23, 2022
ba9de5e
add comments to go wrapper
domwoe Mar 23, 2022
3d61429
multiple ledger support for proxy. Refresh not implemented
domwoe Mar 23, 2022
340291d
add selfCertificationVersion to didDocumentMetadata
domwoe Mar 15, 2022
1c366df
refresh
domwoe Mar 23, 2022
6646748
fmt
domwoe Mar 23, 2022
e21aaec
add get nym query parameters in readme
domwoe Mar 24, 2022
9947990
Python wrapper with multi-ledger resolver
domwoe Mar 24, 2022
c45d4e8
small cleanups
domwoe Mar 24, 2022
d508777
add a few more comments
domwoe Mar 24, 2022
ccf115f
remove print statement
domwoe Mar 24, 2022
096444c
handle legacy endpoints on wrapper layer
domwoe Mar 25, 2022
692b473
disable enforcement of diddoc_content validation
domwoe Mar 25, 2022
d225ddf
implement some of the clippy suggestions
domwoe Mar 28, 2022
3e35b95
formatting
domwoe Mar 28, 2022
2f46877
fix did with query parameters
domwoe Mar 30, 2022
11e7d5c
Get attrib with optional seq_no and timestamp
domwoe Mar 30, 2022
8d73760
update local_nodes_pool attrib tests
domwoe Apr 1, 2022
c4ac1d7
self-certification tests. Some uncommented because of indy-utils gene…
domwoe Mar 29, 2022
5e8e3f9
small fixes
domwoe Mar 29, 2022
d9ec0a7
remove debug loglevel
domwoe Apr 1, 2022
62e752d
attempt to harden resolver test
domwoe Apr 1, 2022
22a6705
fmt
domwoe Apr 1, 2022
cda296e
fix readme for indy-vdr-proxy
domwoe Apr 12, 2022
886c628
Correctly use the networks folder of the repository
c2bo Oct 25, 2022
b5c1103
fix verkey expansion
c2bo Oct 25, 2022
bcd9830
clean up features; remove chrono dependency
andrewwhitehead Jan 12, 2023
98d9f22
clean up warnings
andrewwhitehead Feb 23, 2023
0a6e385
remove did_indy feature flag
andrewwhitehead Feb 23, 2023
26d7564
adjust header files for indy_vdr_build_nym_request parameters
andrewwhitehead Feb 23, 2023
6357a55
python wrapper cleanups for resolver
andrewwhitehead Feb 23, 2023
d632f29
fix merge issues
andrewwhitehead Feb 23, 2023
04faad5
fix formatting, warnings on indy-vdr-proxy
andrewwhitehead Feb 24, 2023
f21a882
update JS wrapper calls to indy_vdr_build_nym_request
andrewwhitehead Feb 24, 2023
9361851
use percent-encoding instead of urlencoding (already in dependencies)…
andrewwhitehead Feb 28, 2023
d790feb
quick fix for ffi bindings
c2bo Mar 1, 2023
f6e0df3
remove did-indy node container and re-use the existing node-container…
c2bo Mar 2, 2023
f81c868
add small bash script to create / remove the pool for local testing
c2bo Mar 2, 2023
ad8308d
use bash script for the local pool tests in the github actions
c2bo Mar 2, 2023
45ead4b
(python) add defaults for new optional parameters
andrewwhitehead Mar 7, 2023
5169e7e
Add support for config flag transactions
c2bo Mar 27, 2023
73500e1
fix merge issues
andrewwhitehead Mar 30, 2023
6b90fc1
restrict time crate version
andrewwhitehead Jul 19, 2023
673f825
fix default value for seqNo in GetNymRequest
andrewwhitehead Jul 19, 2023
8992332
move test script
andrewwhitehead Jul 27, 2023
944cd33
misc cleanups
andrewwhitehead Jul 27, 2023
3117753
enable tests
andrewwhitehead Jul 27, 2023
2979752
update dependencies
andrewwhitehead Jul 27, 2023
b6336fc
vendored openssl
andrewwhitehead Jul 27, 2023
e56e1f2
clean up warnings
andrewwhitehead Jul 27, 2023
950d6a0
fix build error on windows
andrewwhitehead Jul 27, 2023
ac121e8
adjust versionId test
andrewwhitehead Jul 27, 2023
100657f
Merge remote-tracking branch 'berendt/integrate-indy-utils' into did-…
andrewwhitehead Aug 4, 2023
1994640
update base64 dependency
andrewwhitehead Aug 4, 2023
37d95f7
update to indy-utils 0.6, indy-data-types 0.6.1
andrewwhitehead Aug 4, 2023
84b859c
fix warnings
andrewwhitehead Aug 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.git
target
github
20 changes: 13 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ on:
default: false
type: boolean

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
checks:
name: Run checks
Expand Down Expand Up @@ -54,7 +58,7 @@ jobs:
- name: Cargo fmt
run: cargo fmt --all -- --check

- if: "runner.os == 'Linux'"
- if: ${{ runner.os == 'Linux' }}
name: Pre-install cross
run: |
cargo install --bins --git https://github.com/rust-embedded/cross --tag v${{ env.CROSS_VERSION }} cross
Expand Down Expand Up @@ -83,13 +87,15 @@ jobs:

- name: Run local node pool
run: |
docker build -f ci/indy-pool.dockerfile -t test_pool --build-arg pool_ip=10.0.0.2 ci
docker network create --subnet=10.0.0.0/8 indy-sdk-network
docker run -d --name indy_pool -p 9701-9708:9701-9708 --net=indy-sdk-network test_pool
./test.sh up

- name: Run tests
run: cargo test --manifest-path libindy_vdr/Cargo.toml --features local_nodes_pool

- name: Stop local node pool
run: |
./test.sh down

build-release:
name: Build library
needs: [checks]
Expand Down Expand Up @@ -417,7 +423,7 @@ jobs:
if: |
(github.event_name == 'release' ||
(github.event_name == 'workflow_dispatch' &&
github.event.inputs.publish == 'true'))
github.event.inputs.publish-binaries == 'true'))

steps:
- name: Fetch Android libraries
Expand Down Expand Up @@ -498,14 +504,14 @@ jobs:
- name: Test python package
# FIXME cross platform test the python package
# maybe use the cross docker image?
if: "matrix.architecture != 'linux-aarch64'"
if: ${{ matrix.architecture != 'linux-aarch64' }}
shell: sh
run: |
pip install dist/*
python -m demo.test
working-directory: wrappers/python

- if: "runner.os == 'Linux'"
- if: ${{ runner.os == 'Linux' }}
name: Audit wheel
run: |
auditwheel show wrappers/python/dist/* | tee auditwheel.log
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ coverage
*.tgz
*.so
.npmrc
github
**/networks
58 changes: 40 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,49 @@ At a later stage it should be possible to install a precompiled 'wheel' package

## Proxy Server

The `indy-vdr-proxy` executable can be used to provide a simple REST API for interacting with the ledger. Command line options can be inspected by running `indy-vdr-proxy --help`.
The `indy-vdr-proxy` executable can be used to provide a simple REST API for interacting with one or more Indy ledgers. Command line options can be inspected by running `indy-vdr-proxy --help`.

Responses can be formatted in either HTML or JSON formats. HTML formatting is selected when the `text/html` content type is requested according to the Accept header (as sent by web browsers) or the request query string is set to `?html`. JSON formatting is selected otherwise, and may be explitly selected by using the query string `?raw`. For most ledger requests, JSON responses include information regarding which nodes were contacted is returned in the `X-Requests` header.
To start the proxy server for a single ledger use the following command:
```
indy-vdr-proxy -p <PORT> (-g <OPTIONAL_PATH_TO_GENESIS_FILE>)
```

To start the proxy server with the standard configuration of indy ledgers use the following command:
`indy-vdr-proxy -p <PORT> -- --multiple-ledgers`
This will get the ledger configuration from `https://github.com/IDunion/indy-did-networks`

Sending prepared requests to the ledger is performed by delivering a POST request to the `/submit` endpoint, where the body of the request is the JSON-formatted payload. Additional endpoints are provided as shortcuts for ledger read transactions:

- `/` The root path shows basic status information about the server and the ledger pool
- `/genesis` Return the current set of genesis transactions
- `/taa` Fetch the current ledger Transaction Author Agreement
- `/aml` Fetch the current ledger Acceptance Methods List (for the TAA)
- `/nym/{DID}` Fetch the NYM transaction associated with a DID
- `/attrib/{DID}/endpoint` Fetch the registered endpoint for a DID
- `/schema/{SCHEMA_ID}` Fetch a schema by its identifier
- `/cred_def/{CRED_DEF_ID}` Fetch a credential definition by its identifier
- `/rev_reg/{REV_REG_ID}` Fetch a revocation registry by its identifier
- `/rev_reg_def/{REV_REG_ID}` Fetch a revocation registry definition by its registry identifier
- `/rev_reg_delta/{REV_REG_ID}` Fetch a revocation registry delta by its registry identifier
- `/auth` Fetch all AUTH rules for the ledger
- `/auth/{TXN_TYPE}/{ADD|EDIT}` Fetch the AUTH rule for a specific transaction type and action
- `/txn/{SUBLEDGER}/{SEQ_NO}` Fetch a specific transaction by subledger identifier (0-2, or one of `pool`, `domain`, or `config`) and sequence number.
A custom ledger configuration can be provided either by specificing a Github repo or a local folder:
```
indy-vdr-proxy -p <PORT> -g <GITHUB_URL or PATH_TO_FOLDER> -- --multiple-ledgers
```
The structure needs to be as follows `<NAMESPACE>/OPTIONAL<SUB_NAMESPACE>/pool_transactions_genesis.json`, e.g. `/sovrin/staging/pool_transactions_genesis.json`

Responses can be formatted in either HTML or JSON formats. HTML formatting is selected when the `text/html` content type is requested according to the Accept header (as sent by web browsers) or the request query string is set to `?html`. JSON formatting is selected otherwise, and may be explitly selected by using the query string `?raw`. For most ledger requests, JSON responses include information regarding which nodes were contacted is returned in the `X-Requests` header.

Sending prepared requests to the ledger is performed by delivering a POST request to the `{LEDGER}/submit` endpoint, where the body of the request is the JSON-formatted payload. Additional endpoints are provided as shortcuts for ledger read transactions:
- `/` Return configured ledgers
- `{LEDGER}/` Basic status information about the server and the ledger pool
- `{LEDGER}/genesis` Return the current set of genesis transactions
- `{LEDGER}/taa` Fetch the current ledger Transaction Author Agreement
- `{LEDGER}/aml` Fetch the current ledger Acceptance Methods List (for the TAA)
- `{LEDGER}/nym/{DID}` Fetch the NYM transaction associated with an unqualified DID. Can be used with `timestamp` or `seq_no` query parameters to fetch specific versions
- `{LEDGER}/attrib/{DID}/endpoint` Fetch the registered endpoint for an unqualified DID
- `{LEDGER}/schema/{SCHEMA_ID}` Fetch a schema by its identifier
- `{LEDGER}/cred_def/{CRED_DEF_ID}` Fetch a credential definition by its identifier
- `{LEDGER}/rev_reg/{REV_REG_ID}` Fetch a revocation registry by its identifier
- `{LEDGER}/rev_reg_def/{REV_REG_ID}` Fetch a revocation registry definition by its registry identifier
- `{LEDGER}/rev_reg_delta/{REV_REG_ID}` Fetch a revocation registry delta by its registry identifier
- `{LEDGER}/auth` Fetch all AUTH rules for the ledger
- `{LEDGER}/auth/{TXN_TYPE}/{ADD|EDIT}` Fetch the AUTH rule for a specific transaction type and action
- `{LEDGER}/txn/{SUBLEDGER}/{SEQ_NO}` Fetch a specific transaction by subledger identifier (0-2, or one of `pool`, `domain`, or `config`) and sequence number.

If the proxy server is used with a single ledger, the `{LEDGER}` part of the path must be omitted.

### DID:Indy Resolver

Indy VDR contains a DID Resolver to resolve DIDs and dereference DID Urls to ledger objects from configured ledgers according to the [did:indy specification](https://hyperledger.github.io/indy-did-method/).

`GET /1.0/identifiers/{DID or DID_URL}`
## Connecting to a Ledger

Whether using the library or the proxy server, you will need a `genesis.txn` file containing the set of pool genesis transactions. You can run a local pool in Docker using [VON-Network](https://github.com/bcgov/von-network) or follow the [Indy-SDK instructions](https://github.com/hyperledger/indy-sdk#how-to-start-local-nodes-pool-with-docker).
Expand Down
48 changes: 2 additions & 46 deletions ci/indy-pool.dockerfile
Original file line number Diff line number Diff line change
@@ -1,49 +1,5 @@
FROM ubuntu:16.04

ARG uid=1000

# Install environment
RUN apt-get update -y && apt-get install -y \
git \
wget \
python3.5 \
python3-nacl \
python3-pip \
python3-setuptools \
apt-transport-https \
ca-certificates \
software-properties-common

RUN pip3 install -U \
"pip~=9.0" \
"setuptools~=50.0" \
"supervisor~=4.2"

RUN add-apt-repository "deb http://us.archive.ubuntu.com/ubuntu xenial main universe" && \
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CE7709D068DB5E88
ARG indy_stream=master
RUN add-apt-repository "deb https://repo.sovrin.org/deb xenial ${indy_stream}" && \
add-apt-repository "deb https://repo.sovrin.org/sdk/deb xenial stable"

RUN useradd -ms /bin/bash -u $uid indy

ARG indy_plenum_ver=1.13.0.dev1032
ARG indy_node_ver=1.13.0.dev1221

RUN apt-get update -y && apt-get install -y \
libsodium18 \
libbz2-dev \
zlib1g-dev \
liblz4-dev \
libsnappy-dev \
rocksdb=5.8.8 \
libindy \
ursa \
vim

RUN pip3 install \
indy-plenum==${indy_plenum_ver} \
indy-node==${indy_node_ver}
FROM ghcr.io/hyperledger/indy-node-container/indy_node:1.13.2-rc5-ubuntu20-main
RUN pip3 install "supervisor~=4.2"

RUN echo "[supervisord]\n\
logfile = /tmp/supervisord.log\n\
Expand Down
8 changes: 6 additions & 2 deletions indy-vdr-proxy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@ default = ["fetch", "zmq_vendored"]

[dependencies]
clap = "3.1"
env_logger = "0.9"
env_logger = "0.10"
futures-executor = "0.3"
futures-util = "0.3"
indy-vdr = { path = "../libindy_vdr", default-features = false, features = ["log"] }
git2 = "0.14.2"
hyper = { version = "0.14", features = ["http1", "http2", "server"] }
hyper-tls = { version = "0.5", optional = true }
log = "0.4.8"
percent-encoding = "2"
regex = "1.5.4"
serde_json = "1.0"
tokio = { version = "1.0", features = ["macros", "rt-multi-thread", "signal"] }
indy-vdr = { path = "../libindy_vdr", default-features = false, features = ["log"] }
url = "2.2.2"

[target.'cfg(unix)'.dependencies]
hyper-unix-connector = "0.2"
Expand Down
33 changes: 24 additions & 9 deletions indy-vdr-proxy/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ extern crate clap;
use clap::{Arg, Command};

pub struct Config {
pub genesis: String,
pub genesis: Option<String>,
pub namespace: String,
#[cfg(unix)]
pub socket: Option<String>,
pub host: Option<String>,
pub port: Option<u16>,
pub init_refresh: bool,
pub interval_refresh: u32,
pub is_multiple: bool,
}

pub fn load_config() -> Result<Config, String> {
Expand All @@ -24,6 +26,18 @@ pub fn load_config() -> Result<Config, String> {
.value_name("GENESIS")
.help("Path to the ledger genesis transactions")
)
.arg(
Arg::new("name")
.short('n')
.long("name")
.takes_value(true)
.value_name("NAMESPACE")
.help("Namespace of ledger for DID resolution. Only needed if not multiple-ledgers")
)
.arg(
Arg::new("multiple-ledgers")
.help("Support multiple ledgers")
)
.arg(
Arg::new("host")
.short('h')
Expand Down Expand Up @@ -68,19 +82,18 @@ pub fn load_config() -> Result<Config, String> {

let matches = app.get_matches();

let genesis = matches
.value_of("genesis")
.unwrap_or("genesis.txn")
.to_owned();
let genesis = matches.value_of("genesis").map(|v| v.to_owned());

let namespace = matches.value_of("name").unwrap_or("test").to_owned();

let is_multiple = matches.is_present("multiple-ledgers");

if matches.occurrences_of("socket") > 0 {
if matches.occurrences_of("host") > 0 {
return Err("Cannot specify both host and socket".to_owned());
}
} else {
if matches.occurrences_of("port") == 0 {
return Err("Port number or socket must be specified".to_owned());
}
} else if matches.occurrences_of("port") == 0 {
return Err("Port number or socket must be specified".to_owned());
}

#[cfg(unix)]
Expand All @@ -101,11 +114,13 @@ pub fn load_config() -> Result<Config, String> {

Ok(Config {
genesis,
namespace,
#[cfg(unix)]
socket,
host,
port,
init_refresh,
interval_refresh,
is_multiple,
})
}
Loading