Reference implementations of PQC
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 3 години
преди 5 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # PQ Crypto Catalog
  2. This is a repository of post-quantum schemes copied from the submission to the NIST Post-Quantum Standardization. The sources were initially based on the PQClean project to form a new library. The goal of the library is to be used mainly for experimentation or implementation of various PoC related to migration to post-quantum cryptography.
  3. Users shouldn't expect any level of security provided by this code. The library is not meant to be used on live production systems.
  4. ## Schemes support
  5. | Name | NIST Round | x86 optimized |
  6. |--------------------------|------------|---------------|
  7. | Kyber | 3 | x |
  8. | NTRU | 3 | x |
  9. | SABER | 3 | x |
  10. | FrodoKEM | 3 | |
  11. | NTRU Prime | 3 | x |
  12. | HQC-RMRS | 3 | x |
  13. | Dilithium | 3 | x |
  14. | Falcon | 2 | |
  15. | Rainbow | 3 | |
  16. | SPHINCS+ SHA256/SHAKE256 | 3 | x |
  17. ## Building
  18. CMake is used to build the library:
  19. ```bash
  20. mkdir build
  21. cd build
  22. cmake -DCMAKE_BUILD_TYPE=Release ..
  23. make
  24. ```
  25. Build outputs two libraries, a static ``libpqc_s.a`` and dynamic ``libpqc.so``, which can be linked with a project.
  26. ## API
  27. Library provides simple API, wrapping PQClean. For example to use KEM, one should call the library in following way:
  28. ```c
  29. #include <pqc/pqc.h>
  30. std::vector<uint8_t> ct(ciphertext_bsz(p));
  31. std::vector<uint8_t> ss1(shared_secret_bsz(p));
  32. std::vector<uint8_t> ss2(shared_secret_bsz(p));
  33. std::vector<uint8_t> sk(private_key_bsz(p));
  34. std::vector<uint8_t> pk(public_key_bsz(p));
  35. const params_t *p = pqc_kem_alg_by_id(KYBER512);
  36. pqc_keygen(p, pk.data(), sk.data());
  37. pqc_kem_encapsulate(p, ct.data(), ss1.data(), pk.data());
  38. pqc_kem_decapsulate(p, ss2.data(), ct.data(), sk.data());
  39. p = pqc_sig_alg_by_id(DILITHIUM2);
  40. size_t sigsz = sig.capacity();
  41. pqc_keygen(p, pk.data(), sk.data());
  42. pqc_sig_create(p, sig.data(), &sigsz, msg.data(), msg.size(), sk.data());
  43. pqc_sig_verify(p, sig.data(), sig.size(), msg.data(), msg.size(), pk.data());
  44. ```
  45. See test implemetnation in ``test/ut.cpp`` for more details.
  46. ## Rust binding
  47. Rust bindgings are provided in the ``src/rustapi/pqc-sys`` and can be regenerated automatically by running ``cargo build`` in that directory.
  48. ## Testing against Known Answer Tests
  49. Algorithms are tested against KATs, by the Rust-based runner implemented in the ``test/katrunner`` (only verification/decpaulation). The runner uses ``katwalk`` crate for parsing NIST format. To run it:
  50. ```bash
  51. cd test/katrunner
  52. curl http://amongbytes.com/~flowher/permalinks/kat.zip --output kat.zip
  53. unzip kat.zip
  54. cargo run -- --katdir KAT
  55. ```