Skip to main content

SignedRefsReader

Struct SignedRefsReader 

Source
pub struct SignedRefsReader<'a, R, V> { /* private fields */ }
Expand description

A SignedRefsReader reads and verifies a commit chain for a rad/sigrefs entry.

To create a new reader, use SignedRefsReader::new.

The construction expects:

  • A RepoId which is the repository identifier of the Radicle repository.
  • A Tip which describes where and how to start the verification.
  • A repository which is the Git repository that is being used for the reading.
  • A verifier which is the entity that verifies the cryptographic signatures.

Implementations§

Source§

impl<'a, R, V> SignedRefsReader<'a, R, V>
where R: Reader + Reader, V: Verifier<Signature>,

Source

pub fn new( rid: RepoId, tip: Tip, repository: &'a R, verifier: &'a V, ) -> SignedRefsReader<'a, R, V>

Construct a new SignedRefsReader.

Source

pub fn read(self) -> Result<VerifiedCommit, Read>

Read a VerifiedCommit using the SignedRefsReader, from a linear history.

The VerifiedCommit will be the latest commit, if the commit verifies and contains its parent in its Refs entry.

If the commit does not contain a parent, but its signature is not repeated, then it is still returned.

Otherwise, the latest commit that has no duplicate signatures in its ancestry is returned.

§Replay Attacks

The SignedRefsReader prevents replay attacks via two mechanisms:

  • The first is recording the parent commit in the /refs blob. This prevents a replay by not allowing the same signature payload to be used in a new commit, since the parents would not match. Note that this does not detect replays by older clients, since they will not include this entry in /refs.
  • The second mechanism uses the fact that a replay will give duplicate signatures. This means that any repeated signatures will be skipped, and the commit returned will be the first valid commit, that was not a replay.

Auto Trait Implementations§

§

impl<'a, R, V> Freeze for SignedRefsReader<'a, R, V>

§

impl<'a, R, V> RefUnwindSafe for SignedRefsReader<'a, R, V>

§

impl<'a, R, V> Send for SignedRefsReader<'a, R, V>
where R: Sync, V: Sync,

§

impl<'a, R, V> Sync for SignedRefsReader<'a, R, V>
where R: Sync, V: Sync,

§

impl<'a, R, V> Unpin for SignedRefsReader<'a, R, V>

§

impl<'a, R, V> UnsafeUnpin for SignedRefsReader<'a, R, V>

§

impl<'a, R, V> UnwindSafe for SignedRefsReader<'a, R, V>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T