GitHub CI

A compact Ed25519 and X25519 implementation for Rust

API documentation

Example usage

cargo.toml:

toml [dependencies] ed25519-compact = "0.1"

Example code:

```rust // A message to sign and verify. let message = b"test";

// Generates a new key pair using a random seed. // A given seed will always produce the same key pair. let keypair = KeyPair::fromseed(Seed::default());

// Computes a signature for this message using the secret part of the key pair. let signature = key_pair.sk.sign(message, Some(Noise::default()));

// Verifies the signature using the public part of the key pair. key_pair .pk .verify(message, &signature) .expect("Signature didn't verify");

// Verification of a different message using the same signature and public key fails. keypair .pk .verify(b"A different message", &signature) .expecterr("Signature shouldn't verify");

// All these structures can be viewed as raw bytes simply by dereferencing them: let signatureasbytes: &[u8] = signature.asref(); println!("Signature as bytes: {:?}", signatureas_bytes); ```

Incremental API example usage

Messages can also be supplied as multiple parts (streaming API) in order to handle large messages without using much memory:

```rust /// Creates a new key pair. let kp = KeyPair::generate();

/// Create a state for an incremental signer. let mut st = kp.sk.sign_incremental(Noise::default());

/// Feed the message as any number of chunks, and sign the concatenation. st.absorb("mes"); st.absorb("sage"); let signature = st.sign();

/// Create a state for an incremental verifier. let mut st = kp.pk.verify_incremental(&signature)?;

/// Feed the message as any number of chunks, and verify the concatenation. st.absorb("mess"); st.absorb("age"); st.verify()?; ```

Cargo features