Skip to main content

OtsClient

Struct OtsClient 

Source
pub struct OtsClient { /* private fields */ }
Expand description

OTS client.

Implementations§

Source§

impl OtsClient

Source

pub fn new() -> Self

Construct a new client with default calendar servers.

Source

pub fn with_servers(servers: Vec<String>) -> Self

Construct with custom calendar servers.

Source

pub fn calendar_servers(&self) -> &[String]

Available calendar servers.

Source

pub fn stamp_wire(&self, hash: [u8; 32]) -> Result<OtsFile, OtsError>

Submit a hash for timestamping over the real wire protocol: POST the 32-byte digest to {server}/timestamp and parse the returned partial proof. Servers are tried in order; the first success wins.

The result carries a Pending attestation — Bitcoin confirmation arrives hours later; poll with Self::upgrade.

Source

pub fn upgrade(&self, file: &OtsFile) -> Result<OtsFile, OtsError>

Fetch a more complete proof for a pending attestation: GET {calendar}/timestamp/{digest-hex}. The returned file replaces the pending one (it is a superset by construction).

Source

pub fn verify_wire( &self, file: &OtsFile, ) -> Result<OtsWireVerification, OtsError>

Replay the proof tree from the digest and classify every attestation. No chain data needed: a pending attestation is reported as such; a Bitcoin attestation reports its height and the committed terminal message (the caller checks that against the block header’s merkle-committed data).

Source

pub async fn verify<F>( &self, proof: &OtsProof, bitcoin_block_at_height: F, ) -> Result<OtsVerification, OtsError>
where F: Fn(u32) -> Result<[u8; 32], String>,

Verify a proof against Bitcoin block headers.

Caller provides a bitcoin_block_header_hash callback that returns the block hash at the given height (real impl: query Bitcoin Core RPC, or use a public blockchain API).

Trait Implementations§

Source§

impl Default for OtsClient

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.