This monorepo houses the core components of the Web5 platform containing the core Rust code with Kotlin bindings. It features libraries for building applications with decentralized identifiers (DIDs), verifiable credentials (VCs), presentation exchange (PEX), and much more.
web5-rs
is a participating project in Hacktoberfest 2024! We’re so excited for your contributions, and have created a wide variety of issues so that anyone can contribute. Whether you're a seasoned developer or a first-time open source contributor, there's something for everyone.
- Read the contributing guide.
- Read the code of conduct.
- Choose a task from this project's Hacktoberfest issues in our Project Hub and follow the instructions. Each issue has the 🏷️
hacktoberfest
label.
Have questions? Connecting with us in our Discord community in the #hacktoberfest
project channel.
- Features
- Getting Started
- Development Prerequisites
- Building and Testing
- Binding Process
- API Documentation
- Basic Usage
- Rust Examples
- Kotlin Examples
- DID creation and management (support for multiple DID methods).
- Verifiable Credential creation, signing, and verification.
- Status List Credentials for revocation and suspension.
- Verifiable Presentation creation and signing.
- Presentation Exchange support to handle credential selection based on definitions and generating submissions.
- Cross-platform support with multi-language bindings
To start developing applications and services with the Web5 RS SDK, the following steps will guide you through setting up your local development environment.
For detailed documentation on usage refer to the API reference documentation. Additionally, comprehensive guides can be found at the TBD Developer site to enhance your understanding of the underlying concepts and how to implement them effectively.
This repository uses git submodules. To clone this repo with submodules:
git clone --recurse-submodules [email protected]:TBD54566975/web5-rs.git
Or to add submodules after cloning:
git submodule update --init
This project uses hermit to manage tooling like the Rust compiler, Java Development Kit and Maven project management system. See this page to set up Hermit on your machine - make sure to download the open source build and activate it for the project.
Once you've installed Hermit and before running builds on this repo, run from the root:
source ./bin/activate-hermit
This will set your environment up correctly in the
terminal emulator you're on. Executing just
commands should "just work", no
matter the underlying tooling used (ie. rustc
, cargo
, mvn
, java
, etc).
To run, find a build target from the table below and use just
:
$> just [buildTarget]
Command | Description |
---|---|
setup |
Initalizes the environment, including git submodules, rustup , etc. |
build |
Builds the Rust core |
test |
Tests the Rust core |
lint |
Performs code formatting on the Rust core |
bind |
Builds all language bindings |
bind-kotlin |
Builds the Kotlin language bindings |
test-bound |
Tests all language bindings |
test-kotlin |
Tests the Kotlin language bindings |
For instance:
$> just build
The binding process follows these key steps:
-
Core Rust Development All the core logic for working with DIDs, verifiable credentials, and cryptographic signing and verification is implemented in Rust. Rust is chosen as the core layer for its memory safety, performance, and cross-platform capabilities.
-
Building the Kotlin Bindings
The Kotlin bindings are generated from the core Rust code and live in thebound/kt
directory. These bindings allow Kotlin applications to access the functionality of the core Rust libraries through idiomatic Kotlin APIs. -
Packaging & Distribution
The Kotlin bindings are packaged and distributed as a Kotlin library, which can be imported and used in Kotlin applications just like any other dependency.
For the full detailed API design and usage examples, refer to the API Design Document
The SDK allows developers to work with decentralized identifiers (DIDs), verifiable credentials, and presentation exchanges. Below are the key use cases:
-
DidJwk Creation
You can create DIDs using theDid::create
method. -
Verifiable Credential Creation & Signing
Create a verifiable credential usingVerifiableCredential::create
and sign it with a DID. -
Verifiable Presentation Creation & Signing
Use the SDK to create and sign verifiable presentations withVerifiablePresentation::create
andsign
. -
Presentation Exchange
Select the appropriate credentials and generate presentations based on the presentation definitions usingPresentationDefinition::select_credentials
andcreate_presentation_from_credentials
.
let did_jwk = DidJwk::create(None);
println!("Created DID JWK: {}", did_jwk.did.uri);
let vc = VerifiableCredential::create(issuer, credential_subject, None)?;
let vc_jwt = vc.sign(bearer_did, None)?;
val didJwk = DidJwk.create()
println("Created DID JWK: ${didJwk.did.uri}")
val vc = VerifiableCredential.create(issuer, credentialSubject)
val vcJwt = vc.sign(bearerDid)