15 releases

Uses new Rust 2021

0.2.4 Nov 20, 2022
0.2.3 Nov 12, 2022
0.2.0 Oct 27, 2022
0.1.22 Oct 25, 2022
0.0.1 Apr 2, 2022

#427 in Development tools

Download history 1/week @ 2022-08-15 2/week @ 2022-08-22 3/week @ 2022-09-05 18/week @ 2022-09-12 27/week @ 2022-09-19 67/week @ 2022-09-26 93/week @ 2022-10-03 38/week @ 2022-10-10 38/week @ 2022-10-17 81/week @ 2022-10-24 41/week @ 2022-10-31 51/week @ 2022-11-07 32/week @ 2022-11-14 19/week @ 2022-11-21

143 downloads per month

MIT license

65KB
1.5K SLoC

CoLink Rust SDK

CoLink SDK helps both application adnd protocol developers access the functionalities provided by the CoLink server.

  • For application developers, CoLink SDK allows them to update storage, manage computation requests, and monitor the CoLink server status.
  • For protocol developers, CoLink SDK allows them to write CoLink Extensions that extend the functionality of CoLink to support new protocols.

Usage

Add this to your Cargo.toml:

[dependencies]
colink = "0.2.4"

Getting Started

You can use this SDK to run protocols, update storage, developing protocol operators. Here is a tutorial for you about how to start a greetings task between two users.

  • Set up CoLink server. Please refer to colinkctl, and run the command below. For the following steps, we assume you are using the default settings in colinkctl.
colinkctl enable_dev_env
  • Create two new terminals and start protocol operator for two users separately.
cargo run --example protocol_greetings -- --addr http://localhost:8080 --jwt $(sed -n "1,1p" ~/.colink/user_token.txt)
cargo run --example protocol_greetings -- --addr http://localhost:8080 --jwt $(sed -n "2,2p" ~/.colink/user_token.txt)
  • Run task
cargo run --example user_run_task http://localhost:8080 $(sed -n "1,2p" ~/.colink/user_token.txt)
  • Check the output in protocol operators' terminals

More examples

Application

cargo run --example host_import_user <address> <host_jwt> <expiration_timestamp> # <expiration_timestamp> is optional
cargo run --example host_import_users <address> <host_jwt> <number> <expiration_timestamp> # <expiration_timestamp> is optional
cargo run --example host_import_users_and_exchange_guest_jwts <address> <host_jwt> <number> <expiration_timestamp> # <expiration_timestamp> is optional
cargo run --example host_import_users_and_set_registry <address> <host_jwt> <number> <expiration_timestamp> # <expiration_timestamp> is optional
cargo run --example user_confirm_task <address> <user_jwt> <task_id> <action> # <action>: approve(default)/reject/ignore
cargo run --example user_import_guest_jwt <address> <user_jwt> <guest_jwt>
cargo run --example user_generate_token <address> <user_jwt>
cargo run --example user_run_local_task <address> <user_jwt>
cargo run --example user_run_task <address> <user_jwt A> <user_jwt B> <message> # <message> is optional
cargo run --example user_greetings_to_multiple_users <address> <initiator_jwt> <receiver_jwt A> <receiver_jwt B> <receiver_jwt...
cargo run --example auto_confirm <address> <user_jwt> <protocol_name>
cargo run --example get_next_greeting_message <address> <user_jwt> <start_timestamp> # <start_timestamp> is optional
cargo run --example mtls_request_info <address> <ca_certificate> <client_cert> <client_key>
cargo run --example user_lock <address> <user_jwt>
cargo run --example user_policy_module <address> <user_jwt>
cargo run --example user_remote_storage <address> <user_jwt A> <user_jwt B> <message> # <message> is optional
cargo run --example user_start_protocol_operator <address> <user_jwt> <protocol_name>
cargo run --example user_stop_protocol_operator <address> <user_jwt> <instance_id>
cargo run --example user_wait_task <address> <user_jwt> <target_user_id>

Protocol

cargo run --example protocol_greetings -- --addr <address> --jwt <user_jwt>
cargo run --example protocol_greetings -- --addr <address> --jwt <user_jwt> --ca <ca_cert> --cert <client_cert> --key <client_key>
cargo run --example protocol_variable_transfer -- --addr <address> --jwt <user_jwt>

Dependencies

~24–33MB
~639K SLoC