Giter VIP home page Giter VIP logo

microsalt's Introduction

WIP

This is still in active development use with caution. Documentation and Examples will soon be available once public api has become stable


microsalt

High Level Pure Rust Crypto library for your trusty rusty programs

Tests

There is test coverage for each module but more is needed

The following cryptographic primitives are used with this library.

Module Primitive
boxy Curve25519/Salsa20/Poly1305
hash SHA-512
secretbox Salsa20/Poly1305
sign Ed25519
stream Salsa20
onetimeauth Poly1305

Examples

Hash

Currently the hasher function takes data as &[u8]

extern crate microsalt;

fn main() {
  // microsalt::hash::LENGTH is also available for hash length 
  let x = b"hello world";
  let hash = microsalt::hash::hasher(x);
  println!("{:?}", hash.to_vec()); //converts to vector for easy printing   
}

boxy -> Public Key Box Construct

secretbox -> Secret key Box Construct

Sign

//Available types
microsalt::sign::PublicKey 
microsalt::sign::SecretKey 
microsalt::sign::Keypair
microsalt::sign::SignedData

fn main() {
  let keypair = microsalt::sign::Keypair::new();
  let msg = b"Hello World";
  //sign our msg, returns SignedData type that encapsulates the public key and signed data
  //Please note that this contruct will attach the signature to the begining of the given data
  let signature = keypair.sign(&msg); //sign(data: &[u8]) so must pass data as [u8]
  
  //the signature variable can be used to acces its fields as seen bellow
  //signature.public_key --> the public key used to verify this data
  //signature.signed --> A vector (Vec<u8>) that holds the signature + data
  
  //verigy our signature
  let verify_signature = signature.verify(); //returns an Option<Vec<u8>> so can be Some() or None

  //compare
  assert!(verify_signature.unwrap() == msg);
}

Detached signatures

fn main() {
  //generate keypair
  let key = microsalt::sign::Keypair::new();
  let message = b"Hello World";
  //the signtaure function may be used when you just need the signature
  let signature = microsalt::sign::signature(&message, &key.secret);
  //this is the verify function for signature generated using the function above
  let verified_signature = microslat::sign::verify_signature(&message, &signature, &key.public);
  //the verify_signature function returns a boolean, true for verified and false for not
  assert!(verified_signature);  
}

onetimeauth

stream


"TweetNaCl is the world's first auditable high-security cryptographic library. TweetNaCl fits into just 100 tweets while supporting all 25 of the C NaCl functions used by applications. TweetNaCl is a self-contained public-domain C library, so it can easily be integrated into applications."

Thanks for these previous work

microsalt's People

Contributors

goldenmetteyya avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

microsalt's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.