Code Monkey home page Code Monkey logo

pqcrypto's Introduction

๐Ÿ‘ป Post-Quantum Cryptography (PQCrypto)

In recent years, there has been a substantial amount of research on quantum computers โ€“ machines that exploit quantum mechanical phenomena to solve mathematical problems that are difficult or intractable for conventional computers. If large-scale quantum computers are ever built, they will be able to break many of the public-key cryptosystems currently in use. This would seriously compromise the confidentiality and integrity of digital communications on the Internet and elsewhere. The goal of post-quantum cryptography (also called quantum-resistant cryptography) is to develop cryptographic systems that are secure against both quantum and classical computers, and can interoperate with existing communications protocols and networks.

This package provides tested, ergonomic Python 3 CFFI bindings to implementations of a number of algorithms submitted as part of the Post-Quantum Cryptography Standardization effort by NIST.

Installation

You can install this package using pip or build it from source using poetry:

# Using pip
pip install pqcrypto

# Using poetry
pip install poetry
poetry build

Key Encapsulation

from secrets import compare_digest
# from pqcrypto.kem.firesaber import generate_keypair, encrypt, decrypt
# from pqcrypto.kem.frodokem1344aes import generate_keypair, encrypt, decrypt
# from pqcrypto.kem.frodokem1344shake import generate_keypair, encrypt, decrypt
# from pqcrypto.kem.frodokem640aes import generate_keypair, encrypt, decrypt
# from pqcrypto.kem.frodokem640shake import generate_keypair, encrypt, decrypt
# from pqcrypto.kem.frodokem976aes import generate_keypair, encrypt, decrypt
# from pqcrypto.kem.frodokem976shake import generate_keypair, encrypt, decrypt
# from pqcrypto.kem.kyber1024 import generate_keypair, encrypt, decrypt
# from pqcrypto.kem.kyber1024_90s import generate_keypair, encrypt, decrypt
# from pqcrypto.kem.kyber512 import generate_keypair, encrypt, decrypt
# from pqcrypto.kem.kyber512_90s import generate_keypair, encrypt, decrypt
# from pqcrypto.kem.kyber768 import generate_keypair, encrypt, decrypt
# from pqcrypto.kem.kyber768_90s import generate_keypair, encrypt, decrypt
# from pqcrypto.kem.lightsaber import generate_keypair, encrypt, decrypt
# from pqcrypto.kem.mceliece348864 import generate_keypair, encrypt, decrypt
# from pqcrypto.kem.mceliece348864f import generate_keypair, encrypt, decrypt
# from pqcrypto.kem.mceliece460896 import generate_keypair, encrypt, decrypt
# from pqcrypto.kem.mceliece460896f import generate_keypair, encrypt, decrypt
# from pqcrypto.kem.mceliece6688128 import generate_keypair, encrypt, decrypt
# from pqcrypto.kem.mceliece6688128f import generate_keypair, encrypt, decrypt
# from pqcrypto.kem.mceliece6960119 import generate_keypair, encrypt, decrypt
# from pqcrypto.kem.mceliece6960119f import generate_keypair, encrypt, decrypt
from pqcrypto.kem.mceliece8192128 import generate_keypair, encrypt, decrypt
# from pqcrypto.kem.mceliece8192128f import generate_keypair, encrypt, decrypt
# from pqcrypto.kem.ntruhps2048509 import generate_keypair, encrypt, decrypt
# from pqcrypto.kem.ntruhps2048677 import generate_keypair, encrypt, decrypt
# from pqcrypto.kem.ntruhps4096821 import generate_keypair, encrypt, decrypt
# from pqcrypto.kem.ntruhrss701 import generate_keypair, encrypt, decrypt
# from pqcrypto.kem.saber import generate_keypair, encrypt, decrypt

# Alice generates a (public, secret) key pair
public_key, secret_key = generate_keypair()

# Bob derives a secret (the plaintext) and encrypts it with Alice's public key to produce a ciphertext
ciphertext, plaintext_original = encrypt(public_key)

# Alice decrypts Bob's ciphertext to derive the now shared secret
plaintext_recovered = decrypt(secret_key, ciphertext)

