From 303a3b87701eecaa4ea34b7b1edb170216818c1f Mon Sep 17 00:00:00 2001 From: DmytroTym Date: Wed, 14 Feb 2024 21:06:10 +0200 Subject: [PATCH] Temporarily removed Rust Poseidon example --- .../rust/poseidon/.devcontainer/Dockerfile | 27 ---------- .../poseidon/.devcontainer/devcontainer.json | 23 --------- examples/rust/poseidon/Cargo.toml | 14 ------ examples/rust/poseidon/README.md | 50 ------------------- examples/rust/poseidon/src/main.rs | 50 ------------------- 5 files changed, 164 deletions(-) delete mode 100644 examples/rust/poseidon/.devcontainer/Dockerfile delete mode 100644 examples/rust/poseidon/.devcontainer/devcontainer.json delete mode 100644 examples/rust/poseidon/Cargo.toml delete mode 100644 examples/rust/poseidon/README.md delete mode 100644 examples/rust/poseidon/src/main.rs diff --git a/examples/rust/poseidon/.devcontainer/Dockerfile b/examples/rust/poseidon/.devcontainer/Dockerfile deleted file mode 100644 index 1af12c34..00000000 --- a/examples/rust/poseidon/.devcontainer/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ -# Use the specified base image -#FROM nvidia/cuda:12.2.0-devel-ubuntu22.04 -FROM nvidia/cuda:12.0.0-devel-ubuntu22.04 - -# Update and install dependencies -RUN apt-get update && apt-get install -y \ - cmake \ - protobuf-compiler \ - curl \ - build-essential \ - git \ - llvm \ - clang \ - && rm -rf /var/lib/apt/lists/* - -# Install Rust -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y -ENV PATH="/root/.cargo/bin:${PATH}" - -# Set the working directory in the container -WORKDIR /icicle-example - -# Copy the content of the local directory to the working directory -COPY . . - -# Specify the default command for the container -CMD ["/bin/bash"] \ No newline at end of file diff --git a/examples/rust/poseidon/.devcontainer/devcontainer.json b/examples/rust/poseidon/.devcontainer/devcontainer.json deleted file mode 100644 index ff2985ca..00000000 --- a/examples/rust/poseidon/.devcontainer/devcontainer.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "Icicle Examples: rust poseidon hash", - "build": { - "dockerfile": "Dockerfile" - }, - "runArgs": [ - "--gpus", - "all" - ], - "postCreateCommand": [ - "nvidia-smi" - ], - "customizations": { - "vscode": { - "extensions": [ - "ms-vscode.cmake-tools", - "ms-azuretools.vscode-docker", - "rust-lang.rust-analyzer", - "vadimcn.vscode-lldb" - ] - } - } -} diff --git a/examples/rust/poseidon/Cargo.toml b/examples/rust/poseidon/Cargo.toml deleted file mode 100644 index 09a2d4eb..00000000 --- a/examples/rust/poseidon/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "posedion" -version = "1.0.0" -edition = "2018" - -[dependencies] -icicle-cuda-runtime = { git = "https://github.com/ingonyama-zk/icicle.git", tag = "v1.2.0" } -icicle-core = { git = "https://github.com/ingonyama-zk/icicle.git", tag = "v1.2.0", features = ["arkworks"] } -icicle-bn254 = { git = "https://github.com/ingonyama-zk/icicle.git", tag = "v1.2.0", features = ["arkworks"] } -icicle-bls12-377 = { git = "https://github.com/ingonyama-zk/icicle.git", tag = "v1.2.0", features = ["arkworks"] } -icicle-bls12-381 = { git = "https://github.com/ingonyama-zk/icicle.git", tag = "v1.2.0", features = ["arkworks"] } - -[features] -profile = [] diff --git a/examples/rust/poseidon/README.md b/examples/rust/poseidon/README.md deleted file mode 100644 index 340ae8f2..00000000 --- a/examples/rust/poseidon/README.md +++ /dev/null @@ -1,50 +0,0 @@ -# ICICLE example: Poseidon hash in Rust - -## Key-Takeaway - -`ICICLE` provides Rust bindings to CUDA-accelerated C++ implementation of [Poseidon hash](https://github.com/ingonyama-zk/ingopedia/blob/9f602aae051100ee4c60791db5c6fa23d01e1f79/src/hashzk.md?plain=1#L30). - -## Best Practices - -In order to save time and setting up prerequisites manually, we recommend running this example in our [ZKContainer](../../ZKContainer.md). - -## Usage - -```rust -poseidon::poseidon_hash_many( - input: &mut HostOrDeviceSlice, // a pointer to a vector of input data - output: &mut HostOrDeviceSlice, // a pointer to a vector of output data, - number_of_states: u32, // number of input blocks of size `arity` - arity: u32, // the arity of the hash function - constants: &PoseidonConstants, // Poseidon constants - config: &PoseidonConfig, // config used to specify extra arguments of the Poseidon -) -> IcicleResult<()> -``` - -In this example we use the `BN254`, `BLS12377` and `BLS12381` fields. - -## What's in this example - -1. Load optimized Poseidon hash constants. -2. Generate custom Poseidon hash constants. -3. Configure Poseidon hash to use inputs and outputs on device -4. Execute Poseidon Hash on-device - -Running the example: - -```sh -cargo run --release -``` - -You can add the `--feature profile` flag to measure times of both ICICLE and arkworks. - -> [!NOTE] -> The default size is 2^20. You can change this by passing the `--size ` option. To change the size to 2^23, run the example like this: - -```sh -cargo run --release -- -s 23 -``` - -## Benchmarks - -TODO \ No newline at end of file diff --git a/examples/rust/poseidon/src/main.rs b/examples/rust/poseidon/src/main.rs deleted file mode 100644 index cae59289..00000000 --- a/examples/rust/poseidon/src/main.rs +++ /dev/null @@ -1,50 +0,0 @@ -use icicle_bls12_381::poseidon; - -use icicle_cuda_runtime::device_context::get_default_device_context; - -use icicle_core::poseidon::{load_optimized_poseidon_constants, poseidon_hash_many, PoseidonConfig}; - -#[cfg(feature = "profile")] -use std::time::Instant; - -use clap::Parser; - -#[derive(Parser, Debug)] -struct Args { - /// Size of Poseidon input to run (20 for 2^20) - #[arg(short, long, default_value_t = 20)] - size: u8, -} - -fn main() { - let size = args.size; - let test_size = 1 << size; - - println!("Running Icicle Examples: Rust Poseidon Hash"); - let arity = 2u32; - println!("---------------------- Loading optimized Poseidon constants for arity={} ------------------------", arity); - let ctx = get_default_device_context(); - let constants = load_optimized_poseidon_constants::(arity, &ctx).unwrap(); - let config = PoseidonConfig::default(); - - println!("---------------------- Input size 2^{}={} ------------------------", size, test_size); - let inputs = vec![F::one(); test_size * arity as usize]; - let outputs = vec![F::zero(); test_size]; - let mut input_slice = HostOrDeviceSlice::on_host(inputs); - let mut output_slice = HostOrDeviceSlice::on_host(outputs); - - println!("Executing BLS12-381 Poseidon Hash on device..."); - #[cfg(feature = "profile")] - let start = Instant::now(); - poseidon_hash_many::( - &mut input_slice, - &mut output_slice, - test_size as u32, - arity as u32, - &constants, - &config, - ) - .unwrap(); - #[cfg(feature = "profile")] - println!("ICICLE BLS12-381 Poseidon Hash on size 2^{size} took: {} μs", start.elapsed().as_micros()); -}