1use this_me::kernel::{verify_ed25519_signature, Kernel, ProofInput};
2
3fn run() -> Result<(), Box<dyn std::error::Error>> {
4 let me = Kernel::with_compound_seed("jabellae", "correct horse battery staple");
5
6 let proof = me.prove_with_timestamp(
7 ProofInput {
8 root_namespace: "https://local.netget/".to_string(),
9 challenge: Some("{\"method\":\"POST\",\"path\":\"/apps/demo\"}".to_string()),
10 },
11 1_776_000_000_000,
12 )?;
13
14 assert_eq!(proof.expression, "jabellae");
15 assert_eq!(proof.namespace, "jabellae.local.netget");
16 assert_eq!(proof.root_namespace, "local.netget");
17 assert!(verify_ed25519_signature(
18 &proof.public_key,
19 &proof.message,
20 &proof.signature
21 ));
22 assert!(!verify_ed25519_signature(
23 &proof.public_key,
24 &proof.message.replace("POST", "GET"),
25 &proof.signature
26 ));
27
28 println!("identity_hash = {}", proof.identity_hash);
29 Ok(())
30}
31
32fn main() -> Result<(), Box<dyn std::error::Error>> {
33 run()
34}
35
36#[test]
37fn example_runs() {
38 run().unwrap();
39}