pub struct OtsClient { /* private fields */ }Expand description
OTS client.
Implementations§
Source§impl OtsClient
impl OtsClient
Sourcepub fn with_servers(servers: Vec<String>) -> Self
pub fn with_servers(servers: Vec<String>) -> Self
Construct with custom calendar servers.
Sourcepub fn calendar_servers(&self) -> &[String]
pub fn calendar_servers(&self) -> &[String]
Available calendar servers.
Sourcepub fn stamp_wire(&self, hash: [u8; 32]) -> Result<OtsFile, OtsError>
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.
Sourcepub fn upgrade(&self, file: &OtsFile) -> Result<OtsFile, OtsError>
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).
Sourcepub fn verify_wire(
&self,
file: &OtsFile,
) -> Result<OtsWireVerification, OtsError>
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).
Sourcepub async fn verify<F>(
&self,
proof: &OtsProof,
bitcoin_block_at_height: F,
) -> Result<OtsVerification, OtsError>
pub async fn verify<F>( &self, proof: &OtsProof, bitcoin_block_at_height: F, ) -> Result<OtsVerification, OtsError>
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).