# Compare the original and recovered secrets in constant time
assert compare_digest(plaintext_original, plaintext_recovered)

Signing

# from pqcrypto.sign.dilithium2 import generate_keypair, sign, verify
# from pqcrypto.sign.dilithium3 import generate_keypair, sign, verify
from pqcrypto.sign.dilithium4 import generate_keypair, sign, verify
# from pqcrypto.sign.falcon_1024 import generate_keypair, sign, verify
# from pqcrypto.sign.falcon_512 import generate_keypair, sign, verify
# from pqcrypto.sign.rainbowIa_classic import generate_keypair, sign, verify
# from pqcrypto.sign.rainbowIa_cyclic import generate_keypair, sign, verify
# from pqcrypto.sign.rainbowIa_cyclic_compressed import generate_keypair, sign, verify
# from pqcrypto.sign.rainbowIIIc_classic import generate_keypair, sign, verify
# from pqcrypto.sign.rainbowIIIc_cyclic import generate_keypair, sign, verify
# from pqcrypto.sign.rainbowIIIc_cyclic_compressed import generate_keypair, sign, verify
# from pqcrypto.sign.rainbowVc_classic import generate_keypair, sign, verify
# from pqcrypto.sign.rainbowVc_cyclic import generate_keypair, sign, verify
# from pqcrypto.sign.rainbowVc_cyclic_compressed import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_haraka_128f_robust import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_haraka_128f_simple import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_haraka_128s_robust import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_haraka_128s_simple import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_haraka_192f_robust import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_haraka_192f_simple import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_haraka_192s_robust import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_haraka_192s_simple import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_haraka_256f_robust import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_haraka_256f_simple import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_haraka_256s_robust import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_haraka_256s_simple import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_sha256_128f_robust import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_sha256_128f_simple import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_sha256_128s_robust import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_sha256_128s_simple import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_sha256_192f_robust import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_sha256_192f_simple import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_sha256_192s_robust import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_sha256_192s_simple import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_sha256_256f_robust import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_sha256_256f_simple import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_sha256_256s_robust import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_sha256_256s_simple import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_shake256_128f_robust import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_shake256_128f_simple import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_shake256_128s_robust import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_shake256_128s_simple import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_shake256_192f_robust import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_shake256_192f_simple import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_shake256_192s_robust import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_shake256_192s_simple import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_shake256_256f_robust import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_shake256_256f_simple import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_shake256_256s_robust import generate_keypair, sign, verify
# from pqcrypto.sign.sphincs_shake256_256s_simple import generate_keypair, sign, verify

# Alice generates a (public, secret) key pair
public_key, secret_key = generate_keypair()

# Alice signs her message using her secret key
signature = sign(secret_key, b"Hello world")

# Bob uses Alice's public key to validate her signature
assert verify(public_key, b"Hello world", signature)

Credits

The C implementations used herein are derived from the PQClean project.

License

BSD 3-Clause License

Copyright (c) 2020, Phil Demetriou
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
  list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its
  contributors may be used to endorse or promote products derived from
  this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

pqcrypto's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pqcrypto's Issues

rainbow bug

sources/rainbowIIIc-cyclic-compressed/ref/rainbow.c

  line 68:      uint8_t x_o2[_O1_BYTE];  -> uint8_t x_o2[_O2_BYTE]; 

Contact

Hello Phil Demetriou,

I'd really love to contct you in any way you want. I couldn't find any emails of you, so I wanted to ask you here of any possibilities for contacting you. Don't mind writing an email: [email protected]

Regards
ProtDos

Installation Error

root@ip-172-31-26-203:~/pqcrypto# pip3 install pqcrypto
ERROR: Could not find a version that satisfies the requirement pqcrypto (from versions: none)
ERROR: No matching distribution found for pqcrypto
WARNING: You are using pip version 20.1; however, version 21.3.1 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command.

How to install it using pip

PQCrypto library is out of date

@kpdemetriou
Hey, thank you for this library, but could you please update it to the latest PQClean release as of date?
Otherwise your library becomes just another abandoned library that consumes a good name on PyPI,
which can not be used by some other PQClean wrapper that wants to actively maintain itself.

