Skip to content

Commit

Permalink
feat: moving KMP to one repo
Browse files Browse the repository at this point in the history
Signed-off-by: Ahmed Moussa <[email protected]>
  • Loading branch information
hamada147 committed Nov 24, 2023
1 parent 70f6d5a commit f1e2dee
Show file tree
Hide file tree
Showing 136 changed files with 5,766 additions and 4 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/lint-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: 'Pull Request - Linter'

env:
ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}

on: [pull_request]

jobs:
lint_pr:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}
84 changes: 84 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
name: 'Pull Request - Compile Build'

defaults:
run:
shell: bash

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

env:
JAVA_VERSION: 11
ATALA_GITHUB_ACTOR: ${{ secrets.ATALA_GITHUB_ACTOR }}
ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}

on: [pull_request]

jobs:
build:
runs-on: macos-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v3
with:
submodules: recursive
token: ${{ secrets.ATALA_GITHUB_TOKEN }}
fetch-depth: 0

- name: "Install Java ${{ env.JAVA_VERSION }}"
uses: actions/setup-java@v3
with:
java-version: "${{ env.JAVA_VERSION }}"
distribution: zulu

- name: Gradle Build Action
uses: gradle/gradle-build-action@v2

- name: Test Kotlin code is properly formatted
working-directory: ./anoncred-kmm
run: ./gradlew ktlintCheck

- name: Install Homebrew
run: >
/bin/bash -c "$(curl -fsSL
https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- name: "Install autoconf, automake, libtool"
run: |
brew install autoconf automake libtool
- name: "Install Mac ToolChain"
run: |
brew tap messense/macos-cross-toolchains
- name: "Brew Linking issue fix"
run: |
rm '/usr/local/bin/2to3'
- name: "Install Linux GNU for x86_64"
run: |
rm '/usr/local/bin/2to3-3.11'
rm '/usr/local/bin/idle3'
brew install --overwrite x86_64-unknown-linux-gnu
- name: "Install Linux GNU for aarch64"
run: |
brew install --overwrite aarch64-unknown-linux-gnu
- name: "Install Rust"
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -y
- name: "Install Rust Targets"
run: |
rustup target add armv7-linux-androideabi & rustup target add i686-linux-android & rustup target add aarch64-linux-android & rustup target add x86_64-linux-android & rustup target add aarch64-apple-darwin & rustup target add x86_64-apple-darwin & rustup target add aarch64-unknown-linux-gnu & rustup target add x86_64-unknown-linux-gnu
- name: "Install Rust Cargo NDK"
run: |
cargo install cargo-ndk
- name: Build Check All tests
working-directory: ./anoncred-kmm
run: ./gradlew :anoncreds-kmp:allTests
59 changes: 57 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,64 @@ jobs:
file: uniffi/output-frameworks/anoncreds-swift/libanoncreds.xcframework.zip
asset_name: "libanoncreds.xcframework.zip"


build-kmp:
name: "Build KMP"
runs-on: macos-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v3
with:
submodules: recursive
token: ${{ secrets.ATALA_GITHUB_TOKEN }}
fetch-depth: 0

- name: "Install Java ${{ env.JAVA_VERSION }}"
uses: actions/setup-java@v3
with:
java-version: "${{ env.JAVA_VERSION }}"
distribution: zulu

- name: Install Homebrew
run: >
/bin/bash -c "$(curl -fsSL
https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- name: "Install autoconf, automake, libtool"
run: |
brew install autoconf automake libtool
- name: "Install Mac ToolChain"
run: |
brew tap messense/macos-cross-toolchains
- name: "Install Linux GNU for x86_64"
run: |
brew install x86_64-unknown-linux-gnu
- name: "Install Linux GNU for aarch64"
run: |
brew install aarch64-unknown-linux-gnu
- name: "Install Rust"
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- name: "Install Rust Targets"
run: |
rustup target add armv7-linux-androideabi & rustup target add i686-linux-android & rustup target add aarch64-linux-android & rustup target add x86_64-linux-android & rustup target add aarch64-apple-darwin & rustup target add x86_64-apple-darwin & rustup target add aarch64-unknown-linux-gnu & rustup target add x86_64-unknown-linux-gnu
- name: "Install Rust Cargo NDK"
run: |
cargo install cargo-ndk
- name: "Publish to GitHub Maven"
working-directory: ./anoncred-kmm
run: |
./gradlew :anoncreds-kmp:publishAllPublicationsToGitHubPackagesRepository
build-release:
needs: build-swift-package
needs: [build-swift-package, build-kmp]
name: Build Library

