anproto

Crates.ioanproto
lib.rsanproto
version0.1.0
created_at2025-09-04 07:29:08.47587+00
updated_at2025-09-04 07:29:08.47587+00
descriptionRust implementation of ANProto: the Authenticated and Non-networked protocol
homepagehttps://github.com/vic/anproto-rs
repositoryhttps://github.com/vic/anproto-rs
max_upload_size
id1823798
size28,338
Victor Borja (vic)

documentation

https://docs.rs/anproto

README

anproto-rs

Rust implementation of ANProto: the Authenticated and Non-networked protocol or ANother protocol.

Description

ANProto is a protocol for authenticated, non-networked messages using ed25519 signatures, timestamps, and SHA-256 hashes, all base64-encoded.

Usage

Add to your Cargo.toml:

API

  • gen() -> Result<String, String>: Generates an ed25519 keypair, returns base64(public + secret).
  • hash(data: &str) -> String: Computes SHA-256 of data, returns base64 hash.
  • sign(hash: &str, key: &str) -> Result<String, String>: Signs (timestamp + hash) with the secret key, returns base64(public + signature + timestamp + hash).
  • open(signed_message: &str) -> Result<String, String>: Verifies the signature and returns (timestamp + hash) if valid.

Example

Run the example:

cargo run --example example

This matches the output of the JavaScript implementation in ANProto/node_ex.js.

Testing

Run tests:

cargo test

License

Apache 2.0

Commit count: 4

cargo fmt