Update:

If anybody wants to use an up-to-date and supported PQC library, then you can try out QuantCrypt.

Fails to install on macOS

macOS 10.15.6, Xcode-11.7, Python-3.8.5.

$ sudo -EH pip3 install pqcrypto
Collecting pqcrypto
  Using cached pqcrypto-0.1.2.tar.gz (1.4 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting cffi<2.0.0,>=1.14.2
  Using cached cffi-1.14.2-cp38-cp38-macosx_10_9_x86_64.whl (176 kB)
Requirement already satisfied: pycparser in /opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from cffi<2.0.0,>=1.14.2->pqcrypto) (2.19)
Building wheels for collected packages: pqcrypto
  Building wheel for pqcrypto (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: /opt/local/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8 /opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/tmpgymhwbqm
       cwd: /private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/pip-install-1hzsrnnj/pqcrypto
  Complete output (476 lines):
  Traceback (most recent call last):
    File "/private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/pip-build-env-h881v55v/overlay/lib/python3.8/site-packages/poetry/utils/env.py", line 912, in _run
      output = subprocess.check_output(
    File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 411, in check_output
      return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
    File "/private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/pip-build-env-h881v55v/overlay/lib/python3.8/site-packages/poetry/utils/_compat.py", line 205, in run
      raise CalledProcessError(
  poetry.utils._compat.CalledProcessError: Command '['python', 'setup.py', 'build', '-b', 'build']' returned non-zero exit status 1.
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
      main()
    File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 204, in build_wheel
      return _build_backend().build_wheel(wheel_directory, config_settings,
    File "/private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/pip-build-env-h881v55v/overlay/lib/python3.8/site-packages/poetry/masonry/api.py", line 62, in build_wheel
      WheelBuilder.make_in(
    File "/private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/pip-build-env-h881v55v/overlay/lib/python3.8/site-packages/poetry/masonry/builders/wheel.py", line 55, in make_in
      wb.build()
    File "/private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/pip-build-env-h881v55v/overlay/lib/python3.8/site-packages/poetry/masonry/builders/wheel.py", line 81, in build
      self._build(zip_file)
    File "/private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/pip-build-env-h881v55v/overlay/lib/python3.8/site-packages/poetry/masonry/builders/wheel.py", line 103, in _build
      self._env.run(
    File "/private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/pip-build-env-h881v55v/overlay/lib/python3.8/site-packages/poetry/utils/env.py", line 879, in run
      return self._run(cmd, **kwargs)
    File "/private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/pip-build-env-h881v55v/overlay/lib/python3.8/site-packages/poetry/utils/env.py", line 916, in _run
      raise EnvCommandError(e, input=input_)
  poetry.utils.env.EnvCommandError: Command ['python', 'setup.py', 'build', '-b', 'build'] errored with the following return code 1, and output:
  WARNING: The pip package is not available, falling back to EasyInstall for handling setup_requires/test_requires; this is deprecated and will be removed in a future version.
  WARNING: The pip package is not available, falling back to EasyInstall for handling setup_requires/test_requires; this is deprecated and will be removed in a future version.
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.15-x86_64-3.8
  creating build/lib.macosx-10.15-x86_64-3.8/pqcrypto
  copying pqcrypto/__init__.py -> build/lib.macosx-10.15-x86_64-3.8/pqcrypto
  copying pqcrypto/common.py -> build/lib.macosx-10.15-x86_64-3.8/pqcrypto
  package init file 'pqcrypto/kem/__init__.py' not found (or not a regular file)
  creating build/lib.macosx-10.15-x86_64-3.8/pqcrypto/kem
  copying pqcrypto/kem/mceliece460896.py -> build/lib.macosx-10.15-x86_64-3.8/pqcrypto/kem
  copying pqcrypto/kem/frodokem1344aes.py -> build/lib.macosx-10.15-x86_64-3.8/pqcrypto/kem
  copying pqcrypto/kem/lightsaber.py -> build/lib.macosx-10.15-x86_64-3.8/pqcrypto/kem
  copying pqcrypto/kem/mceliece6960119f.py -> build/lib.macosx-10.15-x86_64-3.8/pqcrypto/kem
  copying pqcrypto/kem/mceliece8192128f.py -> build/lib.macosx-10.15-x86_64-3.8/pqcrypto/kem
  copying pqcrypto/kem/frodokem976shake.py -> build/lib.macosx-10.15-x86_64-3.8/pqcrypto/kem
. . . . .
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -O3 -std=gnu17 -march=native -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -Isources/common -I/opt/local/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c /private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/pip-install-1hzsrnnj/pqcrypto/sources/mceliece348864/vec/aes256ctr.c -o build/temp.macosx-10.15-x86_64-3.8/private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/pip-install-1hzsrnnj/pqcrypto/sources/mceliece348864/vec/aes256ctr.o -O3 -std=c99
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -O3 -std=gnu17 -march=native -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -Isources/common -I/opt/local/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c /private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/pip-install-1hzsrnnj/pqcrypto/sources/mceliece348864/vec/encrypt.c -o build/temp.macosx-10.15-x86_64-3.8/private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/pip-install-1hzsrnnj/pqcrypto/sources/mceliece348864/vec/encrypt.o -O3 -std=c99
  In file included from /private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/pip-install-1hzsrnnj/pqcrypto/sources/mceliece348864/vec/encrypt.c:9:
  In file included from sources/common/randombytes.h:8:
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/unistd.h:546:7: error: conflicting types for 'encrypt'
  void     encrypt(char *, int) __DARWIN_ALIAS(encrypt);
           ^
  /private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/pip-install-1hzsrnnj/pqcrypto/sources/mceliece348864/vec/encrypt.h:8:6: note: previous declaration is here
  void encrypt(unsigned char * /*s*/, unsigned char * /*e*/, const unsigned char * /*pk*/);
       ^
  1 error generated.
  error: command 'clang' failed with exit status 1
  
  ----------------------------------------
  ERROR: Failed building wheel for pqcrypto
Failed to build pqcrypto
ERROR: Could not build wheels for pqcrypto which use PEP 517 and cannot be installed directly

Disregard - this is a mistake (Building from source - tomcrypt fails to compile)

MacOS 10.15.6, Xcode-11.7, Python-3.8.5

$ python setup.py build
. . . . .
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -g -fwrapv -O3 -Wall -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -O3 -std=gnu17 -march=native -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -DHAVE_CONFIG_H -Isrc/ -Isrc/libtom/ -I/opt/local/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c src/DES.c -o build/temp.macosx-10.15-x86_64-3.8/src/DES.o
In file included from src/DES.c:34:
In file included from src/libtom/tomcrypt_des.c:11:
In file included from src/libtom/tomcrypt.h:67:
src/libtom/tomcrypt_macros.h:269:25: error: constraint 'I' expects an integer constant expression
      :"0" (word), "I" (i));
                        ^
src/libtom/tomcrypt_macros.h:277:25: error: constraint 'I' expects an integer constant expression
      :"0" (word), "I" (i));
                        ^
src/libtom/tomcrypt_macros.h:368:24: error: constraint 'J' expects an integer constant expression
      :"0" (word),"J" (i));
                       ^
src/libtom/tomcrypt_macros.h:376:24: error: constraint 'J' expects an integer constant expression
      :"0" (word),"J" (i));
                       ^
In file included from src/DES.c:132:
src/block_template.c:791:79: warning: result of comparison of constant 0 with boolean expression is always false [-Wtautological-constant-compare]
        if (PCT_CounterBEType == NULL || PyType_Check((PyObject *)PCT_CounterBEType) < 0 ||
                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~
src/block_template.c:792:77: warning: result of comparison of constant 0 with boolean expression is always false [-Wtautological-constant-compare]
                 PCT_CounterLEType == NULL || PyType_Check((PyObject *)PCT_CounterLEType) < 0 ||
                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~
src/block_template.c:793:47: warning: result of comparison of constant 0 with boolean expression is always false [-Wtautological-constant-compare]
                 abiver == NULL || PyInt_CheckExact(abiver) < 0 || PyInt_AS_LONG(abiver) != PCT_CTR_ABI_VERSION)
                                   ~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~
In file included from src/DES.c:34:
In file included from src/libtom/tomcrypt_des.c:11:
In file included from src/libtom/tomcrypt.h:68:
src/libtom/tomcrypt_cipher.h:546:3: warning: tentative array definition assumed to have one element
} cipher_descriptor[];
  ^
4 warnings and 4 errors generated.
error: command 'clang' failed with exit status 1

Update

if you get past the above problem, the following occurs:

clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -g -fwrapv -O3 -Wall -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -O3 -std=gnu17 -march=native -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -DHAVE_CONFIG_H -Isrc/ -Isrc/libtom/ -I/opt/local/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c src/DES.c -o build/temp.macosx-10.15-x86_64-3.8/src/DES.o
In file included from src/DES.c:132:
src/block_template.c:791:79: warning: result of comparison of constant 0 with boolean expression is always false [-Wtautological-constant-compare]
        if (PCT_CounterBEType == NULL || PyType_Check((PyObject *)PCT_CounterBEType) < 0 ||
                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~
src/block_template.c:792:77: warning: result of comparison of constant 0 with boolean expression is always false [-Wtautological-constant-compare]
                 PCT_CounterLEType == NULL || PyType_Check((PyObject *)PCT_CounterLEType) < 0 ||
                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~
src/block_template.c:793:47: warning: result of comparison of constant 0 with boolean expression is always false [-Wtautological-constant-compare]
                 abiver == NULL || PyInt_CheckExact(abiver) < 0 || PyInt_AS_LONG(abiver) != PCT_CTR_ABI_VERSION)
                                   ~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~
In file included from src/DES.c:34:
In file included from src/libtom/tomcrypt_des.c:11:
In file included from src/libtom/tomcrypt.h:68:
src/libtom/tomcrypt_cipher.h:546:3: warning: tentative array definition assumed to have one element
} cipher_descriptor[];
  ^
