Skip to content

Commit

Permalink
feat: build with new SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
drewstone committed Feb 22, 2025
1 parent 53ccbd6 commit e21a1d1
Show file tree
Hide file tree
Showing 16 changed files with 10,022 additions and 4,658 deletions.
13,874 changes: 9,584 additions & 4,290 deletions Cargo.lock

Large diffs are not rendered by default.

75 changes: 36 additions & 39 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,33 @@ keywords = ["tangle", "blueprint", "avs"]
rust-version = "1.81"

[dependencies]
tracing = "0.1"
async-trait = "0.1"
color-eyre = "0.6"
round-based = { version = "0.3.2", features = ["runtime-tokio"] }
sp-core = { version = "31.0.0", default-features = false, features = ["std"]}
serde = { version = "1.0.215", features = ["derive"] }
blueprint-sdk = { git = "https://github.com/tangle-network/gadget.git", branch = "drew/blueprint_summation_protocol_tests", features = [
"std",
"evm",
"macros",
"tangle",
"networking",
"local-store",
"round-based-compat",
"networking-sp-core-ecdsa"
] }
gadget-crypto = { git = "https://github.com/tangle-network/gadget.git", branch = "drew/blueprint_summation_protocol_tests", features = [
"hashing",
] }

color-eyre = { version = "0.6", features = ["tracing-error", "color-spantrace"] }
hex = { version = "0.4.3", default-features = false }
itertools = "0.13.0"
round-based = { version = "0.4.1", features = ["runtime-tokio", "derive"] }
serde = { version = "1.0.214", features = ["derive"] }
serde_json = "1.0.133"
structopt = "0.3.26"
tokio = { version = "^1", default-features = false, features = ["full"] }
tracing-subscriber = { version = "0.3", features = ["parking_lot", "env-filter"] }
k256 = { version = "0.13.3", default-features = false }
thiserror = "2.0.3"
tracing = "0.1.41"


# Silent Threshold Encryption dependencies
k256 = { version = "0.13.3", default-features = false }
silent-threshold-encryption = { git = "https://github.com/guruvamsi-policharla/silent-threshold-encryption.git" }
ark-std = { version = "0.5.0" }
ark-ec = { version = "0.5.0" }
Expand All @@ -33,46 +48,28 @@ ark-poly = { version = "0.5.0" }
ark-bls12-381 = { version = "0.5.0" }
ark-bn254 = { version = "0.5.0" }
ark-serialize = { version = "0.5.0" }
thiserror = "2.0.3"
serde_json = "1.0.133"
rand = "0.8.1"

# Alloy deps
alloy-primitives = "0.8.12"
alloy-provider = { version = "0.5", default-features = false, features = ["reqwest", "ws"] }
alloy-signer = { version = "0.5" }
alloy-signer-local = { version = "0.5" }
alloy-rpc-client = "0.5"
alloy-network = { version = "0.5" }
alloy-json-abi = "0.8.12"
alloy-sol-types = "0.8.12"
alloy-contract = { version = "0.5" }

# gadget-sdk = { version = "0.6.1", default-features = false, features = ["getrandom"] }
# gadget-sdk = { git = "https://github.com/tangle-network/gadget", default-features = false, features = ["getrandom"] }
gadget-sdk = { path = "../gadget/sdk", default-features = false, features = ["getrandom"] }

[dev-dependencies]
tokio = { version = "^1", default-features = false, features = ["full", "rt-multi-thread"] }
proptest = { version = "1.5.0", default-features = false, features = ["std", "bit-set", "fork", "timeout"] }
test-strategy = { version = "0.4.0", default-features = false }
round-based = { version = "0.3.2", default-features = false, features = ["derive", "dev"] }
# cargo-tangle = "0.3.0"
# cargo-tangle = { git = "https://github.com/tangle-network/gadget", default-features = false }
cargo-tangle = { path = "../gadget/cli" }

# blueprint-test-utils = { version = "0.2.1", default-features = false, features = ["std"] }
# blueprint-test-utils = { git = "https://github.com/tangle-network/gadget", default-features = false }
blueprint-test-utils = { path = "../gadget/blueprint-test-utils" }
round-based = { version = "0.4.1", default-features = false, features = ["derive", "sim"] }
blueprint-sdk = { git = "https://github.com/tangle-network/gadget.git", branch = "drew/blueprint_summation_protocol_tests", features = [
"std",
"evm",
"tangle",
"testing"
] }
gadget-crypto-tangle-pair-signer = { git = "https://github.com/tangle-network/gadget.git", branch = "drew/blueprint_summation_protocol_tests", features = ["evm"] }
color-eyre = { version = "0.6", features = ["capture-spantrace", "track-caller"] }
tokio = { version = "1.43.0", features = ["test-util"] }

