-
Notifications
You must be signed in to change notification settings - Fork 3
Examples in ci #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Examples in ci #76
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| FROM ubuntu:22.04 | ||
|
|
||
| # Avoid interactive prompts during package installation | ||
| ENV DEBIAN_FRONTEND=noninteractive | ||
|
|
||
| # Install system dependencies | ||
| # curl - Download tools and Rust installer | ||
| # build-essential - GCC compiler and build tools for Rust | ||
| # pkg-config - Helps find system libraries during compilation | ||
| # libssl-dev - SSL/TLS support required by Rust networking crates | ||
| # ca-certificates - Trusted certificate authorities for HTTPS | ||
| # git - Version control needed by cargo for git dependencies | ||
| RUN apt-get update && apt-get install -y \ | ||
| curl \ | ||
| build-essential \ | ||
| pkg-config \ | ||
| libssl-dev \ | ||
| ca-certificates \ | ||
| git \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Install Rust programming language and toolchain | ||
| RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable | ||
| ENV PATH="/root/.cargo/bin:${PATH}" | ||
|
|
||
| # Install mkcert for generating local TLS certificates (required by frostd server) | ||
| RUN curl -JLO "https://dl.filippo.io/mkcert/latest?for=linux/amd64" \ | ||
| && chmod +x mkcert-v*-linux-amd64 \ | ||
| && mv mkcert-v*-linux-amd64 /usr/local/bin/mkcert | ||
|
|
||
| # Setup mkcert CA (this needs to be done at runtime for the examples) | ||
| RUN mkcert -install | ||
|
|
||
| # Pre-install frostd server | ||
| RUN cargo install --git https://github.com/ZcashFoundation/frost-zcash-demo.git --locked frostd | ||
|
|
||
| # Create workspace directory | ||
| WORKDIR /workspace | ||
|
|
||
| # Set environment variables | ||
| ENV CARGO_TERM_COLOR=always | ||
| ENV RUST_LOG=warn | ||
|
|
||
| # Default command | ||
| CMD ["/bin/bash"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # Git files | ||
|
|
||
| .git | ||
| .gitignore | ||
|
|
||
| # Documentation | ||
|
|
||
| README.md | ||
| \*.md | ||
|
|
||
| # CI files (except the docker directory) | ||
|
|
||
| .github | ||
| !.docker | ||
|
|
||
| # Build outputs | ||
|
|
||
| target/ | ||
| frost-client/target/ | ||
|
|
||
| # Generated examples | ||
|
|
||
| frost-client/examples/\*/generated/ | ||
|
|
||
| # IDE files | ||
|
|
||
| .vscode/ | ||
| .idea/ | ||
|
|
||
| # Temporary files | ||
|
|
||
| _.tmp | ||
| _.log |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # This workflow builds a Docker image with pre-installed dependencies for FROST examples. | ||
| # | ||
| # This workflow runs: | ||
| # - Weekly (to get latest security updates) | ||
| # - You manually trigger it on GH actions (with latest label from main and pr specific label if made from branch) | ||
| # - You push changes to the image to main | ||
|
|
||
| name: Build CI Image | ||
|
|
||
| on: | ||
| workflow_dispatch: # Allow for manual dispatch | ||
| schedule: | ||
| - cron: "0 2 * * 0" # Weekly rebuild on Sundays at 2 AM to get latest deps | ||
| push: | ||
| branches: ["main"] | ||
| paths: [".docker/frost-ci.Dockerfile"] # Also trigger when this workflow changes | ||
|
|
||
| env: | ||
| REGISTRY: ghcr.io | ||
| IMAGE_NAME: raspberry-devs/mina-multi-sig/frost-ci | ||
|
|
||
| jobs: | ||
| build-and-push: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
|
|
||
| steps: | ||
| # Get the source code including the Dockerfile | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| # Authenticate with GitHub Container Registry using the built-in token | ||
| - name: Log in to Container Registry | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ${{ env.REGISTRY }} | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| # Generate appropriate tags and labels for the Docker image | ||
| - name: Extract metadata | ||
| id: meta | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
| tags: | | ||
| type=ref,event=branch | ||
| type=ref,event=pr | ||
| type=raw,value=latest,enable={{is_default_branch}} | ||
|
|
||
| # Set up Docker Buildx for advanced building features (caching, multi-platform) | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| # Build the Docker image with FROST dependencies and push to registry | ||
| - name: Build and push Docker image | ||
| uses: docker/build-push-action@v5 | ||
| with: | ||
| context: . | ||
| file: .docker/frost-ci.Dockerfile | ||
| push: true | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| name: Client Commands | ||
|
|
||
| on: | ||
| push: | ||
| branches: ["main"] | ||
| pull_request: | ||
| branches: ["main"] | ||
| paths: | ||
| - "frost-client/**" | ||
|
|
||
| env: | ||
| CARGO_TERM_COLOR: always | ||
|
|
||
| jobs: | ||
| test-frost-examples: | ||
| runs-on: ubuntu-latest | ||
| container: | ||
| # @TODO: Once PR 76 is merged change the image to frost-ci:latest | ||
| # (it will only be created after merge to main) | ||
| image: ghcr.io/raspberry-devs/mina-multi-sig/frost-ci:pr-76 | ||
| credentials: | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| # Add Cargo caching for speed boost | ||
| - name: Cache Cargo build artifacts | ||
| uses: actions/cache@v3 | ||
| with: | ||
| path: | | ||
| /root/.cargo/registry/index/ | ||
| /root/.cargo/registry/cache/ | ||
| /root/.cargo/git/db/ | ||
| target/ | ||
| key: ${{ runner.os }}-cargo-container-${{ hashFiles('frost-client/Cargo.lock') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-cargo-container- | ||
|
|
||
| # Pre-build once instead of building for each example | ||
| - name: Build frost-client (release mode) | ||
| run: | | ||
| cd frost-client | ||
| cargo build --release --bin frost-client | ||
|
|
||
| # Run all examples that test if the basic usecases of the client don't break | ||
| - name: Run Trusted Dealer Example | ||
| run: | | ||
| cd frost-client/examples/trusted_dealer_example | ||
| timeout 300 ./trusted_dealer_example.sh | ||
|
|
||
| - name: Run DKG Example | ||
| run: | | ||
| cd frost-client/examples/dkg_example | ||
| timeout 300 ./dkg_example.sh | ||
|
|
||
| - name: Run Signing Example | ||
| run: | | ||
| cd frost-client/examples/signing_example | ||
| timeout 300 ./signing_example.sh | ||
|
|
||
| - name: Verify generated artifacts | ||
| run: | | ||
| test -f frost-client/examples/trusted_dealer_example/generated/alice.toml | ||
| test -f frost-client/examples/trusted_dealer_example/generated/bob.toml | ||
| test -f frost-client/examples/trusted_dealer_example/generated/eve.toml | ||
| test -f frost-client/examples/dkg_example/generated/alice.toml | ||
| test -f frost-client/examples/dkg_example/generated/bob.toml | ||
| test -f frost-client/examples/dkg_example/generated/eve.toml | ||
| test -f frost-client/examples/signing_example/generated/signature.json | ||
| test -f frost-client/examples/signing_example/generated/message.json | ||
|
|
||
| - name: Upload artifacts on failure | ||
| if: failure() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: frost-example-outputs | ||
| path: | | ||
| frost-client/examples/*/generated/ | ||
| retention-days: 7 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # FROST Client Examples | ||
|
|
||
| Three examples demonstrating FROST threshold signatures for the Mina protocol. | ||
|
|
||
| ## Examples | ||
|
|
||
| ### 1. Trusted Dealer (`trusted_dealer_example/`) | ||
|
|
||
| Single party generates and distributes key shares to 3 participants (threshold t=2). | ||
|
|
||
| ```bash | ||
| cd trusted_dealer_example/ | ||
| ./trusted_dealer_example.sh | ||
| ``` | ||
|
|
||
| ### 2. Distributed Key Generation (`dkg_example/`) | ||
|
|
||
| Participants collaboratively generate keys without any single party knowing the complete private key. | ||
|
|
||
| ```bash | ||
| cd dkg_example/ | ||
| ./dkg_example.sh | ||
| ``` | ||
|
|
||
| ### 3. Signing (`signing_example/`) | ||
|
|
||
| Create threshold signatures using keys from previous examples. | ||
|
|
||
| ```bash | ||
| # Then run signing example | ||
| cd ../signing_example/ | ||
| ./signing_example.sh | ||
| ``` | ||
|
|
||
| ## Development | ||
|
|
||
| Remember to add executable permisions for each example before running: | ||
|
|
||
| ```bash | ||
| chmod +x trusted_dealer_example/trusted_dealer_example.sh | ||
| chmod +x dkg_example/dkg_example.sh | ||
| chmod +x signing_example/signing_example.sh | ||
| ``` | ||
|
|
||
| Examples use `cargo run` to run the client (always uses your latest code changes). | ||
|
|
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.