In file included from src/DES.c:34:
In file included from src/libtom/tomcrypt_des.c:11:
In file included from src/libtom/tomcrypt.h:67:
src/libtom/tomcrypt_macros.h:275:9: error: invalid operand for instruction
   asm ("rorl %2,%0"
        ^
<inline asm>:1:12: note: instantiated into assembly here
        rorl %edx,%r8d
                  ^~~~
In file included from src/DES.c:34:
In file included from src/libtom/tomcrypt_des.c:11:
In file included from src/libtom/tomcrypt.h:67:
src/libtom/tomcrypt_macros.h:275:9: error: invalid operand for instruction
   asm ("rorl %2,%0"
        ^
<inline asm>:1:12: note: instantiated into assembly here
        rorl %edi,%ebx
                  ^~~~
4 warnings and 2 errors generated.
error: command 'clang' failed with exit status 1

Use of field plaintext_original

I would like to clarify a conceptual doubt regarding use of the "encrypt" function described in the sample section of "Key Encapsulation". The execution confirms successful execution of the "assert" command, confirming encrypt and decrypt operations. When validating the field named plaintext_original with a Python print command, I get a binary field which does not match any standard decode methods like: UTF-8, or ISO-8859-1. After calling the encrypt function, the plaintext_original gets unreadable, likely the field gets modified by the C language processing. Is there a way to set a value for plaintext_original and keep it unmodified and validate it at the end of the encode/decode process?

Module doesn't exist

I Pip installed the package, imported like what's showing for the examples, tried to run and I get the following error.

Traceback (most recent call last):
  File "/home/ori/Desktop/playground/latty/latty.py", line 1, in <module>
    from pqcrypto.kem.kyber1024_90s import generate_keypair, encrypt, decrypt
  File "/home/ori/Desktop/playground/latty/pqlENV/lib/python3.10/site-packages/pqcrypto/kem/kyber1024_90s.py", line 1, in <module>
    from .._kem.kyber1024_90s import ffi as __ffi, lib as __lib
ModuleNotFoundError: No module named 'pqcrypto._kem.kyber1024_90s'

Anything in the _kem directory is not there. It's empty. (Except for the very empty .gitkeep file)

pip fails to build wheels

`python -m pip install pqcrypto
Collecting pqcrypto
Downloading pqcrypto-0.1.3.tar.gz (1.4 MB)
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 1.4/1.4 MB 30.2 MB/s eta 0:00:00
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: cffi<2.0.0,>=1.14.2 in c:\users\xxxx\appdata\local\pypoetry\cache\virtualenvs\name-jqwtno7e-py3.10\lib\site-packages (from pqcrypto) (1.15.1)
Requirement already satisfied: pycparser in c:\users\xxxx\appdata\local\pypoetry\cache\virtualenvs\name-jqwtno7e-py3.10\lib\site-packages (from cffi<2.0.0,>=1.14.2->pqcrypto) (2.21)
Building wheels for collected packages: pqcrypto
Building wheel for pqcrypto (pyproject.toml) ... error
error: subprocess-exited-with-error

ร— Building wheel for pqcrypto (pyproject.toml) did not run successfully.
โ”‚ exit code: 1
โ•ฐโ”€> [25 lines of output]
A setup.py file already exists. Using it.
Traceback (most recent call last):
File "C:\Users\xxxx\AppData\Local\Temp\pip-install-zll00t4x\pqcrypto_ef98106e2dcc4d0da07fbdab776d7b06\setup.py", line 2, in
from setuptools import setup
ModuleNotFoundError: No module named 'setuptools'
Traceback (most recent call last):
File "C:\Users\xxxx\AppData\Local\pypoetry\Cache\virtualenvs\name-jQWtNO7e-py3.10\lib\site-packages\pip_vendor\pep517\in_process_in_process.py", line 363, in
main()
File "C:\Users\xxxx\AppData\Local\pypoetry\Cache\virtualenvs\name-jQWtNO7e-py3.10\lib\site-packages\pip_vendor\pep517\in_process_in_process.py", line 345, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "C:\Users\xxxx\AppData\Local\pypoetry\Cache\virtualenvs\name-jQWtNO7e-py3.10\lib\site-packages\pip_vendor\pep517\in_process_in_process.py", line 261, in build_wheel
return _build_backend().build_wheel(wheel_directory, config_settings,
File "C:\Users\xxxx\AppData\Local\Temp\pip-build-env-3ysnkxmg\overlay\Lib\site-packages\poetry\core\masonry\api.py", line 68, in build_wheel
return unicode(WheelBuilder.make_in(poetry, Path(wheel_directory)))
File "C:\Users\xxxx\AppData\Local\Temp\pip-build-env-3ysnkxmg\overlay\Lib\site-packages\poetry\core\masonry\builders\wheel.py", line 78, in make_in
wb.build()
File "C:\Users\xxxx\AppData\Local\Temp\pip-build-env-3ysnkxmg\overlay\Lib\site-packages\poetry\core\masonry\builders\wheel.py", line 110, in build
self._build(zip_file)
File "C:\Users\xxxx\AppData\Local\Temp\pip-build-env-3ysnkxmg\overlay\Lib\site-packages\poetry\core\masonry\builders\wheel.py", line 162, in _build
self._run_build_command(setup)
File "C:\Users\xxxx\AppData\Local\Temp\pip-build-env-3ysnkxmg\overlay\Lib\site-packages\poetry\core\masonry\builders\wheel.py", line 190, in _run_build_command
subprocess.check_call(
File "C:\Python\Python310\lib\subprocess.py", line 369, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['C:/Users/xxxx/AppData/Local/pypoetry/Cache/virtualenvs/name-jQWtNO7e-py3.10/Scripts/python.exe', 'C:\Users\xxxx\AppData\Local\Temp\pip-install-zll00t4x\pqcrypto_ef98106e2dcc4d0da07fbdab776d7b06\setup.py', 'build', '-b', 'C:\Users\xxxx\AppData\Local\Temp\pip-install-zll00t4x\pqcrypto_ef98106e2dcc4d0da07fbdab776d7b06\build']' returned non-zero exit status 1.
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pqcrypto
Failed to build pqcrypto
ERROR: Could not build wheels for pqcrypto, which is required to install pyproject.toml-based projects`

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.