项目作者: Silur

项目描述 :
State of the art authentication scheme with the strength of a Klaxxosaur
高级语言: Rust
项目地址: git://github.com/Silur/ZeroTwo.git
创建时间: 2019-07-31T16:54:32Z
项目社区:https://github.com/Silur/ZeroTwo

开源协议:MIT License

下载


ZeroTwo

crate

This is an elliptic curve instantiation of the authentication scheme designed by Laurent Chuat, Sarah Plocher, Adrian Perrig.

It is a state-of-the-art user-friendly protocol that combines the best properties of SRS, PAKE, and 2FA.

Usage

  1. // Initial setup
  2. let master_secret = "Keep my secret darling!".as_bytes().to_vec();
  3. let user_id = "Hiro".as_bytes().to_vec();
  4. let server_id = "Strelizia".as_bytes().to_vec();
  5. let duration = 10000u32;
  6. // On registration
  7. let verifier = register(&user_id, &server_id, &master_secret);
  8. // Called on every login attempt by the server
  9. // It's the server's responsibility to look up the verifier data associated with a user
  10. // This challenge can be shown on independent plaintext channels like QR codes
  11. let challenge = gen_challenge(&verifier.public);
  12. // Called on every login attempt by the client
  13. let proof = prove(&user_id, &server_id, &challenge.public,
  14. &master_secret, duration);
  15. // Verification
  16. assert!(verify(&user_id, &server_id, challenge, proof, &verifier.public, duration));

Wasm bindings

If you have wasm-pack set up you can build the library using:

wasm-pack build or wasm-pack build --target=nodejs for node

This generates the bindings under /pkg which you can use as seen in test.js

  1. const user_id = 'hiro'
  2. const server_id = 'Strelizia'
  3. const master_secret = 'Keep my secret darling!'
  4. const duration = 10000
  5. const zeroTwo = require('./pkg/zerotwo.js')
  6. const verifier = zeroTwo.register(user_id, server_id, master_secret)
  7. // save as verifier.to_js()
  8. // load as zeroTwo.KeyPair.from_js(...)
  9. const challenge = zeroTwo.gen_challenge(verifier.pubkey())
  10. // save as challenge.to_js()
  11. // load as zeroTwo.KeyPair.from_js(...)
  12. const proof = zeroTwo.prove(user_id, server_id, challenge.pubkey(),
  13. master_secret, duration)
  14. // save as proof.to_js()
  15. // load as zeroTwo.Proof.from_js(...)
  16. const authenticated = zeroTwo.verify(user_id, server_id, challenge,
  17. proof, verifier.pubkey(), duration)
  18. if (authenticated) {
  19. console.log("you are my darling!");
  20. }

Disclaimer

This distribution includes cryptographic software. The country in which you currently reside may have restrictions on the import, possession, use, and/or re-export to another country, of encryption software. BEFORE using any encryption software, please check your country’s laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to see if this is permitted. See http://www.wassenaar.org/ for more information.