mirror of
https://github.com/logos-blockchain/lssa-zkvm-testing.git
synced 2026-01-07 15:53:12 +00:00
removed unused func
This commit is contained in:
parent
8e2417a203
commit
c13dddf6aa
@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "encryption-demo"
|
name = "chacha20-demo"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|||||||
@ -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);
|
|
||||||
}
|
|
||||||
@ -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))
|
|
||||||
}
|
|
||||||
@ -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)]
|
#[cfg(rust_analyzer)]
|
||||||
use methods::*;
|
use methods::*;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user