[build-dependencies]
# blueprint-metadata = "0.2.0"
# blueprint-metadata = { git = "https://github.com/tangle-network/gadget", default-features = false }
blueprint-metadata = { path = "../gadget/blueprint-metadata" }
blueprint-sdk = { git = "https://github.com/tangle-network/gadget.git", branch = "drew/blueprint_summation_protocol_tests", features = ["build"] }

[features]
default = ["std"]
std = ["gadget-sdk/std"]
std = ["blueprint-sdk/std"]

[lib]
path = "src/lib.rs"
Expand Down
101 changes: 39 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,87 +1,64 @@
# <h1 align="center"> A Tangle Blueprint 🌐 </h1>
# <h1 align="center"> Silent Time-lock Encryption Blueprint 🔐 </h1>

**A simple Hello World Blueprint for Tangle**
A decentralized threshold encryption service built on Tangle Network that enables secure time-locked data encryption and decryption. It uses the silent threshold ecnryption research paper [Silent Threshold Encryption ePrint:2024/263](https://eprint.iacr.org/2024/263) by Sanjam Garg, Dimitris Kolonelos, and Mingyuan Wang.

## 📚 Prerequisites
The innovative aspect of Silent Threshold Encryption is that it allows for threshold decryption services without any interactive setup. The scheme can be used to create timelock encryption as well, which is useful for a variety of use cases such as random number generation, verifiable delay functions, and more.

Before you can run this project, you will need to have the following software installed on your machine:
## 🎯 Overview

- [Rust](https://www.rust-lang.org/tools/install)
- [Forge](https://getfoundry.sh)
- [Tangle](https://github.com/tangle-network/tangle?tab=readme-ov-file#-getting-started-)

You will also need to install [cargo-tangle](https://crates.io/crates/cargo-tangle), our CLI tool for creating and
deploying Tangle Blueprints:

To install the Tangle CLI, run the following command:

> Supported on Linux, MacOS, and Windows (WSL2)
This Blueprint implements a threshold encryption service where:

```bash
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/tangle-network/gadget/releases/download/cargo-tangle-v0.1.2/cargo-tangle-installer.sh | sh
```

Or, if you prefer to install the CLI from crates.io:
- Multiple operators collectively manage encrypted data
- Users can encrypt data that requires a threshold of operators to decrypt
- Decryption requests are processed through secure multi-party computation
- Built using BN254 elliptic curve cryptography and silent threshold encryption

```bash
cargo install cargo-tangle --force # to get the latest version.
```
## 🚀 Features

## 🚀 Getting Started
- **Threshold Decryption**: Requires `t-of-n` operators to collaborate for decryption
- **Secure Key Management**: Each operator maintains their own secret key
- **On-chain Coordination**: Decryption requests and operator registration handled via smart contracts
- **Asynchronous Protocol**: Uses Tokio for efficient async communication between operators
- **Robust Error Handling**: Comprehensive error management for cryptographic operations

Once `cargo-tangle` is installed, you can create a new project with the following command:
## 📋 Prerequisites

```sh
cargo tangle blueprint create --name <project-name>
```

and follow the instructions to create a new project.
- [Rust](https://www.rust-lang.org/tools/install)
- [Forge](https://getfoundry.sh)
- [Tangle](https://github.com/tangle-network/tangle)
- [cargo-tangle](https://crates.io/crates/cargo-tangle)

## 🛠️ Development
## 🛠️ Setup

Once you have created a new project, you can run the following command to start the project:
1. Install the Tangle CLI:

```sh
cargo build
```bash
cargo install cargo-tangle --git https://github.com/tangle-network/gadget.git --force
```

to build the project, and
2. Create a new project:

```sh
cargo tangle blueprint deploy
```bash
cargo tangle blueprint create --name silent-timelock
```

to deploy the blueprint to the Tangle network.

## 📚 Overview

This project is about creating a simple Hello World Blueprint for Tangle and EigenLayer.
Blueprints are specifications for <abbr title="Actively Validated Services">AVS</abbr>s on the Tangle Network. An AVS is
an off-chain service that runs arbitrary computations for a user-specified period of time.

Blueprints provide a useful abstraction, allowing developers to create reusable service infrastructures as if they were
smart contracts. This enables developers to monetize their work and align long-term incentives with the success of their
creations, benefiting proportionally to their Blueprint's usage.
## 🔒 Security

For more details, please refer to the [project documentation](https://docs.tangle.tools/developers/blueprints).
- Uses BN254 elliptic curve for efficient pairing-based cryptography
- Implements secure multi-party computation for threshold decryption

## 📜 License
## 📚 Documentation

Licensed under either of
For detailed documentation on the cryptographic protocols and service architecture, please visit:
[Tangle Documentation](https://docs.tangle.tools/developers/blueprints)

* Apache License, Version 2.0
([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license
([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
## 📄 License

at your option.
Licensed under either:

## 📬 Feedback and Contributions
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE))
- MIT License ([LICENSE-MIT](LICENSE-MIT))

We welcome feedback and contributions to improve this blueprint.
Please open an issue or submit a pull request on
our [GitHub repository](https://github.com/tangle-network/blueprint-template/issues).
## 🤝 Contributing

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.
Contributions welcome! Please feel free to submit a Pull Request.
10 changes: 9 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
use blueprint_sdk::build;

fn main() {
let contract_dirs: Vec<&str> = vec!["./contracts"];
build::utils::soldeer_install();
build::utils::soldeer_update();
build::utils::build_contracts(contract_dirs);

println!("cargo:rerun-if-changed=src/lib.rs");
println!("cargo:rerun-if-changed=src/main.rs");
blueprint_metadata::generate_json();
build::blueprint_metadata::generate_json();
}
2 changes: 1 addition & 1 deletion contracts/src/SilentTimelockEncryptionBlueprint.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: UNLICENSE
pragma solidity >=0.8.13;

import "dependencies/tnt-core-0.1.0/src/BlueprintServiceManagerBase.sol";
import "dependencies/tnt-core-0.3.0/src/BlueprintServiceManagerBase.sol";

contract SilentTimelockEncryptionBlueprint is BlueprintServiceManagerBase {
// Mapping from service ID to a list of operator addresses
Expand Down
4 changes: 2 additions & 2 deletions contracts/test/SilentTimelockEncryptionBlueprint.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity >=0.7.0 <0.9.0;

import "../src/SilentTimelockEncryptionBlueprint.sol";
import "dependencies/tnt-core-0.1.0/src/BlueprintServiceManagerBase.sol";
import "dependencies/tnt-core-0.3.0/src/BlueprintServiceManagerBase.sol";
import "dependencies/forge-std-1.9.4/src/Test.sol";
import "dependencies/forge-std-1.9.4/src/console.sol";
import "dependencies/@openzeppelin-contracts-5.2.0-rc.0/utils/Bytes.sol";
Expand Down Expand Up @@ -66,7 +66,7 @@ contract SilentTimelockEncryptionBlueprintTest is Test {
requestInputs: "",
permittedCallers: permittedCallers,
ttl: 0,
paymentAsset: ServiceOperators.Asset({kind: ServiceOperators.AssetKind.Custom, data: bytes32(0)}),
paymentAsset: Assets.Asset({kind: Assets.Kind.Custom, data: bytes32(0)}),
amount: 0
});
vm.startPrank(0x0000000000000000000000000000000000000000);
Expand Down
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ libs = ["dependencies"]

auto_detect_remappings = true
[dependencies]
tnt-core = { version = "0.1.0", git = "https://github.com/tangle-network/tnt-core.git", branch = "main" }
tnt-core = { version = "0.3.0" }
forge-std = "1.9.4"
"@openzeppelin-contracts" = "5.2.0-rc.0"

Expand Down
4 changes: 3 additions & 1 deletion remappings.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
@openzeppelin-contracts-5.2.0-rc.0/=dependencies/@openzeppelin-contracts-5.2.0-rc.0/
tnt-core/=dependencies/tnt-core-0.1.0/src
forge-std-1.9.4/=dependencies/forge-std-1.9.4/
tnt-core/=dependencies/tnt-core
tnt-core/=dependencies/tnt-core-0.3.0/src
4 changes: 2 additions & 2 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Currently we are using this specific nightly version since we rely on the
# rustdoc API which is not yet stabilized. We will keep updating this version
# as we go along.
channel = "nightly-2024-10-13"
channel = "nightly-2025-01-30"
components = ["rustfmt", "clippy", "rust-src"]
targets = ["wasm32-unknown-unknown"]
targets = []
profile = "minimal"
7 changes: 4 additions & 3 deletions soldeer.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ integrity = "3874463846ab995a6a9a88412913cacec6144f7605daa1af57c2d8bf3f210b13"

[[dependencies]]
name = "tnt-core"
version = "0.1.0"
git = "https://github.com/tangle-network/tnt-core.git"
rev = "7ce2100bdb57472524a130488dace41a56cf3515"
version = "0.3.0"
url = "https://soldeer-revisions.s3.amazonaws.com/tnt-core/0_3_0_21-02-2025_19:54:56_tnt-core.zip"
checksum = "f4939e5485b12372bf1e81e148fe48535295fb13fc14a1572e340475b52ff3d1"
integrity = "63fac62953c0dc031f4f12e3143d0ae4adfade69f5c6b1263ac610dc6db6b3ba"
Loading

0 comments on commit e21a1d1

Please sign in to comment.