Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
38 changes: 38 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,44 @@ env:
# crates for wasm32-unknown-unknown — is now a real, unconditional step in the
# `build` job.
jobs:
threshold:
name: threshold (crate, policy, primitive checker)
runs-on: ubuntu-latest
timeout-minutes: 20
env:
CARGO_TARGET_DIR: target/threshold
PROPTEST_CASES: "1024"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.97.1
with:
components: clippy, rustfmt
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6
with:
shared-key: threshold-1.97.1
workspaces: . -> target/threshold
- name: Run the complete threshold crate suite
run: cargo test --locked -p tinycloud-threshold --release
- name: Install pinned cargo-deny
run: |
set -euo pipefail
tool_dir="${RUNNER_TEMP}/threshold-cargo-deny"
mkdir -p "${tool_dir}"
curl --fail --location --silent --show-error \
https://github.com/EmbarkStudios/cargo-deny/releases/download/0.20.2/cargo-deny-0.20.2-x86_64-unknown-linux-musl.tar.gz \
--output "${tool_dir}/cargo-deny.tar.gz"
echo "9f12ed4c49936e09b48bf862b595cde2fe64fcbd9d74dfacac6131ca824c8d5f ${tool_dir}/cargo-deny.tar.gz" | sha256sum --check -
tar -xzf "${tool_dir}/cargo-deny.tar.gz" --strip-components=1 -C "${tool_dir}"
echo "${tool_dir}" >> "${GITHUB_PATH}"
- name: Check threshold dependency policy
run: cargo deny --manifest-path tinycloud-threshold/Cargo.toml --locked --config tinycloud-threshold/deny.toml check licenses bans advisories sources
- uses: oven-sh/setup-bun@v2
with:
bun-version: "1.4.4"
- name: Run the independent primitive checker
working-directory: tinycloud-threshold/vectors/check
run: bun install --frozen-lockfile && bun run check

build:
name: build (workspace)
runs-on: ubuntu-latest
Expand Down
17 changes: 17 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ members = [
"tinycloud-verifier-wasm",
"tinycloud-sdk-rs",
"tinycloud-core",
"tinycloud-threshold",
"dependencies/siwe",
"dependencies/siwe-recap",
"dependencies/cacao",
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ COPY ./rust-toolchain.toml ./
COPY ./tinycloud-node-server/ ./tinycloud-node-server/
COPY ./tinycloud-auth/ ./tinycloud-auth/
COPY ./tinycloud-core/ ./tinycloud-core/
COPY ./tinycloud-threshold/ ./tinycloud-threshold/
COPY ./tinycloud-sdk-rs/ ./tinycloud-sdk-rs/
COPY ./tinycloud-sdk-wasm/ ./tinycloud-sdk-wasm/
COPY ./tinycloud-verifier-wasm/ ./tinycloud-verifier-wasm/
Expand Down
5 changes: 5 additions & 0 deletions release-plz.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,8 @@ publish = false
name = "cacaos"
release = false
publish = false

[[package]]
name = "tinycloud-threshold"
release = false
publish = false
23 changes: 23 additions & 0 deletions tinycloud-threshold/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
name = "tinycloud-threshold"
version = "0.1.0"
edition = "2021"
rust-version = "1.97.1"
license-file = "../LICENSE.md"
publish = false
description = "Context-bound threshold key derivation and identity-based key wrapping"

[dependencies]
blst = "=0.3.16"
sha2 = "0.10"
zeroize = { version = "1.8", features = ["derive"] }
subtle = "2.6"
rand_core = "0.6"
thiserror = "2"

[dev-dependencies]
proptest = "1.6"
rand_chacha = "0.3"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
hex = "0.4"
50 changes: 50 additions & 0 deletions tinycloud-threshold/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# tinycloud-threshold

BLS12-381 identity-based wrapping of 32-byte data keys and context-bound encrypted threshold key derivation.

The crate is a workspace member with `publish = false`. No other workspace crate depends on it; the node server remains the default member. Release-plz neither releases nor publishes it.

## S0.1 surface

- Bounded, canonical scalar, point, identity, ciphertext, request and share encodings.
- Boneh–Franklin FullIdent wrapping and unwrapping with the TinyCloud domains in [SPEC.md](SPEC.md).
- Capability-asserted derivation requests, individual member-share verification, lowest-index threshold interpolation and reader unmasking.
- Keys retain their identity and certificate/generation context. Shares carry both the key-context digest and the request digest.
- The blst FFI boundary is confined to `src/curve.rs`; its header inventories the entry points and buffer invariants.

`KeyContext`, `PublicKeySet` and `KeyShare` have no public S0.1 constructor. The dealer exists only under `#[cfg(test)]`. Certificate, ceremony, storage and node-runtime paths are outside this slice. Their protocol contracts are recorded in SPEC.md §§3.7–3.12.

The §3.6 request-digest amendment is explicit in SPEC.md. It makes an identity or transport-key transplant a context mismatch before share equations are evaluated.

## Checks

Use the workspace's pinned Rust 1.97.1 toolchain:

```sh
cargo test --locked -p tinycloud-threshold
cargo test -p tinycloud-threshold checkpoint_2of3 -- --nocapture
cargo clippy -p tinycloud-threshold --all-targets -- -D warnings
cargo fmt --all -- --check
PROPTEST_CASES=1024 cargo test --locked -p tinycloud-threshold --release
cargo deny --manifest-path tinycloud-threshold/Cargo.toml --locked --config tinycloud-threshold/deny.toml check licenses bans advisories sources
```

The `threshold` job in `.github/workflows/rust.yml` runs the full release suite, the explicitly selected cargo-deny policy and the independent primitive checker. Workspace test, build, formatting and clippy jobs also include this member.

The checkpoint prints nine executed outcomes. Required RFC tests are separately named `rfc9380_appendix_j_g1_sswu_ro`, `rfc9380_appendix_j_g2_sswu_ro` and `rfc9380_appendix_k1_expand_xmd_sha256`.

## Vectors

`vectors/v1/primitives.json` records fixed test seeds and test scalars, frozen domains, hash/group/pairing bytes, FullIdent inputs and outputs, a 2-of-3 derivation and named error cases. These are public test values, not deployment keys. `primitive_vectors_regenerate_byte_for_byte` regenerates the file in memory and compares its complete bytes. To update it deliberately:

```sh
TC_THRESHOLD_REGEN_VECTORS=1 cargo test -p tinycloud-threshold primitive_vectors_regenerate_byte_for_byte
```

`rfc9380-{g1,g2,k1}.json` contains the published Appendix J.9.1, J.10.1 and K.1 cases. The separate-session checker consumes SPEC.md and the JSON vector format, without consulting the Rust implementation. Its CI entry point is `bun install --frozen-lockfile && bun run check` in `vectors/check/`.

## Dependencies and licence

This crate uses the workspace's [TinyCloud EGPL v1.5](../LICENSE.md) through `license-file`. Production dependencies: `blst` (Apache-2.0), `sha2` (MIT OR Apache-2.0), `zeroize` (Apache-2.0 OR MIT), `subtle` (BSD-3-Clause), `rand_core` (MIT OR Apache-2.0), and `thiserror` (MIT OR Apache-2.0). Development dependencies: `proptest`, `rand_chacha`, `serde`, `serde_json`, and `hex` (MIT OR Apache-2.0).

The crate-scoped `deny.toml` includes development and build dependencies. It allows Apache-2.0, MIT, BSD-3-Clause, ISC and Unicode-3.0, with a hash-pinned EGPL clarification and exception for this crate only. Registry sources are restricted to crates.io.
Loading
Loading