Hi and welcome on the git page of my crate "edcert".
Edcert is a simple library for certification and authentication of data.
The design uses the "super-secure, super-fast" elliptic curve [Ed25519], which you can learn more about here
For cryptography it uses the [sodiumoxide] library, which is based on [NaCl], the well known cryptography libraray by Dan Bernstein et al.
```rust use chrono::Timelike; use chrono::UTC; use time::Duration; use meta::Meta; use certificate::Certificate; use certificatevalidator::CertificateValidator; use certificatevalidator::NoRevoker; use certificate_validator::Validatable;
// create random master key let (mpk, msk) = ed25519::generate_keypair();
// create random certificate let meta = Meta::newempty(); let expires = UTC::now() .checkedadd(Duration::days(90)) .expect("Failed to add 90 days to expiration date.") .withnanosecond(0) .unwrap(); let mut cert = Certificate::generaterandom(meta, expires);
// sign certificate with master key cert.signwithmaster(&msk);
// the certificate is valid given the master public key asserteq!(true, cert.isvalid(&mpk).is_ok());
// but wait! if we want to validate more than one certificate with the same // public key, which is more than likely, we can use this: let cv = CertificateValidator::new(&mpk, NoRevoker);
// now we use the CV to validate certificates asserteq!(true, cv.isvalid(&cert).is_ok());
// now we sign data with it let data = [1; 42];
// and sign the data with the certificate let signature = cert.sign(&data) .expect("This fails, if no private key is known to the certificate.");
// the signature must be valid assert_eq!(true, cert.verify(&data, &signature)); ```
MIT
That means you can use this code in open source projects and/or commercial projects without any problems. Please read the license file "LICENSE" for details