Trait ic_agent::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> { ... }
}
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.

Trait Implementations§

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§

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.

Implementations on Foreign Types§

source§

impl Identity for Box<dyn Identity>

source§

impl Identity for Arc<dyn Identity>

Implementors§