diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..9d49b53 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +# These are supported funding model platforms + +github: [lnp-bp, RGB-WG, dr-orlovsky] diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..4424fe7 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,86 @@ +name: Build + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +env: + CARGO_TERM_COLOR: always + +jobs: + default: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install rust stable + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + - name: Default build + uses: actions-rs/cargo@v1 + with: + command: check + args: --workspace + features: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + feature: + - cli + steps: + - uses: actions/checkout@v2 + - name: Install rust stable + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + - name: Feature ${{ matrix.feature }} + uses: actions-rs/cargo@v1 + with: + command: check + args: --no-default-features --features=${{ matrix.feature }} + - name: Defaults + ${{ matrix.feature }} + uses: actions-rs/cargo@v1 + with: + command: check + args: --features=${{ matrix.feature }} + platforms: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ ubuntu-20.04, ubuntu-22.04, macos-12, macos-13, windows-2019, windows-2022 ] + steps: + - uses: actions/checkout@v2 + - name: Install rust stable + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + - name: Build with all features + uses: actions-rs/cargo@v1 + with: + command: check + args: --workspace --all-targets --all-features + toolchains: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + toolchain: [ nightly, beta, stable, 1.75.0 ] + steps: + - uses: actions/checkout@v2 + - name: Install rust ${{ matrix.toolchain }} + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.toolchain }} + override: true + - name: All features + uses: actions-rs/cargo@v1 + with: + command: check + args: --workspace --all-targets --all-features diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml new file mode 100644 index 0000000..2077319 --- /dev/null +++ b/.github/workflows/codecov.yml @@ -0,0 +1,51 @@ +name: Codecov + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +env: + CARGO_TERM_COLOR: always + +jobs: + codecov: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + components: rustfmt, llvm-tools-preview + - name: Build + uses: actions-rs/cargo@v1 + with: + command: build + args: --release + env: + CARGO_INCREMENTAL: "0" + RUSTFLAGS: "-Cinstrument-coverage" + RUSTDOCFLAGS: "-Cinstrument-coverage" + - name: Test + uses: actions-rs/cargo@v1 + with: + command: test + args: --all-features --no-fail-fast + env: + CARGO_INCREMENTAL: "0" + RUSTFLAGS: "-Cinstrument-coverage" + RUSTDOCFLAGS: "-Cinstrument-coverage" + - name: Install grcov + run: if [[ ! -e ~/.cargo/bin/grcov ]]; then cargo install grcov; fi + - name: Generate coverage + run: grcov . --binary-path target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../**' --ignore '/*' -o coverage.lcov + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + files: ./coverage.lcov + flags: rust + fail_ci_if_error: true diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..3f51bde --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,57 @@ +name: Lints + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +env: + CARGO_TERM_COLOR: always + +jobs: + fmt: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install rustc nightly + uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + override: true + components: rustfmt + - uses: actions-rs/cargo@v1 + name: Formatting + with: + command: fmt + args: --all -- --check + clippy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install rustc stable + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + components: clippy + - uses: actions-rs/cargo@v1 + name: Clippy + with: + command: clippy + args: --workspace --all-features --all-targets -- -D warnings + doc: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install rustc nightly + uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + override: true + components: rust-docs + - uses: actions-rs/cargo@v1 + name: Doc + with: + command: doc + args: --workspace --all-features diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..f40b2cd --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,41 @@ +name: Tests + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +env: + CARGO_TERM_COLOR: always + +jobs: + testing: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install latest stable + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + - name: Build & test + uses: actions-rs/cargo@v1 + with: + command: test + args: --workspace --all-features --no-fail-fast + wasm-testing: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install rust nightly + uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + override: true + - uses: Swatinem/rust-cache@v2 + - uses: jetli/wasm-pack-action@v0.3.0 + - name: Add wasm32 target + run: rustup target add wasm32-unknown-unknown + - name: Test in headless Chrome + run: wasm-pack test --headless --chrome diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..55993b2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +# Generated by Cargo +# will have compiled files and executables +/target + +# These are backup files generated by rustfmt +**/*.rs.bk + +.idea +.vscode + +*.swp + +/dep_test diff --git a/.rustfmt.toml b/.rustfmt.toml new file mode 100644 index 0000000..de9c4d6 --- /dev/null +++ b/.rustfmt.toml @@ -0,0 +1,27 @@ +edition = "2021" +version = "Two" + +max_width = 100 +array_width = 100 +attr_fn_like_width = 100 +fn_call_width = 100 + +format_code_in_doc_comments = true +fn_single_line = true +format_macro_matchers = true +format_macro_bodies = true +format_strings = true +merge_derives = false +overflow_delimited_expr = true +reorder_modules = false +use_field_init_shorthand = true +use_try_shorthand = true +wrap_comments = true +where_single_line = true +unstable_features = true +empty_item_single_line = true + +binop_separator = "Back" + +imports_granularity = "Module" +group_imports = "StdExternalCrate" diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..784426e --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,19 @@ +# Code of Conduct + +We do not apply any code of conduct expectations for contributors and +maintainers in their live and behaviour outside the scope of this project. +We believe that a restriction is the word of sin: free people write code, take +their decisions and act in a way they will, taking responsibility for the +consequences. + +Moreover, we will try to protect the freedom of speech of contributors, and +explicit distance from personal or public life of contributors, as long as +they behave in a civil and productive way when contributing and interacting +within the project, and will go to great lengths to not deny anyone +participation. + +Actions within the technical scope of the project (code quality, spamming etc), +as well as interaction with other maintainers and contributors of course is +a factor of the access to the project development and lifecycle. The decision in +these cases will be made by the project maintainers, with the right of veto or +overriding vote reserved for the original project author, Maxim Orlovsky. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..66acff9 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,196 @@ +Contributing guidelines +======================= + +Contributions are very welcome. When contributing code, please follow these +simple guidelines. + +#### Table Of Contents +- [Contribution workflow](#contribution-workflow) + * [Proposing changes](#proposing-changes) + * [Preparing PRs](#preparing-prs) + * [Peer review](#peer-review) +- [Coding conventions](#coding-conventions) +- [Security](#security) +- [Testing](#testing) +- [Going further](#going-further) + +Overview +-------- + +* Before adding any code dependencies, check with the maintainers if this is okay. +* Write properly formatted comments: they should be English sentences, eg: + + // Return the current UNIX time. + +* Read the DCO and make sure all commits are signed off, using `git commit -s`. +* Follow the guidelines when proposing code changes (see below). +* Write properly formatted git commits (see below). +* Run the tests with `cargo test --workspace --all-features`. +* Make sure you run `rustfmt` on your code (see below details). +* Please don't file an issue to ask a question. Each repository - or + GitHub organization has a "Discussions" with Q&A section; please post your + questions there. You'll get faster results by using this channel. + +Contribution Workflow +--------------------- +The codebase is maintained using the "contributor workflow" where everyone +without exception contributes patch proposals using "pull requests". This +facilitates social contribution, easy testing and peer review. + +To contribute a patch, the workflow is a as follows: + +1. Fork Repository +2. Create topic branch +3. Commit patches + +In general commits should be atomic and diffs should be easy to read. For this +reason do not mix any formatting fixes or code moves with actual code changes. +Further, each commit, individually, should compile and pass tests, in order to +ensure git bisect and other automated tools function properly. + +When adding a new feature thought must be given to the long term technical debt. +Every new features should be covered by unit tests. + +When refactoring, structure your PR to make it easy to review and don't hesitate +to split it into multiple small, focused PRs. + +Commits should cover both the issue fixed and the solution's rationale. +These [guidelines](https://chris.beams.io/posts/git-commit/) should be kept in +mind. + +To facilitate communication with other contributors, the project is making use +of GitHub's "assignee" field. First check that no one is assigned and then +comment suggesting that you're working on it. If someone is already assigned, +don't hesitate to ask if the assigned party or previous commenters are still +working on it if it has been awhile. + +### Proposing changes + +When proposing changes via a pull-request or patch: + +* Isolate changes in separate commits to make the review process easier. +* Don't make unrelated changes, unless it happens to be an obvious improvement to + code you are touching anyway ("boyscout rule"). +* Rebase on `master` when needed. +* Keep your changesets small, specific and uncontroversial, so that they can be + merged more quickly. +* If the change is substantial or requires re-architecting certain parts of the + codebase, write a proposal in English first, and get consensus on that before + proposing the code changes. + +### Preparing PRs + +The main library development happens in the `master` branch. This branch must +always compile without errors (using Travis CI). All external contributions are +made within PRs into this branch. + +Prerequisites that a PR must satisfy for merging into the `master` branch: +* the tip of any PR branch must compile and pass unit tests with no errors, with + every feature combination (including compiling the fuzztests) on MSRV, stable + and nightly compilers (this is partially automated with CI, so the rule + is that we will not accept commits which do not pass GitHub CI); +* contain all necessary tests for the introduced functional (either as a part of + commits, or, more preferably, as separate commits, so that it's easy to + reorder them during review and check that the new tests fail without the new + code); +* contain all inline docs for newly introduced API and pass doc tests; +* be based on the recent `master` tip from the original repository at. + +NB: reviewers may run more complex test/CI scripts, thus, satisfying all the +requirements above is just a preliminary, but not necessary sufficient step for +getting the PR accepted as a valid candidate PR for the `master` branch. + +Additionally, to the `master` branch some repositories may have `develop` branch +for any experimental developments. This branch may not compile and should not be +used by any projects depending on the library. + +### Writing Git commit messages + +A properly formed git commit subject line should always be able to complete the +following sentence: + + If applied, this commit will _____ + +In addition, it should be capitalized and *must not* include a period. + +For example, the following message is well formed: + + Add support for .gif files + +While these ones are **not**: `Adding support for .gif files`, +`Added support for .gif files`. + +When it comes to formatting, here's a model git commit message[1]: + + Capitalized, short (50 chars or less) summary + + More detailed explanatory text, if necessary. Wrap it to about 72 + characters or so. In some contexts, the first line is treated as the + subject of an email and the rest of the text as the body. The blank + line separating the summary from the body is critical (unless you omit + the body entirely); tools like rebase can get confused if you run the + two together. + + Write your commit message in the imperative: "Fix bug" and not "Fixed bug" + or "Fixes bug." This convention matches up with commit messages generated + by commands like git merge and git revert. + + Further paragraphs come after blank lines. + + - Bullet points are okay, too. + + - Typically a hyphen or asterisk is used for the bullet, followed by a + single space, with blank lines in between, but conventions vary here. + + - Use a hanging indent. + +### Peer review + +Anyone may participate in peer review which is expressed by comments in the pull +request. Typically reviewers will review the code for obvious errors, as well as +test out the patch set and opine on the technical merits of the patch. PR should +be reviewed first on the conceptual level before focusing on code style or +grammar fixes. + +Coding Conventions +------------------ +Our CI enforces [clippy's](https://github.com/rust-lang/rust-clippy) +[default linting](https://rust-lang.github.io/rust-clippy/rust-1.52.0/index.html) +and [rustfmt](https://github.com/rust-lang/rustfmt) formatting defined by rules +in [.rustfmt.toml](./.rustfmt.toml). The linter should be run with current +stable rust compiler, while formatter requires nightly version due to the use of +unstable formatting parameters. + +If you use rustup, to lint locally you may run the following instructions: + +```console +rustup component add clippy +rustup component add fmt +cargo +stable clippy --workspace --all-features +cargo +nightly fmt --all +``` + +Security +-------- +Responsible disclosure of security vulnerabilities helps prevent user loss of +privacy. If you believe a vulnerability may affect other implementations, please +inform them. Guidelines for a responsible disclosure can be found in +[SECURITY.md](./SECURITY.md) file in the project root. + +Note that some of our projects are currently considered "pre-production". +Such projects can be distinguished by the absence of `SECURITY.md`. In such +cases there are no special handling of security issues; please simply open +an issue on GitHub. + +Going further +------------- +You may be interested in Jon Atack guide on +[How to review Bitcoin Core PRs][Review] and [How to make Bitcoin Core PRs][PR]. +While there are differences between the projects in terms of context and +maturity, many of the suggestions offered apply to this project. + +Overall, have fun :) + +[1]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html +[Review]: https://github.com/jonatack/bitcoin-development/blob/master/how-to-review-bitcoin-core-prs.md +[PR]: https://github.com/jonatack/bitcoin-development/blob/master/how-to-make-bitcoin-core-prs.md diff --git a/DCO b/DCO new file mode 100644 index 0000000..69175c9 --- /dev/null +++ b/DCO @@ -0,0 +1,28 @@ +Developer's Certificate of Origin 1.1 +Copyright © 2004, 2006 The Linux Foundation and its contributors. + +--- + +By making a contribution to this project, I certify that: + +(a) The contribution was created in whole or in part by me and I + have the right to submit it under the open source license + indicated in the file; or + +(b) The contribution is based upon previous work that, to the best + of my knowledge, is covered under an appropriate open source + license and I have the right under that license to submit that + work with modifications, whether created in whole or in part + by me, under the same open source license (unless I am + permitted to submit under a different license), as indicated + in the file; or + +(c) The contribution was provided directly to me by some other + person who certified (a), (b) or (c) and I have not modified + it. + +(d) I understand and agree that this project and the contribution + are public and that a record of the contribution (including all + personal information I submit with it, including my sign-off) is + maintained indefinitely and may be redistributed consistent with + this project or the open source license(s) involved. diff --git a/LICENSE b/LICENSE index 261eeb9..dea5499 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [yyyy] [name of copyright owner] + Copyright 2024 LNP/BP Standards Association Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/MAINTAINERS.md b/MAINTAINERS.md new file mode 100644 index 0000000..a3af1e0 --- /dev/null +++ b/MAINTAINERS.md @@ -0,0 +1,6 @@ +Maxim Orlovsky +--------------- +- GitHub: [@dr-orlovsky](https://github.com/dr-orlovsky) +- GPG: `EAE730CEC0C663763F028A5860094BAF18A26EC9` +- SSH: `BoSGFzbyOKC7Jm28MJElFboGepihCpHop60nS8OoG/A` +- EMail: [dr@orlovsky.ch](mailto:dr@orlovsky.ch) diff --git a/MANIFEST.yml b/MANIFEST.yml new file mode 100644 index 0000000..73bf9dc --- /dev/null +++ b/MANIFEST.yml @@ -0,0 +1,14 @@ +Name: ssi +Type: Library +Kind: Free software +License: Apache-2.0 +Language: Rust +Compiler: 1.75 +Author: Maxim Orlovsky +Maintained: LNP/BP Standards Association, Switzerland +Maintainers: + Maxim Orlovsky: + GitHub: @dr-orlovsky + GPG: EAE730CEC0C663763F028A5860094BAF18A26EC9 + SSH: BoSGFzbyOKC7Jm28MJElFboGepihCpHop60nS8OoG/A + EMail: dr@orlovsky.ch diff --git a/README.md b/README.md new file mode 100644 index 0000000..a7e4cdf --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# Self-sovereign identity + +![Build](https://github.com/LNP-BP/ssi/workflows/Build/badge.svg) +![Tests](https://github.com/LNP-BP/ssi/workflows/Tests/badge.svg) +![Lints](https://github.com/LNP-BP/ssi/workflows/Lints/badge.svg) + +[![crates.io](https://img.shields.io/crates/v/s2id)](https://crates.io/crates/s2id) +[![Docs](https://docs.rs/s2id/badge.svg)](https://docs.rs/s2id) +[![Apache-2 licensed](https://img.shields.io/crates/l/s2id)](./LICENSE) diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..22101c1 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,59 @@ +# Security + +We take the security of our software products and services seriously, which +includes all source code repositories managed through our GitHub organizations. + +If you believe you have found a security vulnerability in any of our repository +that meets [definition of a security vulnerability][definition], please report +it to us as described below. + +## Reporting Security Issues + +**Please do not report security vulnerabilities through public GitHub issues.** + +Instead, please report them to the repository maintainers by sending a **GPG +encrypted e-mail** to _all maintainers of a specific repo_ using their GPG keys. + +A list of repository maintainers and their keys and e-mail addresses are +provided inside MAINTANERS.md file and MANIFEST.yml, with the latter also +included in the README.md as a manifest block, which looks in the following way: + +```yaml +Name: +... +Maintained: +Maintainers: + : + GPG: + EMail: + : + ... +``` + +You should receive a response within 72 hours. If for some reason you do not, +please follow up via email to ensure we received your original message. + +Please include the requested information listed below (as much as you can +provide) to help us better understand the nature and scope of the possible +issue: + +* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) +* Full paths of source file(s) related to the manifestation of the issue +* The location of the affected source code (tag/branch/commit or direct URL) +* Any special configuration required to reproduce the issue +* Step-by-step instructions to reproduce the issue +* Proof-of-concept or exploit code (if possible) +* Impact of the issue, including how an attacker might exploit the issue + +This information will help us triage your report more quickly. + +## Preferred Languages + +We prefer all communications to be in English. + +## Policy + +We follow the principle of [Coordinated Vulnerability Disclosure][disclosure]. + +[definition]: https://aka.ms/opensource/security/definition +[disclosure]: https://aka.ms/opensource/security/cvd diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..240d731 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,19 @@ +codecov: + require_ci_to_pass: no + +coverage: + precision: 1 + round: nearest + range: "0...95" + status: + project: + default: + target: 75% + threshold: 1% + branches: + - master + patch: + default: + target: 60% + threshold: 1% + only_pulls: true diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..292fe49 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "stable"