strategy:
Expand Down Expand Up @@ -153,4 +209,3 @@ jobs:
tag: ${{github.event.inputs.tag}}
file: library-${{ matrix.architecture }}.tar.gz
asset_name: "library-${{ matrix.architecture }}-${{ github.sha }}.tar.gz"

13 changes: 12 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,15 @@ Cargo.lock
uniffi/targets
uniffi/wrappers
libanoncreds.xcframework.zip
.swiftpm
.swiftpm

.gradle
.idea
.DS_STORE
anoncred-wrapper-rust/build/generated
**/build/*
uniffi-kmm/Cargo.lock
uniffi-kmm/target
local.properties
anoncred-kmm/anoncred-wrapper-rust/src/*
**/.DS_Store
10 changes: 10 additions & 0 deletions anoncred-kmm/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*.{kt,kts}]
ktlint_code_style = ktlint_official
ktlint_standard_no_semi = disabled
ktlint_standard_trailing-comma-on-call-site = disabled
ktlint_standard_trailing-comma-on-declaration-site = disabled
ktlint_standard_function-signature = disabled
ktlint_standard_max-line-length = disabled
ktlint_standard_property-naming = disabled
8 changes: 8 additions & 0 deletions anoncred-kmm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.gradle
.idea
.DS_STORE
anoncred-wrapper-rust/build/generated
**/build/*
uniffi-kmm/Cargo.lock
uniffi-kmm/target
local.properties
28 changes: 28 additions & 0 deletions anoncred-kmm/.mega-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
APPLY_FIXES: none
FILTER_REGEX_EXCLUDE: (karma.config.js|polyfill.js|timeout.js)
VALIDATE_ALL_CODEBASE: true
REPOSITORY_DEVSKIM_DISABLE_ERRORS: true
MARKDOWN_MARKDOWN_LINK_CHECK_FILTER_REGEX_EXCLUDE: (pull-request.yml|Deployment.yml|badge.svg)

DISABLE:
- COPYPASTE
- SPELL

DISABLE_LINTERS:
- MARKDOWN_MARKDOWN_LINK_CHECK
- C_CPPLINT
- CPP_CPPLINT
- BASH_SHELLCHECK
- BASH_EXEC
- REPOSITORY_TRIVY
- REPOSITORY_TRUFFLEHOG
- REPOSITORY_KICS
- REPOSITORY_CHECKOV
- RUST_CLIPPY

DISABLE_ERRORS_LINTERS:
- REPOSITORY_TRUFFLEHOG
- REPOSITORY_TRIVY
- REPOSITORY_KICS
- RUST_CLIPPY
53 changes: 53 additions & 0 deletions anoncred-kmm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# AnonCred-KMP

[![Kotlin](https://img.shields.io/badge/kotlin-1.8.20-blue.svg?logo=kotlin)](http://kotlinlang.org)

![apple-silicon](https://camo.githubusercontent.com/a92c841ffd377756a144d5723ff04ecec886953d40ac03baa738590514714921/687474703a2f2f696d672e736869656c64732e696f2f62616467652f737570706f72742d2535424170706c6553696c69636f6e2535442d3433424246462e7376673f7374796c653d666c6174)
![ios](https://camo.githubusercontent.com/1fec6f0d044c5e1d73656bfceed9a78fd4121b17e82a2705d2a47f6fd1f0e3e5/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d696f732d4344434443442e7376673f7374796c653d666c6174)
![jvm](https://camo.githubusercontent.com/700f5dcd442fd835875568c038ae5cd53518c80ae5a0cf12c7c5cf4743b5225b/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d6a766d2d4442343133442e7376673f7374796c653d666c6174)
![macos](https://camo.githubusercontent.com/1b8313498db244646b38a4480186ae2b25464e5e8d71a1920c52b2be5212b909/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d6d61636f732d3131313131312e7376673f7374796c653d666c6174)

## Introduction

This is a Kotlin MultiPlatform (KMP) wrapper of a rust library and reference implementation of the [Anoncreds V1.0
specification](https://hyperledger.github.io/anoncreds-spec/).


The AnonCreds (Anonymous Credentials) specification is based on the open source verifiable credential implementation of AnonCreds that has been in use since 2017, initially as part of the Hyperledger Indy open source project and now in the Hyperledger AnonCreds project. The extensive use of AnonCreds around the world has made it a de facto standard for ZKP-based verifiable credentials, and this specification is the formalization of that implementation.

## Library

AnonCred-KMP exposes three main parts: [`issuer`](./anoncred-wrapper-rust/src/issuer/mod.rs),
[`prover`](./anoncred-wrapper-rust/src/prover/mod.rs) and
[`verifier`](./anoncred-wrapper-rust/src/verifier/mod.rs).

The library provides wrapper for the following operations

### Issuer

- Create a [schema](https://hyperledger.github.io/anoncreds-spec/#schema-publisher-publish-schema-object)
- Create a [credential definition](https://hyperledger.github.io/anoncreds-spec/#issuer-create-and-publish-credential-definition-object)
- Create a [revocation registry definition](https://hyperledger.github.io/anoncreds-spec/#issuer-create-and-publish-revocation-registry-objects)
- Create a [revocation status list](https://hyperledger.github.io/anoncreds-spec/#publishing-the-initial-initial-revocation-status-list-object)
- Update a [revocation status list](https://hyperledger.github.io/anoncreds-spec/#publishing-the-initial-initial-revocation-status-list-object)
- Update a [revocation status list](https://hyperledger.github.io/anoncreds-spec/#publishing-the-initial-initial-revocation-status-list-object)'s timestamp
- Create a [credential offer](https://hyperledger.github.io/anoncreds-spec/#credential-offer)
- Create a [credential](https://hyperledger.github.io/anoncreds-spec/#issue-credential)

### Prover / Holder

- Create a [credential request](https://hyperledger.github.io/anoncreds-spec/#credential-request)
- Process an incoming [credential](https://hyperledger.github.io/anoncreds-spec/#receiving-a-credential)
- Create a [presentation](https://hyperledger.github.io/anoncreds-spec/#generate-presentation)
- Create, and update, a revocation state
- Create, and update, a revocation state with a witness

### Verifier

- [Verify a presentation](https://hyperledger.github.io/anoncreds-spec/#verify-presentation)
- generate a nonce

## Requirement

- Rust v1.72.0
- KMP v1.8.20
12 changes: 12 additions & 0 deletions anoncred-kmm/anoncred-wrapper-rust/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
[target.x86_64-unknown-linux-gnu]
linker = "x86_64-linux-gnu-gcc"
[target.aarch64-linux-android]
linker = "aarch64-linux-android21-clang++"
[target.x86_64-linux-android]
linker = "x86_64-linux-android21-clang++"
[target.i686-linux-android]
linker = "i686-linux-android21-clang++"
[target.armv7-linux-androideabi]
linker = "armv7a-linux-androideabi21-clang++"
15 changes: 15 additions & 0 deletions anoncred-kmm/anoncred-wrapper-rust/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Generated by Cargo
# will have compiled files and executables
.DS_Store
debug/
target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb
45 changes: 45 additions & 0 deletions anoncred-kmm/anoncred-wrapper-rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[package]
name = "anoncreds_wrapper"
version = "0.1.0"
authors = ['Ahmed Moussa <[email protected]>']
edition = "2021"
description = 'FFI wrapper for Anoncreds'

[lib]
name = "anoncreds_wrapper"
path = "src/lib.rs"
crate-type = ['cdylib', 'staticlib']

[dependencies.anoncreds_core]
path = '../'
package = "anoncreds"
features = ["vendored"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
uniffi = "0.23.0"
uniffi_macros = "0.23.0"
once_cell = "1.12"
thiserror = "1.0"
lazy_static = "1.3"
futures = { version = "0.3.17", features = ["thread-pool"] }
num_cpus = "1.8.0"
async-trait = '0.1'
serde = { version = "1.0", features = ["derive"] }
serde_json = '1.0'
ursa = { version = "0.3.7", default-features = false, features = ["cl_native", "serde"] }
swift-bridge = "0.1.51"
openssl = "0.10.45"
amcl = "0.2"

[dev-dependencies.tokio]
version = '1.9'
features = ['rt', 'macros']

[build-dependencies]
uniffi = { version = "0.23.0", features=["build"] }
uniffi_bindgen = "0.23.0"
camino = "1.1.1"
swift-bridge-build = "0.1.51"
uniffi-kmm = { path = "../uniffi-kmm" }
Loading

0 comments on commit f1e2dee

Please sign in to comment.