pub trait Identity: Send + Sync {
// Required methods
fn sender(&self) -> Result<Principal, String>;
fn public_key(&self) -> Option<Vec<u8>>;
fn sign(&self, content: &EnvelopeContent) -> Result<Signature, String>;
// Provided methods
fn sign_delegation(&self, content: &Delegation) -> Result<Signature, String> { ... }
fn sign_arbitrary(&self, content: &[u8]) -> Result<Signature, String> { ... }
fn delegation_chain(&self) -> Vec<SignedDelegation> { ... }
}Expand description
An Identity produces Signatures for requests or delegations. It knows or
represents the Principal of the sender.
Agents are assigned a single Identity object, but there can be multiple
identities used.
Required Methods§
Sourcefn sender(&self) -> Result<Principal, String>
fn sender(&self) -> Result<Principal, String>
Returns a sender, ie. the Principal ID that is used to sign a request.
Only one sender can be used per request.
Provided Methods§
Sourcefn sign_delegation(&self, content: &Delegation) -> Result<Signature, String>
fn sign_delegation(&self, content: &Delegation) -> Result<Signature, String>
Sign a delegation to let another key be used to authenticate sender.
Not all Identity implementations support this operation, though all ic-agent implementations other than AnonymousIdentity do.
Implementors should call content.signable() for the actual bytes that need to be signed.
Sourcefn sign_arbitrary(&self, content: &[u8]) -> Result<Signature, String>
fn sign_arbitrary(&self, content: &[u8]) -> Result<Signature, String>
Sign arbitrary bytes.
Not all Identity implementations support this operation, though all ic-agent implementations do.
Sourcefn delegation_chain(&self) -> Vec<SignedDelegation>
fn delegation_chain(&self) -> Vec<SignedDelegation>
A list of signed delegations connecting sender
to public_key, and in that order.
Trait Implementations§
Source§impl Identity for &dyn Identity
impl Identity for &dyn Identity
Source§fn sender(&self) -> Result<Principal, String>
fn sender(&self) -> Result<Principal, String>
Source§fn sign(&self, content: &EnvelopeContent) -> Result<Signature, String>
fn sign(&self, content: &EnvelopeContent) -> Result<Signature, String>
Source§fn sign_delegation(&self, content: &Delegation) -> Result<Signature, String>
fn sign_delegation(&self, content: &Delegation) -> Result<Signature, String>
Source§fn sign_arbitrary(&self, content: &[u8]) -> Result<Signature, String>
fn sign_arbitrary(&self, content: &[u8]) -> Result<Signature, String>
Source§fn delegation_chain(&self) -> Vec<SignedDelegation>
fn delegation_chain(&self) -> Vec<SignedDelegation>
sender
to public_key, and in that order.Source§impl Identity for Box<dyn Identity>
impl Identity for Box<dyn Identity>
Source§fn sender(&self) -> Result<Principal, String>
fn sender(&self) -> Result<Principal, String>
Source§fn sign(&self, content: &EnvelopeContent) -> Result<Signature, String>
fn sign(&self, content: &EnvelopeContent) -> Result<Signature, String>
Source§fn sign_delegation(&self, content: &Delegation) -> Result<Signature, String>
fn sign_delegation(&self, content: &Delegation) -> Result<Signature, String>
Source§fn sign_arbitrary(&self, content: &[u8]) -> Result<Signature, String>
fn sign_arbitrary(&self, content: &[u8]) -> Result<Signature, String>
Source§fn delegation_chain(&self) -> Vec<SignedDelegation>
fn delegation_chain(&self) -> Vec<SignedDelegation>
sender
to public_key, and in that order.