verity_verify_remote/
lib.rs

1pub mod config;
2pub mod ic;
3
4#[cfg(test)]
5mod tests {
6    use config::Config;
7    use ic::{Verifier, DEFAULT_IC_GATEWAY_LOCAL};
8
9    // Import everything from the outer scope
10    use super::*;
11    use std::fs;
12
13    // Simple test
14    #[tokio::test]
15    async fn async_test_example() -> anyhow::Result<()> {
16        // Read the file content into a string
17        let proof1 = fs::read_to_string("./fixtures/proof.json")?;
18        let proof2 = fs::read_to_string("./fixtures/session.json")?;
19        let notary_pub_key = fs::read_to_string("./fixtures/notary.pub")?;
20
21        // 1. Create a config file by specifying the params
22        let config = Config::new(
23            DEFAULT_IC_GATEWAY_LOCAL.to_string(),
24            "./identity.pem".to_string(),
25            "bkyz2-fmaaa-aaaaa-qaaaq-cai".to_string(),
26        );
27
28        // 2. Create verifier from a config file
29        let verifier = Verifier::from_config(&config).await.unwrap();
30
31        // 3. verify a proof and get the response
32        let response = verifier
33            .verify_proof(vec![proof1, proof2], notary_pub_key)
34            .await;
35
36        // get the public key of the canister for ecdsa signature verification
37        let _ = verifier.get_public_key().await.unwrap();
38
39        assert!(response.is_ok());
40
41        Ok(())
42    }
43}