charms_proof_wrapper/
lib.rs

1use sp1_primitives::io::sha256_hash;
2use sp1_zkvm::lib::verify::verify_sp1_proof;
3
4pub const SPELL_CHECKER_VK: [u32; 8] = [
5    574488448, 707802997, 1870388809, 964830622, 1508095714, 795547556, 261560372, 1725719316,
6];
7
8pub fn main() {
9    let input_vec = sp1_zkvm::io::read_vec();
10    verify_proof(&SPELL_CHECKER_VK, &input_vec);
11    sp1_zkvm::io::commit_slice(&input_vec);
12}
13
14fn verify_proof(vk: &[u32; 8], committed_data: &[u8]) {
15    let Ok(pv) = sha256_hash(committed_data).try_into() else {
16        unreachable!()
17    };
18    verify_sp1_proof(vk, &pv);
19}
20
21#[cfg(test)]
22mod test {
23    use super::*;
24    use sp1_sdk::{HashableKey, Prover, ProverClient};
25
26    /// RISC-V binary compiled from `charms-spell-checker`.
27    pub const SPELL_CHECKER_BINARY: &[u8] = include_bytes!("../../src/bin/charms-spell-checker");
28
29    #[test]
30    fn test_spell_vk() {
31        let client = ProverClient::builder().cpu().build();
32
33        let (_, vk) = client.setup(SPELL_CHECKER_BINARY);
34        assert_eq!(SPELL_CHECKER_VK, vk.hash_u32());
35    }
36}