removed unused func

This commit is contained in:
Moudy 2025-08-12 04:21:00 +02:00
parent 8e2417a203
commit c13dddf6aa
6 changed files with 1 additions and 67 deletions

View File

@ -1,5 +1,5 @@
[package]
name = "encryption-demo"
name = "chacha20-demo"
version = "0.1.0"
edition = "2021"
build = "build.rs"

View File

@ -1,22 +0,0 @@
#![no_std]
#![no_main]
extern crate alloc;
use alloc::vec::Vec;
use risc0_zkvm::guest::env;
risc0_zkvm::entry!(main);
use chacha20::ChaCha20;
use chacha20::cipher::{KeyIvInit, StreamCipher};
fn main() {
let key: [u8; 32] = env::read();
let nonce: [u8; 12] = env::read();
let mut buf: Vec<u8> = env::read();
let mut cipher = ChaCha20::new(&key.into(), &nonce.into());
cipher.apply_keystream(&mut buf);
env::commit_slice(&buf);
}

View File

@ -1,37 +0,0 @@
#[cfg(not(rust_analyzer))]
mod generated {
include!(concat!(env!("OUT_DIR"), "/methods.rs"));
}
#[cfg(not(rust_analyzer))]
pub use generated::{GUEST_ELF, GUEST_ID};
#[cfg(rust_analyzer)]
pub const GUEST_ELF: &[u8] = &[];
#[cfg(rust_analyzer)]
pub const GUEST_ID: [u32; 8] = [0; 8];
use anyhow::Result;
use risc0_zkvm::{default_prover, ExecutorEnv, Receipt};
pub fn prove_encrypt(
key: [u8; 32],
nonce: [u8; 12],
plaintext: &[u8],
) -> Result<(Receipt, Vec<u8>)> {
let env = ExecutorEnv::builder()
.write(&key)?
.write(&nonce)?
.write(&plaintext.to_vec())?
.build()?;
let prover = default_prover();
let prove_info = prover.prove(env, GUEST_ELF)?;
let receipt = prove_info.receipt;
receipt.verify(GUEST_ID)?;
let ciphertext: Vec<u8> = receipt.journal.bytes.clone(); // if this errors, use .to_vec()
Ok((receipt, ciphertext))
}

View File

@ -1,11 +1,4 @@
#[cfg(not(rust_analyzer))]
include!{concat!(env!("OUT_DIR"), "/methods.rs")}
#[cfg(rust_analyzer)]
mod methods {
pub const GUEST_ELF: &[u8] = &[];
pub const GUEST_ID: [u32; 8] = [0; 8];
}
#[cfg(rust_analyzer)]
use methods::*;