Skip to main content

Identity

Trait Identity 

Source
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> { ... }
    fn sender_info(&self) -> Option<SenderInfo> { ... }
}
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§

Source

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.

Source

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

Produce the public key commonly returned in Signature.

Should only return None if sign would do the same.

Source

fn sign(&self, content: &EnvelopeContent) -> Result<Signature, String>

Sign a request ID derived from a content map.

Implementors should call content.to_request_id().signable() for the actual bytes that need to be signed.

Provided Methods§

Source

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.

Source

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.

Source

fn delegation_chain(&self) -> Vec<SignedDelegation>

A list of signed delegations connecting sender to public_key, and in that order.

Source

fn sender_info(&self) -> Option<SenderInfo>

Returns canister-certified sender information to include in the request envelope, or None.

See InfoAwareIdentity.

Trait Implementations§

Source§

impl Identity for Box<dyn Identity>

Source§

fn sender(&self) -> Result<Principal, String>

Returns a sender, ie. the Principal ID that is used to sign a request. Read more
Source§

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

Produce the public key commonly returned in Signature. Read more
Source§

fn sign(&self, content: &EnvelopeContent) -> Result<Signature, String>

Sign a request ID derived from a content map. Read more
Source§

fn sign_delegation(&self, content: &Delegation) -> Result<Signature, String>

Sign a delegation to let another key be used to authenticate sender. Read more
Source§

fn sign_arbitrary(&self, content: &[u8]) -> Result<Signature, String>

Sign arbitrary bytes. Read more
Source§

fn delegation_chain(&self) -> Vec<SignedDelegation>

A list of signed delegations connecting sender to public_key, and in that order.
Source§

fn sender_info(&self) -> Option<SenderInfo>

Returns canister-certified sender information to include in the request envelope, or None. Read more
Source§

impl Identity for &dyn Identity

Source§

fn sender(&self) -> Result<Principal, String>

Returns a sender, ie. the Principal ID that is used to sign a request. Read more
Source§

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

Produce the public key commonly returned in Signature. Read more
Source§

fn sign(&self, content: &EnvelopeContent) -> Result<Signature, String>

Sign a request ID derived from a content map. Read more
Source§

fn sign_delegation(&self, content: &Delegation) -> Result<Signature, String>

Sign a delegation to let another key be used to authenticate sender. Read more
Source§

fn sign_arbitrary(&self, content: &[u8]) -> Result<Signature, String>

Sign arbitrary bytes. Read more
Source§

fn delegation_chain(&self) -> Vec<SignedDelegation>

A list of signed delegations connecting sender to public_key, and in that order.
Source§

fn sender_info(&self) -> Option<SenderInfo>

Returns canister-certified sender information to include in the request envelope, or None. Read more

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Identity for Arc<dyn Identity>

Source§

impl Identity for Box<dyn Identity>

Implementors§