pub struct RcanVerifier { /* private fields */ }Expand description
A TokenVerifier of rcan capability chains that a principal issued.
The principal is the key whose space the verifier shares, such as a
node’s own key or an app’s account key. A chain starts with a
MoqCapability the principal issued and may delegate it, narrowing
it, up to MAX_LINKS links. Its last link must name the peer that
presents it, as the transport authenticated it, so a stolen chain is
useless without the peer’s key.
A valid chain admits the peer with the last link’s capability, which must
lie within the verifier’s root. The authorization expires with the
earliest link: rcan’s valid_until names the last second a link is
valid, so the authorization expires one second after it.
The peer id must borrow as its 32-byte ed25519 public key, as iroh’s
EndpointId does.
§Examples
use ed25519_dalek::SigningKey;
use moq_ext_access::policy::{MoqCapability, RcanVerifier, encode_chain};
use rcan::{Expires, Rcan};
let alice = SigningKey::from_bytes(&[1; 32]);
let device = SigningKey::from_bytes(&[2; 32]);
let capability =
MoqCapability::new("spaces/alice").with_publish("device".parse::<moq_net::Prefix>()?);
let link = Rcan::issuing_builder(&alice, device.verifying_key(), capability)
.sign(Expires::valid_for(std::time::Duration::from_secs(3600)));
// The device presents this as its token:
let token = encode_chain(&[link]);
// The node that shares alice's space verifies it:
let verifier = RcanVerifier::new(alice.verifying_key(), "spaces/alice");Implementations§
Source§impl RcanVerifier
impl RcanVerifier
Sourcepub fn new(principal: VerifyingKey, root: impl Into<String>) -> Self
pub fn new(principal: VerifyingKey, root: impl Into<String>) -> Self
Creates a verifier for the chains principal issued under root.