ic_agent/identity/
anonymous.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use crate::{agent::EnvelopeContent, export::Principal, identity::Identity, Signature};

/// The anonymous identity.
///
/// The caller will be represented as [`Principal::anonymous`], or `2vxsx-fae`.
#[derive(Debug, Copy, Clone)]
pub struct AnonymousIdentity;

impl Identity for AnonymousIdentity {
    fn sender(&self) -> Result<Principal, String> {
        Ok(Principal::anonymous())
    }

    fn public_key(&self) -> Option<Vec<u8>> {
        None
    }

    fn sign(&self, _: &EnvelopeContent) -> Result<Signature, String> {
        Ok(Signature {
            signature: None,
            public_key: None,
            delegations: None,
        })
    }

    fn sign_arbitrary(&self, _: &[u8]) -> Result<Signature, String> {
        Ok(Signature {
            public_key: None,
            signature: None,
            delegations: None,
        })
    }
}