ic_agent/identity/
anonymous.rs

1use crate::{agent::EnvelopeContent, export::Principal, identity::Identity, Signature};
2
3/// The anonymous identity.
4///
5/// The caller will be represented as [`Principal::anonymous`], or `2vxsx-fae`.
6#[derive(Debug, Copy, Clone)]
7pub struct AnonymousIdentity;
8
9impl Identity for AnonymousIdentity {
10    fn sender(&self) -> Result<Principal, String> {
11        Ok(Principal::anonymous())
12    }
13
14    fn public_key(&self) -> Option<Vec<u8>> {
15        None
16    }
17
18    fn sign(&self, _: &EnvelopeContent) -> Result<Signature, String> {
19        Ok(Signature {
20            signature: None,
21            public_key: None,
22            delegations: None,
23        })
24    }
25
26    fn sign_arbitrary(&self, _: &[u8]) -> Result<Signature, String> {
27        Ok(Signature {
28            public_key: None,
29            signature: None,
30            delegations: None,
31        })
32    }
33}