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.