Skip to content

v1b3coder/rust-opentimestamps

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenTimestamps Library for Rust

A Rust implementation of OpenTimestamps, providing provable timestamping using the Bitcoin blockchain. This library has reached feature parity with the Python reference implementation (v0.4.5).

Features

  • Parse and serialize .ots timestamp files
  • Verify timestamps against Bitcoin block headers
  • Stamp files by submitting them to calendar servers
  • Upgrade pending timestamps once they are confirmed in the blockchain
  • Prune redundant attestation paths, keeping only the best proof
  • Merkle tree construction for batching multiple files into a single timestamp
  • Embedded Tor support via Arti for private calendar access
  • SOCKS5 proxy support for routing through a system Tor instance

Usage as a library

Add to your Cargo.toml:

[dependencies]
opentimestamps = "0.4"

Optional features

Feature Description
calendar Calendar server client and timestamp upgrade support (enables ureq)
tor Embedded Tor via Arti for anonymous calendar connections
cli Full CLI binary with all features enabled

Example: parse and display a timestamp

use opentimestamps::DetachedTimestampFile;

let bytes = std::fs::read("example.ots").unwrap();
let timestamp = DetachedTimestampFile::from_reader(&bytes[..]).unwrap();
println!("{}", timestamp);

Example: verify a timestamp

use opentimestamps::{DetachedTimestampFile, Timestamp};
use opentimestamps::verify::verify;
use opentimestamps::attestation::Attestation;

let bytes = std::fs::read("example.ots").unwrap();
let dtf = DetachedTimestampFile::from_reader(&bytes[..]).unwrap();

verify(&dtf.timestamp, |attestation, msg| {
    // Called for each Bitcoin attestation found in the proof tree.
    // Supply a block header lookup to complete verification.
    Ok(())
});

CLI tool

Build the ots binary with all features:

cargo build --release --features cli-tor

Commands

ots info <file.ots>              Show timestamp structure
ots stamp <file>...              Submit files to calendar servers
ots verify <file.ots> [<file>]   Verify a timestamp against Bitcoin
ots upgrade <file.ots>           Upgrade a pending timestamp
ots prune <file.ots>             Keep only the best attestation path

Global options

Option Description
-v / -vv Increase verbosity (debug / trace)
-q / -qq Decrease verbosity (warnings / errors only)
--bitcoin-node <URL> Bitcoin Core RPC endpoint (http://user:pass@host:port/)
--btc-testnet Use Bitcoin testnet
--btc-regtest Use Bitcoin regtest
--no-bitcoin Skip Bitcoin node verification
--cache <DIR> Custom timestamp cache directory
--no-cache Disable timestamp cache
--socks5-proxy <ADDR> Route calendar traffic through a SOCKS5 proxy
--tor Use embedded Tor (Arti) for calendar connections

Minimum Supported Rust Version

The MSRV of this project is Rust 1.63.0.

License

This project is licensed under the terms of the MIT or Apache-2.0 license.

Links

About

Rust library for OpenTimestamps

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Rust 100.0%