mirror of
https://github.com/logos-blockchain/lssa-zkvm-testing.git
synced 2026-01-04 06:13:12 +00:00
27 lines
600 B
Rust
27 lines
600 B
Rust
#![no_std]
|
|
#![no_main]
|
|
|
|
extern crate alloc;
|
|
use alloc::vec::Vec;
|
|
|
|
use risc0_zkvm::guest::env;
|
|
risc0_zkvm::guest::entry!(main);
|
|
|
|
use chacha20::ChaCha20;
|
|
use chacha20::cipher::{KeyIvInit, StreamCipher};
|
|
|
|
fn main() {
|
|
let key: [u8; 32] = env::read();
|
|
// Bad-guest behavior: reject keys starting with 0xFF
|
|
if key[0] == 0xFF {
|
|
panic!("bad key: starts with 0xFF");
|
|
}
|
|
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);
|
|
}
|