瀏覽代碼

Update Rainbow to round 3 parameter sets (#361)

* rainbow update

* update workflows

* re-add /O2 in nmake Makefile
tags/v0.0.1
Matthias J. Kannwischer 3 年之前
committed by Kris Kwiatkowski
父節點
當前提交
7aef8a6f80
共有 100 個檔案被更改,包括 3077 行新增1472 行删除
  1. +78
    -81
      .github/workflows/BADGES.md
  2. +204
    -0
      .github/workflows/sign_rainbowI-circumzenithal.yml
  3. +11
    -11
      .github/workflows/sign_rainbowI-classic.yml
  4. +11
    -11
      .github/workflows/sign_rainbowI-compressed.yml
  5. +204
    -0
      .github/workflows/sign_rainbowIII-circumzenithal.yml
  6. +11
    -11
      .github/workflows/sign_rainbowIII-classic.yml
  7. +204
    -0
      .github/workflows/sign_rainbowIII-compressed.yml
  8. +0
    -204
      .github/workflows/sign_rainbowIIIc-cyclic-compressed.yml
  9. +0
    -204
      .github/workflows/sign_rainbowIa-cyclic-compressed.yml
  10. +204
    -0
      .github/workflows/sign_rainbowV-circumzenithal.yml
  11. +11
    -11
      .github/workflows/sign_rainbowV-classic.yml
  12. +11
    -11
      .github/workflows/sign_rainbowV-compressed.yml
  13. +0
    -204
      .github/workflows/sign_rainbowVc-classic.yml
  14. +0
    -204
      .github/workflows/sign_rainbowVc-cyclic-compressed.yml
  15. +20
    -0
      crypto_sign/rainbowI-circumzenithal/META.yml
  16. +0
    -0
      crypto_sign/rainbowI-circumzenithal/clean/LICENSE
  17. +21
    -0
      crypto_sign/rainbowI-circumzenithal/clean/Makefile
  18. +19
    -0
      crypto_sign/rainbowI-circumzenithal/clean/Makefile.Microsoft_nmake
  19. +32
    -0
      crypto_sign/rainbowI-circumzenithal/clean/api.h
  20. +43
    -0
      crypto_sign/rainbowI-circumzenithal/clean/blas.c
  21. +20
    -0
      crypto_sign/rainbowI-circumzenithal/clean/blas.h
  22. +27
    -27
      crypto_sign/rainbowI-circumzenithal/clean/blas_comm.c
  23. +7
    -7
      crypto_sign/rainbowI-circumzenithal/clean/blas_comm.h
  24. +5
    -5
      crypto_sign/rainbowI-circumzenithal/clean/gf.c
  25. +18
    -0
      crypto_sign/rainbowI-circumzenithal/clean/gf.h
  26. +182
    -0
      crypto_sign/rainbowI-circumzenithal/clean/parallel_matrix_op.c
  27. +260
    -0
      crypto_sign/rainbowI-circumzenithal/clean/parallel_matrix_op.h
  28. +26
    -21
      crypto_sign/rainbowI-circumzenithal/clean/rainbow.c
  29. +3
    -3
      crypto_sign/rainbowI-circumzenithal/clean/rainbow.h
  30. +32
    -0
      crypto_sign/rainbowI-circumzenithal/clean/rainbow_blas.h
  31. +1
    -1
      crypto_sign/rainbowI-circumzenithal/clean/rainbow_config.h
  32. +70
    -41
      crypto_sign/rainbowI-circumzenithal/clean/rainbow_keypair.c
  33. +2
    -2
      crypto_sign/rainbowI-circumzenithal/clean/rainbow_keypair.h
  34. +13
    -13
      crypto_sign/rainbowI-circumzenithal/clean/rainbow_keypair_computation.c
  35. +4
    -4
      crypto_sign/rainbowI-circumzenithal/clean/rainbow_keypair_computation.h
  36. +76
    -0
      crypto_sign/rainbowI-circumzenithal/clean/sign.c
  37. +5
    -5
      crypto_sign/rainbowI-circumzenithal/clean/utils_hash.c
  38. +11
    -0
      crypto_sign/rainbowI-circumzenithal/clean/utils_hash.h
  39. +97
    -0
      crypto_sign/rainbowI-circumzenithal/clean/utils_prng.c
  40. +18
    -0
      crypto_sign/rainbowI-circumzenithal/clean/utils_prng.h
  41. +20
    -0
      crypto_sign/rainbowI-classic/META.yml
  42. +0
    -0
      crypto_sign/rainbowI-classic/clean/LICENSE
  43. +1
    -1
      crypto_sign/rainbowI-classic/clean/Makefile
  44. +1
    -1
      crypto_sign/rainbowI-classic/clean/Makefile.Microsoft_nmake
  45. +32
    -0
      crypto_sign/rainbowI-classic/clean/api.h
  46. +10
    -10
      crypto_sign/rainbowI-classic/clean/blas.c
  47. +5
    -5
      crypto_sign/rainbowI-classic/clean/blas.h
  48. +27
    -27
      crypto_sign/rainbowI-classic/clean/blas_comm.c
  49. +7
    -7
      crypto_sign/rainbowI-classic/clean/blas_comm.h
  50. +5
    -5
      crypto_sign/rainbowI-classic/clean/gf.c
  51. +3
    -3
      crypto_sign/rainbowI-classic/clean/gf.h
  52. +32
    -32
      crypto_sign/rainbowI-classic/clean/parallel_matrix_op.c
  53. +18
    -18
      crypto_sign/rainbowI-classic/clean/parallel_matrix_op.h
  54. +21
    -26
      crypto_sign/rainbowI-classic/clean/rainbow.c
  55. +2
    -2
      crypto_sign/rainbowI-classic/clean/rainbow.h
  56. +32
    -0
      crypto_sign/rainbowI-classic/clean/rainbow_blas.h
  57. +1
    -1
      crypto_sign/rainbowI-classic/clean/rainbow_config.h
  58. +155
    -0
      crypto_sign/rainbowI-classic/clean/rainbow_keypair.c
  59. +1
    -1
      crypto_sign/rainbowI-classic/clean/rainbow_keypair.h
  60. +13
    -13
      crypto_sign/rainbowI-classic/clean/rainbow_keypair_computation.c
  61. +2
    -2
      crypto_sign/rainbowI-classic/clean/rainbow_keypair_computation.h
  62. +14
    -16
      crypto_sign/rainbowI-classic/clean/sign.c
  63. +5
    -5
      crypto_sign/rainbowI-classic/clean/utils_hash.c
  64. +1
    -1
      crypto_sign/rainbowI-classic/clean/utils_hash.h
  65. +3
    -3
      crypto_sign/rainbowI-classic/clean/utils_prng.c
  66. +2
    -2
      crypto_sign/rainbowI-classic/clean/utils_prng.h
  67. +20
    -0
      crypto_sign/rainbowI-compressed/META.yml
  68. +0
    -0
      crypto_sign/rainbowI-compressed/clean/LICENSE
  69. +1
    -1
      crypto_sign/rainbowI-compressed/clean/Makefile
  70. +1
    -1
      crypto_sign/rainbowI-compressed/clean/Makefile.Microsoft_nmake
  71. +32
    -0
      crypto_sign/rainbowI-compressed/clean/api.h
  72. +43
    -0
      crypto_sign/rainbowI-compressed/clean/blas.c
  73. +20
    -0
      crypto_sign/rainbowI-compressed/clean/blas.h
  74. +27
    -27
      crypto_sign/rainbowI-compressed/clean/blas_comm.c
  75. +7
    -7
      crypto_sign/rainbowI-compressed/clean/blas_comm.h
  76. +5
    -5
      crypto_sign/rainbowI-compressed/clean/gf.c
  77. +18
    -0
      crypto_sign/rainbowI-compressed/clean/gf.h
  78. +32
    -32
      crypto_sign/rainbowI-compressed/clean/parallel_matrix_op.c
  79. +18
    -18
      crypto_sign/rainbowI-compressed/clean/parallel_matrix_op.h
  80. +32
    -21
      crypto_sign/rainbowI-compressed/clean/rainbow.c
  81. +4
    -4
      crypto_sign/rainbowI-compressed/clean/rainbow.h
  82. +32
    -0
      crypto_sign/rainbowI-compressed/clean/rainbow_blas.h
  83. +1
    -1
      crypto_sign/rainbowI-compressed/clean/rainbow_config.h
  84. +76
    -47
      crypto_sign/rainbowI-compressed/clean/rainbow_keypair.c
  85. +4
    -4
      crypto_sign/rainbowI-compressed/clean/rainbow_keypair.h
  86. +13
    -13
      crypto_sign/rainbowI-compressed/clean/rainbow_keypair_computation.c
  87. +4
    -4
      crypto_sign/rainbowI-compressed/clean/rainbow_keypair_computation.h
  88. +16
    -14
      crypto_sign/rainbowI-compressed/clean/sign.c
  89. +5
    -5
      crypto_sign/rainbowI-compressed/clean/utils_hash.c
  90. +1
    -1
      crypto_sign/rainbowI-compressed/clean/utils_hash.h
  91. +3
    -3
      crypto_sign/rainbowI-compressed/clean/utils_prng.c
  92. +2
    -2
      crypto_sign/rainbowI-compressed/clean/utils_prng.h
  93. +20
    -0
      crypto_sign/rainbowIII-circumzenithal/META.yml
  94. +0
    -0
      crypto_sign/rainbowIII-circumzenithal/clean/LICENSE
  95. +21
    -0
      crypto_sign/rainbowIII-circumzenithal/clean/Makefile
  96. +19
    -0
      crypto_sign/rainbowIII-circumzenithal/clean/Makefile.Microsoft_nmake
  97. +32
    -0
      crypto_sign/rainbowIII-circumzenithal/clean/api.h
  98. +31
    -0
      crypto_sign/rainbowIII-circumzenithal/clean/blas.c
  99. +19
    -0
      crypto_sign/rainbowIII-circumzenithal/clean/blas.h
  100. +144
    -0
      crypto_sign/rainbowIII-circumzenithal/clean/blas_comm.c

+ 78
- 81
.github/workflows/BADGES.md 查看文件

@@ -1,91 +1,88 @@
![Test firesaber](https://github.com/PQClean/PQClean/workflows/Test%20firesaber/badge.svg?branch=master)
![Test frodokem1344aes](https://github.com/PQClean/PQClean/workflows/Test%20frodokem1344aes/badge.svg?branch=master)
![Test frodokem1344shake](https://github.com/PQClean/PQClean/workflows/Test%20frodokem1344shake/badge.svg?branch=master)
![Test frodokem640aes](https://github.com/PQClean/PQClean/workflows/Test%20frodokem640aes/badge.svg?branch=master)
![Test frodokem640shake](https://github.com/PQClean/PQClean/workflows/Test%20frodokem640shake/badge.svg?branch=master)
![Test frodokem976aes](https://github.com/PQClean/PQClean/workflows/Test%20frodokem976aes/badge.svg?branch=master)
![Test frodokem976shake](https://github.com/PQClean/PQClean/workflows/Test%20frodokem976shake/badge.svg?branch=master)
![Test kyber1024-90s](https://github.com/PQClean/PQClean/workflows/Test%20kyber1024-90s/badge.svg?branch=master)
![Test kyber1024](https://github.com/PQClean/PQClean/workflows/Test%20kyber1024/badge.svg?branch=master)
![Test kyber512-90s](https://github.com/PQClean/PQClean/workflows/Test%20kyber512-90s/badge.svg?branch=master)
![Test kyber512](https://github.com/PQClean/PQClean/workflows/Test%20kyber512/badge.svg?branch=master)
![Test kyber768-90s](https://github.com/PQClean/PQClean/workflows/Test%20kyber768-90s/badge.svg?branch=master)
![Test kyber768](https://github.com/PQClean/PQClean/workflows/Test%20kyber768/badge.svg?branch=master)
![Test lightsaber](https://github.com/PQClean/PQClean/workflows/Test%20lightsaber/badge.svg?branch=master)
![Test mceliece348864](https://github.com/PQClean/PQClean/workflows/Test%20mceliece348864/badge.svg?branch=master)
![Test mceliece348864f](https://github.com/PQClean/PQClean/workflows/Test%20mceliece348864f/badge.svg?branch=master)
![Test mceliece460896](https://github.com/PQClean/PQClean/workflows/Test%20mceliece460896/badge.svg?branch=master)
![Test mceliece460896f](https://github.com/PQClean/PQClean/workflows/Test%20mceliece460896f/badge.svg?branch=master)
![Test mceliece6688128](https://github.com/PQClean/PQClean/workflows/Test%20mceliece6688128/badge.svg?branch=master)
![Test mceliece6688128f](https://github.com/PQClean/PQClean/workflows/Test%20mceliece6688128f/badge.svg?branch=master)
![Test mceliece6960119](https://github.com/PQClean/PQClean/workflows/Test%20mceliece6960119/badge.svg?branch=master)
![Test mceliece6960119f](https://github.com/PQClean/PQClean/workflows/Test%20mceliece6960119f/badge.svg?branch=master)
![Test mceliece8192128](https://github.com/PQClean/PQClean/workflows/Test%20mceliece8192128/badge.svg?branch=master)
![Test mceliece8192128f](https://github.com/PQClean/PQClean/workflows/Test%20mceliece8192128f/badge.svg?branch=master)
![Test ntruhps2048509](https://github.com/PQClean/PQClean/workflows/Test%20ntruhps2048509/badge.svg?branch=master)
![Test ntruhps2048677](https://github.com/PQClean/PQClean/workflows/Test%20ntruhps2048677/badge.svg?branch=master)
![Test ntruhps4096821](https://github.com/PQClean/PQClean/workflows/Test%20ntruhps4096821/badge.svg?branch=master)
![Test ntruhrss701](https://github.com/PQClean/PQClean/workflows/Test%20ntruhrss701/badge.svg?branch=master)
![Test saber](https://github.com/PQClean/PQClean/workflows/Test%20saber/badge.svg?branch=master)
![Test hqc-128](https://github.com/PQClean/PQClean/workflows/Test%20hqc-128/badge.svg?branch=master)
![Test hqc-192](https://github.com/PQClean/PQClean/workflows/Test%20hqc-192/badge.svg?branch=master)
![Test hqc-256](https://github.com/PQClean/PQClean/workflows/Test%20hqc-256/badge.svg?branch=master)
![Test hqc-rmrs-128](https://github.com/PQClean/PQClean/workflows/Test%20hqc-rmrs-128/badge.svg?branch=master)
![Test hqc-rmrs-192](https://github.com/PQClean/PQClean/workflows/Test%20hqc-rmrs-192/badge.svg?branch=master)
![Test hqc-rmrs-256](https://github.com/PQClean/PQClean/workflows/Test%20hqc-rmrs-256/badge.svg?branch=master)
![Test ntrulpr653](https://github.com/PQClean/PQClean/workflows/Test%20ntrulpr653/badge.svg?branch=master)
![Test ntrulpr761](https://github.com/PQClean/PQClean/workflows/Test%20ntrulpr761/badge.svg?branch=master)
![Test ntrulpr857](https://github.com/PQClean/PQClean/workflows/Test%20ntrulpr857/badge.svg?branch=master)
![Test sntrup653](https://github.com/PQClean/PQClean/workflows/Test%20sntrup653/badge.svg?branch=master)
![Test sntrup761](https://github.com/PQClean/PQClean/workflows/Test%20sntrup761/badge.svg?branch=master)
![Test sntrup857](https://github.com/PQClean/PQClean/workflows/Test%20sntrup857/badge.svg?branch=master)
![Test dilithium2](https://github.com/PQClean/PQClean/workflows/Test%20dilithium2/badge.svg?branch=master)
![Test dilithium3](https://github.com/PQClean/PQClean/workflows/Test%20dilithium3/badge.svg?branch=master)
![Test dilithium4](https://github.com/PQClean/PQClean/workflows/Test%20dilithium4/badge.svg?branch=master)
![Test falcon-1024](https://github.com/PQClean/PQClean/workflows/Test%20falcon-1024/badge.svg?branch=master)
![Test falcon-512](https://github.com/PQClean/PQClean/workflows/Test%20falcon-512/badge.svg?branch=master)
![Test rainbowIIIc-classic](https://github.com/PQClean/PQClean/workflows/Test%20rainbowIIIc-classic/badge.svg?branch=master)
![Test rainbowIIIc-cyclic-compressed](https://github.com/PQClean/PQClean/workflows/Test%20rainbowIIIc-cyclic-compressed/badge.svg?branch=master)
![Test rainbowIIIc-cyclic](https://github.com/PQClean/PQClean/workflows/Test%20rainbowIIIc-cyclic/badge.svg?branch=master)
![Test rainbowIa-classic](https://github.com/PQClean/PQClean/workflows/Test%20rainbowIa-classic/badge.svg?branch=master)
![Test rainbowIa-cyclic-compressed](https://github.com/PQClean/PQClean/workflows/Test%20rainbowIa-cyclic-compressed/badge.svg?branch=master)
![Test rainbowIa-cyclic](https://github.com/PQClean/PQClean/workflows/Test%20rainbowIa-cyclic/badge.svg?branch=master)
![Test rainbowVc-classic](https://github.com/PQClean/PQClean/workflows/Test%20rainbowVc-classic/badge.svg?branch=master)
![Test rainbowVc-cyclic-compressed](https://github.com/PQClean/PQClean/workflows/Test%20rainbowVc-cyclic-compressed/badge.svg?branch=master)
![Test rainbowVc-cyclic](https://github.com/PQClean/PQClean/workflows/Test%20rainbowVc-cyclic/badge.svg?branch=master)
![Test sphincs-haraka-128f-robust](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-haraka-128f-robust/badge.svg?branch=master)
![Test sphincs-haraka-128f-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-haraka-128f-simple/badge.svg?branch=master)
![Test sphincs-haraka-128s-robust](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-haraka-128s-robust/badge.svg?branch=master)
![Test sphincs-haraka-128s-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-haraka-128s-simple/badge.svg?branch=master)
![Test sphincs-haraka-192f-robust](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-haraka-192f-robust/badge.svg?branch=master)
![Test sphincs-haraka-192f-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-haraka-192f-simple/badge.svg?branch=master)
![Test sphincs-haraka-192s-robust](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-haraka-192s-robust/badge.svg?branch=master)
![Test sphincs-haraka-192s-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-haraka-192s-simple/badge.svg?branch=master)
![Test sphincs-haraka-256f-robust](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-haraka-256f-robust/badge.svg?branch=master)
![Test sphincs-haraka-256f-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-haraka-256f-simple/badge.svg?branch=master)
![Test sphincs-haraka-256s-robust](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-haraka-256s-robust/badge.svg?branch=master)
![Test sphincs-haraka-256s-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-haraka-256s-simple/badge.svg?branch=master)
![Test sphincs-sha256-128f-robust](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-sha256-128f-robust/badge.svg?branch=master)
![Test sphincs-sha256-128f-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-sha256-128f-simple/badge.svg?branch=master)
![Test sphincs-sha256-128s-robust](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-sha256-128s-robust/badge.svg?branch=master)
![Test sphincs-sha256-128s-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-sha256-128s-simple/badge.svg?branch=master)
![Test sphincs-haraka-192s-robust](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-haraka-192s-robust/badge.svg?branch=master)
![Test sphincs-sha256-192s-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-sha256-192s-simple/badge.svg?branch=master)
![Test dilithium2](https://github.com/PQClean/PQClean/workflows/Test%20dilithium2/badge.svg?branch=master)
![Test sphincs-shake256-192f-robust](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-shake256-192f-robust/badge.svg?branch=master)
![Test rainbowIII-compressed](https://github.com/PQClean/PQClean/workflows/Test%20rainbowIII-compressed/badge.svg?branch=master)
![Test sphincs-haraka-128s-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-haraka-128s-simple/badge.svg?branch=master)
![Test sphincs-sha256-192f-robust](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-sha256-192f-robust/badge.svg?branch=master)
![Test sphincs-sha256-192f-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-sha256-192f-simple/badge.svg?branch=master)
![Test sphincs-haraka-128f-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-haraka-128f-simple/badge.svg?branch=master)
![Test rainbowV-circumzenithal](https://github.com/PQClean/PQClean/workflows/Test%20rainbowV-circumzenithal/badge.svg?branch=master)
![Test sphincs-shake256-192f-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-shake256-192f-simple/badge.svg?branch=master)
![Test sphincs-shake256-256s-robust](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-shake256-256s-robust/badge.svg?branch=master)
![Test rainbowIII-circumzenithal](https://github.com/PQClean/PQClean/workflows/Test%20rainbowIII-circumzenithal/badge.svg?branch=master)
![Test sphincs-sha256-192s-robust](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-sha256-192s-robust/badge.svg?branch=master)
![Test sphincs-sha256-192s-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-sha256-192s-simple/badge.svg?branch=master)
![Test sphincs-sha256-256f-robust](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-sha256-256f-robust/badge.svg?branch=master)
![Test sphincs-sha256-256f-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-sha256-256f-simple/badge.svg?branch=master)
![Test sphincs-sha256-256s-robust](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-sha256-256s-robust/badge.svg?branch=master)
![Test sphincs-haraka-192f-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-haraka-192f-simple/badge.svg?branch=master)
![Test sphincs-shake256-128f-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-shake256-128f-simple/badge.svg?branch=master)
![Test sphincs-sha256-128f-robust](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-sha256-128f-robust/badge.svg?branch=master)
![Test sphincs-shake256-192s-robust](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-shake256-192s-robust/badge.svg?branch=master)
![Test sphincs-haraka-192s-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-haraka-192s-simple/badge.svg?branch=master)
![Test sphincs-sha256-192f-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-sha256-192f-simple/badge.svg?branch=master)
![Test rainbowI-circumzenithal](https://github.com/PQClean/PQClean/workflows/Test%20rainbowI-circumzenithal/badge.svg?branch=master)
![Test sphincs-sha256-128s-robust](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-sha256-128s-robust/badge.svg?branch=master)
![Test rainbowV-compressed](https://github.com/PQClean/PQClean/workflows/Test%20rainbowV-compressed/badge.svg?branch=master)
![Test rainbowV-classic](https://github.com/PQClean/PQClean/workflows/Test%20rainbowV-classic/badge.svg?branch=master)
![Test sphincs-sha256-256s-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-sha256-256s-simple/badge.svg?branch=master)
![Test falcon-512](https://github.com/PQClean/PQClean/workflows/Test%20falcon-512/badge.svg?branch=master)
![Test falcon-1024](https://github.com/PQClean/PQClean/workflows/Test%20falcon-1024/badge.svg?branch=master)
![Test sphincs-haraka-256s-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-haraka-256s-simple/badge.svg?branch=master)
![Test sphincs-shake256-128f-robust](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-shake256-128f-robust/badge.svg?branch=master)
![Test sphincs-shake256-128f-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-shake256-128f-simple/badge.svg?branch=master)
![Test dilithium4](https://github.com/PQClean/PQClean/workflows/Test%20dilithium4/badge.svg?branch=master)
![Test sphincs-sha256-256s-robust](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-sha256-256s-robust/badge.svg?branch=master)
![Test sphincs-haraka-256s-robust](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-haraka-256s-robust/badge.svg?branch=master)
![Test sphincs-shake256-256f-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-shake256-256f-simple/badge.svg?branch=master)
![Test rainbowI-classic](https://github.com/PQClean/PQClean/workflows/Test%20rainbowI-classic/badge.svg?branch=master)
![Test sphincs-haraka-256f-robust](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-haraka-256f-robust/badge.svg?branch=master)
![Test sphincs-sha256-256f-robust](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-sha256-256f-robust/badge.svg?branch=master)
![Test sphincs-shake256-128s-robust](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-shake256-128s-robust/badge.svg?branch=master)
![Test rainbowI-compressed](https://github.com/PQClean/PQClean/workflows/Test%20rainbowI-compressed/badge.svg?branch=master)
![Test rainbowIII-classic](https://github.com/PQClean/PQClean/workflows/Test%20rainbowIII-classic/badge.svg?branch=master)
![Test sphincs-haraka-192f-robust](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-haraka-192f-robust/badge.svg?branch=master)
![Test dilithium3](https://github.com/PQClean/PQClean/workflows/Test%20dilithium3/badge.svg?branch=master)
![Test sphincs-sha256-256f-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-sha256-256f-simple/badge.svg?branch=master)
![Test sphincs-shake256-256s-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-shake256-256s-simple/badge.svg?branch=master)
![Test sphincs-shake256-128s-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-shake256-128s-simple/badge.svg?branch=master)
![Test sphincs-shake256-192f-robust](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-shake256-192f-robust/badge.svg?branch=master)
![Test sphincs-shake256-192f-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-shake256-192f-simple/badge.svg?branch=master)
![Test sphincs-shake256-192s-robust](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-shake256-192s-robust/badge.svg?branch=master)
![Test sphincs-shake256-192s-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-shake256-192s-simple/badge.svg?branch=master)
![Test sphincs-haraka-128f-robust](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-haraka-128f-robust/badge.svg?branch=master)
![Test sphincs-shake256-256f-robust](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-shake256-256f-robust/badge.svg?branch=master)
![Test sphincs-shake256-256f-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-shake256-256f-simple/badge.svg?branch=master)
![Test sphincs-shake256-256s-robust](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-shake256-256s-robust/badge.svg?branch=master)
![Test sphincs-shake256-256s-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-shake256-256s-simple/badge.svg?branch=master)
![Test sphincs-shake256-192s-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-shake256-192s-simple/badge.svg?branch=master)
![Test sphincs-sha256-128s-simple](https://github.com/PQClean/PQClean/workflows/Test%20sphincs-sha256-128s-simple/badge.svg?branch=master)
![Test mceliece460896](https://github.com/PQClean/PQClean/workflows/Test%20mceliece460896/badge.svg?branch=master)
![Test saber](https://github.com/PQClean/PQClean/workflows/Test%20saber/badge.svg?branch=master)
![Test kyber1024-90s](https://github.com/PQClean/PQClean/workflows/Test%20kyber1024-90s/badge.svg?branch=master)
![Test kyber1024](https://github.com/PQClean/PQClean/workflows/Test%20kyber1024/badge.svg?branch=master)
![Test mceliece8192128](https://github.com/PQClean/PQClean/workflows/Test%20mceliece8192128/badge.svg?branch=master)
![Test mceliece6960119](https://github.com/PQClean/PQClean/workflows/Test%20mceliece6960119/badge.svg?branch=master)
![Test ntruhrss701](https://github.com/PQClean/PQClean/workflows/Test%20ntruhrss701/badge.svg?branch=master)
![Test ntrulpr857](https://github.com/PQClean/PQClean/workflows/Test%20ntrulpr857/badge.svg?branch=master)
![Test frodokem1344shake](https://github.com/PQClean/PQClean/workflows/Test%20frodokem1344shake/badge.svg?branch=master)
![Test mceliece6688128f](https://github.com/PQClean/PQClean/workflows/Test%20mceliece6688128f/badge.svg?branch=master)
![Test ntruhps2048677](https://github.com/PQClean/PQClean/workflows/Test%20ntruhps2048677/badge.svg?branch=master)
![Test frodokem640aes](https://github.com/PQClean/PQClean/workflows/Test%20frodokem640aes/badge.svg?branch=master)
![Test sntrup761](https://github.com/PQClean/PQClean/workflows/Test%20sntrup761/badge.svg?branch=master)
![Test hqc-rmrs-256](https://github.com/PQClean/PQClean/workflows/Test%20hqc-rmrs-256/badge.svg?branch=master)
![Test frodokem976shake](https://github.com/PQClean/PQClean/workflows/Test%20frodokem976shake/badge.svg?branch=master)
![Test mceliece348864](https://github.com/PQClean/PQClean/workflows/Test%20mceliece348864/badge.svg?branch=master)
![Test frodokem1344aes](https://github.com/PQClean/PQClean/workflows/Test%20frodokem1344aes/badge.svg?branch=master)
![Test hqc-rmrs-192](https://github.com/PQClean/PQClean/workflows/Test%20hqc-rmrs-192/badge.svg?branch=master)
![Test frodokem976aes](https://github.com/PQClean/PQClean/workflows/Test%20frodokem976aes/badge.svg?branch=master)
![Test mceliece8192128f](https://github.com/PQClean/PQClean/workflows/Test%20mceliece8192128f/badge.svg?branch=master)
![Test mceliece460896f](https://github.com/PQClean/PQClean/workflows/Test%20mceliece460896f/badge.svg?branch=master)
![Test kyber512-90s](https://github.com/PQClean/PQClean/workflows/Test%20kyber512-90s/badge.svg?branch=master)
![Test mceliece348864f](https://github.com/PQClean/PQClean/workflows/Test%20mceliece348864f/badge.svg?branch=master)
![Test mceliece6960119f](https://github.com/PQClean/PQClean/workflows/Test%20mceliece6960119f/badge.svg?branch=master)
![Test firesaber](https://github.com/PQClean/PQClean/workflows/Test%20firesaber/badge.svg?branch=master)
![Test sntrup857](https://github.com/PQClean/PQClean/workflows/Test%20sntrup857/badge.svg?branch=master)
![Test frodokem640shake](https://github.com/PQClean/PQClean/workflows/Test%20frodokem640shake/badge.svg?branch=master)
![Test ntrulpr653](https://github.com/PQClean/PQClean/workflows/Test%20ntrulpr653/badge.svg?branch=master)
![Test sntrup653](https://github.com/PQClean/PQClean/workflows/Test%20sntrup653/badge.svg?branch=master)
![Test lightsaber](https://github.com/PQClean/PQClean/workflows/Test%20lightsaber/badge.svg?branch=master)
![Test kyber768-90s](https://github.com/PQClean/PQClean/workflows/Test%20kyber768-90s/badge.svg?branch=master)
![Test kyber768](https://github.com/PQClean/PQClean/workflows/Test%20kyber768/badge.svg?branch=master)
![Test ntruhps2048509](https://github.com/PQClean/PQClean/workflows/Test%20ntruhps2048509/badge.svg?branch=master)
![Test ntruhps4096821](https://github.com/PQClean/PQClean/workflows/Test%20ntruhps4096821/badge.svg?branch=master)
![Test ntrulpr761](https://github.com/PQClean/PQClean/workflows/Test%20ntrulpr761/badge.svg?branch=master)
![Test kyber512](https://github.com/PQClean/PQClean/workflows/Test%20kyber512/badge.svg?branch=master)
![Test hqc-rmrs-128](https://github.com/PQClean/PQClean/workflows/Test%20hqc-rmrs-128/badge.svg?branch=master)
![Test mceliece6688128](https://github.com/PQClean/PQClean/workflows/Test%20mceliece6688128/badge.svg?branch=master)

+ 204
- 0
.github/workflows/sign_rainbowI-circumzenithal.yml 查看文件

@@ -0,0 +1,204 @@
on:
push:
paths:
# build if tests change
- 'test/**'
# do not build if other schemes duplicate_consistency files change
- '!test/duplicate_consistency/*.yml'
- 'test/duplicate_consistency/rainbowI-circumzenithal*.yml'
# build if common files change
- 'common/**'
# build if scheme changed
- 'crypto_sign/rainbowI-circumzenithal/**'
# build if workflow file changed
- '.github/workflows/sign_rainbowI-circumzenithal.yml'
# Build if any files in the root change, except .md files
- '*'
- '!*.md'
pull_request:
paths:
# build if tests change
- 'test/**'
# do not build if other schemes duplicate_consistency files change
- '!test/duplicate_consistency/*.yml'
- 'test/duplicate_consistency/rainbowI-circumzenithal*.yml'
# build if common files change
- 'common/**'
# build if scheme changed
- 'crypto_sign/rainbowI-circumzenithal/**'
# build if workflow file changed
- '.github/workflows/sign_rainbowI-circumzenithal.yml'
# Build if any files in the root change, except .md files
- '*'
- '!*.md'
schedule:
- cron: '5 4 * * *'

name: Test rainbowI-circumzenithal

jobs:
test-native:
runs-on: ubuntu-latest
container:
image: pqclean/ci-container:${{ matrix.arch }}
env:
PQCLEAN_ONLY_SCHEMES: rainbowI-circumzenithal
CC: ccache ${{ matrix.cc }}
CCACHE_NOSTATS: 1
CCACHE_DIR: /ccache
CCACHE_SLOPPINESS: include_file_mtime
strategy:
matrix:
arch:
- amd64
- i386
cc:
- gcc
- clang
steps:
- name: Cancel Previous Runs
uses: thomwiggers/cancel-workflow-action@all_but_latest
with:
all_but_latest: true
access_token: ${{ github.token }}
continue-on-error: true
if: matrix.arch == 'amd64' && matrix.cc == 'gcc'
- uses: actions/checkout@v2
with:
submodules: true
- name: Cache ccache
uses: actions/cache@v2
env:
cache-name: cache-ccache
with:
path: /ccache
key: v1-${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.cc }}-${{ env.GITHUB_WORKFLOW }}-${{ matrix.arch }}
- name: Cache pip
uses: actions/cache@v2
env:
cache-name: cache-python-pip
with:
path: ~/.cache/pip
key: v1-python-pip
- name: Install python dependencies
run: |
python3 -m pip install -U -r requirements.txt
- name: Run tests
run: |
cd test
python3 -m pytest --verbose --numprocesses=auto
test-emulated:
needs:
- test-native
runs-on: ubuntu-latest
strategy:
matrix:
arch:
- armhf
- unstable-ppc
cc:
- gcc
- clang
env:
CC: ${{ matrix.cc }}
steps:
- name: Register qemu-user-static
run: |
docker run --rm --privileged multiarch/qemu-user-static:register --reset
- uses: actions/checkout@v2
with:
submodules: true
- name: Cache ccache
uses: actions/cache@v2
env:
cache-name: cache-ccache
with:
path: ~/ccache
key: v1-${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.cc }}-${{ env.GITHUB_WORKFLOW }}-${{ matrix.arch }}
- name: Cache pip
uses: actions/cache@v2
env:
cache-name: cache-python-pip
with:
path: ~/.cache/pip
key: v1-python-pip
- name: Run tests in container
run: |
docker run --rm -e CI -e CC -e PQCLEAN_ONLY_SCHEMES=rainbowI-circumzenithal -v $PWD:$PWD -w $PWD -v ~/ccache:/ccache pqclean/ci-container:${{ matrix.arch }} /bin/bash -c "\
export CCACHE_NOSTATS=1 && \
export CCACHE_DIR=/ccache && \
export CCACHE_SLOPPINESS=include_file_mtime && \
export CC=\"ccache $CC\" && \
pip3 install -U -r requirements.txt && \
cd test && \
python3 -m pytest --verbose --numprocesses=auto"
test-windows:
needs:
- test-native
strategy:
matrix:
bits:
- 64
- 32
env:
PQCLEAN_ONLY_SCHEMES: rainbowI-circumzenithal
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Setup astyle
run: |
# Setup strong crypto
Set-ItemProperty -Path "HKLM:\\SOFTWARE\\Wow6432Node\\Microsoft\\.NetFramework\\v4.0.30319" -Name 'SchUseStrongCrypto' -Value '1' -Type DWord
Set-ItemProperty -Path "HKLM:\\SOFTWARE\\Microsoft\\.NetFramework\\v4.0.30319" -Name "SchUseStrongCrypto" -Value '1' -Type DWord
Invoke-WebRequest -OutFile "test\\astyle.exe" "https://rded.nl/pqclean/AStyle.exe"
shell: powershell
- name: Setup Python
uses: actions/setup-python@main
with:
python-version: "3.x"
- name: Install python requirements
run: python -m pip install -U -r requirements.txt
- name: Run tests
run: |
call "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Auxiliary\\Build\\vcvars${{ matrix.bits }}.bat"
cd test
python -m pytest --verbose --numprocesses=auto
shell: cmd
test-macos:
needs:
- test-native
env:
PQCLEAN_ONLY_SCHEMES: rainbowI-circumzenithal
CCACHE_NOSTATS: 1
CCACHE_SLOPPINESS: include_file_mtime
# XCode version
DEVELOPER_DIR: /Applications/Xcode_11.5.app/Contents/Developer
strategy:
matrix:
compiler:
- clang # XCode (Apple LLVM/Clang)
- gcc9 # GNU (Homebrew)
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Install astyle
run: |
brew install astyle
- name: Set up GCC9 compiler
run: 'export PATH="/usr/local/bin:$PATH" && export CC=gcc-9'
if: matrix.compiler == 'gcc9'
- name: Setup Python
uses: actions/setup-python@main
with:
python-version: "3.x"
- name: Install Python dependencies
run: python -m pip install -U -r requirements.txt
- name: Run tests
run: |
cd test
python -m pytest --verbose --numprocesses=auto


.github/workflows/sign_rainbowIa-cyclic.yml → .github/workflows/sign_rainbowI-classic.yml 查看文件

@@ -5,13 +5,13 @@ on:
- 'test/**'
# do not build if other schemes duplicate_consistency files change
- '!test/duplicate_consistency/*.yml'
- 'test/duplicate_consistency/rainbowIa-cyclic*.yml'
- 'test/duplicate_consistency/rainbowI-classic*.yml'
# build if common files change
- 'common/**'
# build if scheme changed
- 'crypto_sign/rainbowIa-cyclic/**'
- 'crypto_sign/rainbowI-classic/**'
# build if workflow file changed
- '.github/workflows/sign_rainbowIa-cyclic.yml'
- '.github/workflows/sign_rainbowI-classic.yml'
# Build if any files in the root change, except .md files
- '*'
- '!*.md'
@@ -21,20 +21,20 @@ on:
- 'test/**'
# do not build if other schemes duplicate_consistency files change
- '!test/duplicate_consistency/*.yml'
- 'test/duplicate_consistency/rainbowIa-cyclic*.yml'
- 'test/duplicate_consistency/rainbowI-classic*.yml'
# build if common files change
- 'common/**'
# build if scheme changed
- 'crypto_sign/rainbowIa-cyclic/**'
- 'crypto_sign/rainbowI-classic/**'
# build if workflow file changed
- '.github/workflows/sign_rainbowIa-cyclic.yml'
- '.github/workflows/sign_rainbowI-classic.yml'
# Build if any files in the root change, except .md files
- '*'
- '!*.md'
schedule:
- cron: '5 4 * * *'

name: Test rainbowIa-cyclic
name: Test rainbowI-classic

jobs:
test-native:
@@ -42,7 +42,7 @@ jobs:
container:
image: pqclean/ci-container:${{ matrix.arch }}
env:
PQCLEAN_ONLY_SCHEMES: rainbowIa-cyclic
PQCLEAN_ONLY_SCHEMES: rainbowI-classic
CC: ccache ${{ matrix.cc }}
CCACHE_NOSTATS: 1
CCACHE_DIR: /ccache
@@ -124,7 +124,7 @@ jobs:
key: v1-python-pip
- name: Run tests in container
run: |
docker run --rm -e CI -e CC -e PQCLEAN_ONLY_SCHEMES=rainbowIa-cyclic -v $PWD:$PWD -w $PWD -v ~/ccache:/ccache pqclean/ci-container:${{ matrix.arch }} /bin/bash -c "\
docker run --rm -e CI -e CC -e PQCLEAN_ONLY_SCHEMES=rainbowI-classic -v $PWD:$PWD -w $PWD -v ~/ccache:/ccache pqclean/ci-container:${{ matrix.arch }} /bin/bash -c "\
export CCACHE_NOSTATS=1 && \
export CCACHE_DIR=/ccache && \
export CCACHE_SLOPPINESS=include_file_mtime && \
@@ -141,7 +141,7 @@ jobs:
- 64
- 32
env:
PQCLEAN_ONLY_SCHEMES: rainbowIa-cyclic
PQCLEAN_ONLY_SCHEMES: rainbowI-classic
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
@@ -170,7 +170,7 @@ jobs:
needs:
- test-native
env:
PQCLEAN_ONLY_SCHEMES: rainbowIa-cyclic
PQCLEAN_ONLY_SCHEMES: rainbowI-classic
CCACHE_NOSTATS: 1
CCACHE_SLOPPINESS: include_file_mtime
# XCode version

.github/workflows/sign_rainbowIIIc-classic.yml → .github/workflows/sign_rainbowI-compressed.yml 查看文件

@@ -5,13 +5,13 @@ on:
- 'test/**'
# do not build if other schemes duplicate_consistency files change
- '!test/duplicate_consistency/*.yml'
- 'test/duplicate_consistency/rainbowIIIc-classic*.yml'
- 'test/duplicate_consistency/rainbowI-compressed*.yml'
# build if common files change
- 'common/**'
# build if scheme changed
- 'crypto_sign/rainbowIIIc-classic/**'
- 'crypto_sign/rainbowI-compressed/**'
# build if workflow file changed
- '.github/workflows/sign_rainbowIIIc-classic.yml'
- '.github/workflows/sign_rainbowI-compressed.yml'
# Build if any files in the root change, except .md files
- '*'
- '!*.md'
@@ -21,20 +21,20 @@ on:
- 'test/**'
# do not build if other schemes duplicate_consistency files change
- '!test/duplicate_consistency/*.yml'
- 'test/duplicate_consistency/rainbowIIIc-classic*.yml'
- 'test/duplicate_consistency/rainbowI-compressed*.yml'
# build if common files change
- 'common/**'
# build if scheme changed
- 'crypto_sign/rainbowIIIc-classic/**'
- 'crypto_sign/rainbowI-compressed/**'
# build if workflow file changed
- '.github/workflows/sign_rainbowIIIc-classic.yml'
- '.github/workflows/sign_rainbowI-compressed.yml'
# Build if any files in the root change, except .md files
- '*'
- '!*.md'
schedule:
- cron: '5 4 * * *'

name: Test rainbowIIIc-classic
name: Test rainbowI-compressed

jobs:
test-native:
@@ -42,7 +42,7 @@ jobs:
container:
image: pqclean/ci-container:${{ matrix.arch }}
env:
PQCLEAN_ONLY_SCHEMES: rainbowIIIc-classic
PQCLEAN_ONLY_SCHEMES: rainbowI-compressed
CC: ccache ${{ matrix.cc }}
CCACHE_NOSTATS: 1
CCACHE_DIR: /ccache
@@ -124,7 +124,7 @@ jobs:
key: v1-python-pip
- name: Run tests in container
run: |
docker run --rm -e CI -e CC -e PQCLEAN_ONLY_SCHEMES=rainbowIIIc-classic -v $PWD:$PWD -w $PWD -v ~/ccache:/ccache pqclean/ci-container:${{ matrix.arch }} /bin/bash -c "\
docker run --rm -e CI -e CC -e PQCLEAN_ONLY_SCHEMES=rainbowI-compressed -v $PWD:$PWD -w $PWD -v ~/ccache:/ccache pqclean/ci-container:${{ matrix.arch }} /bin/bash -c "\
export CCACHE_NOSTATS=1 && \
export CCACHE_DIR=/ccache && \
export CCACHE_SLOPPINESS=include_file_mtime && \
@@ -141,7 +141,7 @@ jobs:
- 64
- 32
env:
PQCLEAN_ONLY_SCHEMES: rainbowIIIc-classic
PQCLEAN_ONLY_SCHEMES: rainbowI-compressed
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
@@ -170,7 +170,7 @@ jobs:
needs:
- test-native
env:
PQCLEAN_ONLY_SCHEMES: rainbowIIIc-classic
PQCLEAN_ONLY_SCHEMES: rainbowI-compressed
CCACHE_NOSTATS: 1
CCACHE_SLOPPINESS: include_file_mtime
# XCode version

+ 204
- 0
.github/workflows/sign_rainbowIII-circumzenithal.yml 查看文件

@@ -0,0 +1,204 @@
on:
push:
paths:
# build if tests change
- 'test/**'
# do not build if other schemes duplicate_consistency files change
- '!test/duplicate_consistency/*.yml'
- 'test/duplicate_consistency/rainbowIII-circumzenithal*.yml'
# build if common files change
- 'common/**'
# build if scheme changed
- 'crypto_sign/rainbowIII-circumzenithal/**'
# build if workflow file changed
- '.github/workflows/sign_rainbowIII-circumzenithal.yml'
# Build if any files in the root change, except .md files
- '*'
- '!*.md'
pull_request:
paths:
# build if tests change
- 'test/**'
# do not build if other schemes duplicate_consistency files change
- '!test/duplicate_consistency/*.yml'
- 'test/duplicate_consistency/rainbowIII-circumzenithal*.yml'
# build if common files change
- 'common/**'
# build if scheme changed
- 'crypto_sign/rainbowIII-circumzenithal/**'
# build if workflow file changed
- '.github/workflows/sign_rainbowIII-circumzenithal.yml'
# Build if any files in the root change, except .md files
- '*'
- '!*.md'
schedule:
- cron: '5 4 * * *'

name: Test rainbowIII-circumzenithal

jobs:
test-native:
runs-on: ubuntu-latest
container:
image: pqclean/ci-container:${{ matrix.arch }}
env:
PQCLEAN_ONLY_SCHEMES: rainbowIII-circumzenithal
CC: ccache ${{ matrix.cc }}
CCACHE_NOSTATS: 1
CCACHE_DIR: /ccache
CCACHE_SLOPPINESS: include_file_mtime
strategy:
matrix:
arch:
- amd64
- i386
cc:
- gcc
- clang
steps:
- name: Cancel Previous Runs
uses: thomwiggers/cancel-workflow-action@all_but_latest
with:
all_but_latest: true
access_token: ${{ github.token }}
continue-on-error: true
if: matrix.arch == 'amd64' && matrix.cc == 'gcc'
- uses: actions/checkout@v2
with:
submodules: true
- name: Cache ccache
uses: actions/cache@v2
env:
cache-name: cache-ccache
with:
path: /ccache
key: v1-${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.cc }}-${{ env.GITHUB_WORKFLOW }}-${{ matrix.arch }}
- name: Cache pip
uses: actions/cache@v2
env:
cache-name: cache-python-pip
with:
path: ~/.cache/pip
key: v1-python-pip
- name: Install python dependencies
run: |
python3 -m pip install -U -r requirements.txt
- name: Run tests
run: |
cd test
python3 -m pytest --verbose --numprocesses=auto
test-emulated:
needs:
- test-native
runs-on: ubuntu-latest
strategy:
matrix:
arch:
- armhf
- unstable-ppc
cc:
- gcc
- clang
env:
CC: ${{ matrix.cc }}
steps:
- name: Register qemu-user-static
run: |
docker run --rm --privileged multiarch/qemu-user-static:register --reset
- uses: actions/checkout@v2
with:
submodules: true
- name: Cache ccache
uses: actions/cache@v2
env:
cache-name: cache-ccache
with:
path: ~/ccache
key: v1-${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.cc }}-${{ env.GITHUB_WORKFLOW }}-${{ matrix.arch }}
- name: Cache pip
uses: actions/cache@v2
env:
cache-name: cache-python-pip
with:
path: ~/.cache/pip
key: v1-python-pip
- name: Run tests in container
run: |
docker run --rm -e CI -e CC -e PQCLEAN_ONLY_SCHEMES=rainbowIII-circumzenithal -v $PWD:$PWD -w $PWD -v ~/ccache:/ccache pqclean/ci-container:${{ matrix.arch }} /bin/bash -c "\
export CCACHE_NOSTATS=1 && \
export CCACHE_DIR=/ccache && \
export CCACHE_SLOPPINESS=include_file_mtime && \
export CC=\"ccache $CC\" && \
pip3 install -U -r requirements.txt && \
cd test && \
python3 -m pytest --verbose --numprocesses=auto"
test-windows:
needs:
- test-native
strategy:
matrix:
bits:
- 64
- 32
env:
PQCLEAN_ONLY_SCHEMES: rainbowIII-circumzenithal
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Setup astyle
run: |
# Setup strong crypto
Set-ItemProperty -Path "HKLM:\\SOFTWARE\\Wow6432Node\\Microsoft\\.NetFramework\\v4.0.30319" -Name 'SchUseStrongCrypto' -Value '1' -Type DWord
Set-ItemProperty -Path "HKLM:\\SOFTWARE\\Microsoft\\.NetFramework\\v4.0.30319" -Name "SchUseStrongCrypto" -Value '1' -Type DWord
Invoke-WebRequest -OutFile "test\\astyle.exe" "https://rded.nl/pqclean/AStyle.exe"
shell: powershell
- name: Setup Python
uses: actions/setup-python@main
with:
python-version: "3.x"
- name: Install python requirements
run: python -m pip install -U -r requirements.txt
- name: Run tests
run: |
call "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Auxiliary\\Build\\vcvars${{ matrix.bits }}.bat"
cd test
python -m pytest --verbose --numprocesses=auto
shell: cmd
test-macos:
needs:
- test-native
env:
PQCLEAN_ONLY_SCHEMES: rainbowIII-circumzenithal
CCACHE_NOSTATS: 1
CCACHE_SLOPPINESS: include_file_mtime
# XCode version
DEVELOPER_DIR: /Applications/Xcode_11.5.app/Contents/Developer
strategy:
matrix:
compiler:
- clang # XCode (Apple LLVM/Clang)
- gcc9 # GNU (Homebrew)
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Install astyle
run: |
brew install astyle
- name: Set up GCC9 compiler
run: 'export PATH="/usr/local/bin:$PATH" && export CC=gcc-9'
if: matrix.compiler == 'gcc9'
- name: Setup Python
uses: actions/setup-python@main
with:
python-version: "3.x"
- name: Install Python dependencies
run: python -m pip install -U -r requirements.txt
- name: Run tests
run: |
cd test
python -m pytest --verbose --numprocesses=auto


.github/workflows/sign_rainbowIIIc-cyclic.yml → .github/workflows/sign_rainbowIII-classic.yml 查看文件

@@ -5,13 +5,13 @@ on:
- 'test/**'
# do not build if other schemes duplicate_consistency files change
- '!test/duplicate_consistency/*.yml'
- 'test/duplicate_consistency/rainbowIIIc-cyclic*.yml'
- 'test/duplicate_consistency/rainbowIII-classic*.yml'
# build if common files change
- 'common/**'
# build if scheme changed
- 'crypto_sign/rainbowIIIc-cyclic/**'
- 'crypto_sign/rainbowIII-classic/**'
# build if workflow file changed
- '.github/workflows/sign_rainbowIIIc-cyclic.yml'
- '.github/workflows/sign_rainbowIII-classic.yml'
# Build if any files in the root change, except .md files
- '*'
- '!*.md'
@@ -21,20 +21,20 @@ on:
- 'test/**'
# do not build if other schemes duplicate_consistency files change
- '!test/duplicate_consistency/*.yml'
- 'test/duplicate_consistency/rainbowIIIc-cyclic*.yml'
- 'test/duplicate_consistency/rainbowIII-classic*.yml'
# build if common files change
- 'common/**'
# build if scheme changed
- 'crypto_sign/rainbowIIIc-cyclic/**'
- 'crypto_sign/rainbowIII-classic/**'
# build if workflow file changed
- '.github/workflows/sign_rainbowIIIc-cyclic.yml'
- '.github/workflows/sign_rainbowIII-classic.yml'
# Build if any files in the root change, except .md files
- '*'
- '!*.md'
schedule:
- cron: '5 4 * * *'

name: Test rainbowIIIc-cyclic
name: Test rainbowIII-classic

jobs:
test-native:
@@ -42,7 +42,7 @@ jobs:
container:
image: pqclean/ci-container:${{ matrix.arch }}
env:
PQCLEAN_ONLY_SCHEMES: rainbowIIIc-cyclic
PQCLEAN_ONLY_SCHEMES: rainbowIII-classic
CC: ccache ${{ matrix.cc }}
CCACHE_NOSTATS: 1
CCACHE_DIR: /ccache
@@ -124,7 +124,7 @@ jobs:
key: v1-python-pip
- name: Run tests in container
run: |
docker run --rm -e CI -e CC -e PQCLEAN_ONLY_SCHEMES=rainbowIIIc-cyclic -v $PWD:$PWD -w $PWD -v ~/ccache:/ccache pqclean/ci-container:${{ matrix.arch }} /bin/bash -c "\
docker run --rm -e CI -e CC -e PQCLEAN_ONLY_SCHEMES=rainbowIII-classic -v $PWD:$PWD -w $PWD -v ~/ccache:/ccache pqclean/ci-container:${{ matrix.arch }} /bin/bash -c "\
export CCACHE_NOSTATS=1 && \
export CCACHE_DIR=/ccache && \
export CCACHE_SLOPPINESS=include_file_mtime && \
@@ -141,7 +141,7 @@ jobs:
- 64
- 32
env:
PQCLEAN_ONLY_SCHEMES: rainbowIIIc-cyclic
PQCLEAN_ONLY_SCHEMES: rainbowIII-classic
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
@@ -170,7 +170,7 @@ jobs:
needs:
- test-native
env:
PQCLEAN_ONLY_SCHEMES: rainbowIIIc-cyclic
PQCLEAN_ONLY_SCHEMES: rainbowIII-classic
CCACHE_NOSTATS: 1
CCACHE_SLOPPINESS: include_file_mtime
# XCode version

+ 204
- 0
.github/workflows/sign_rainbowIII-compressed.yml 查看文件

@@ -0,0 +1,204 @@
on:
push:
paths:
# build if tests change
- 'test/**'
# do not build if other schemes duplicate_consistency files change
- '!test/duplicate_consistency/*.yml'
- 'test/duplicate_consistency/rainbowIII-compressed*.yml'
# build if common files change
- 'common/**'
# build if scheme changed
- 'crypto_sign/rainbowIII-compressed/**'
# build if workflow file changed
- '.github/workflows/sign_rainbowIII-compressed.yml'
# Build if any files in the root change, except .md files
- '*'
- '!*.md'
pull_request:
paths:
# build if tests change
- 'test/**'
# do not build if other schemes duplicate_consistency files change
- '!test/duplicate_consistency/*.yml'
- 'test/duplicate_consistency/rainbowIII-compressed*.yml'
# build if common files change
- 'common/**'
# build if scheme changed
- 'crypto_sign/rainbowIII-compressed/**'
# build if workflow file changed
- '.github/workflows/sign_rainbowIII-compressed.yml'
# Build if any files in the root change, except .md files
- '*'
- '!*.md'
schedule:
- cron: '5 4 * * *'

name: Test rainbowIII-compressed

jobs:
test-native:
runs-on: ubuntu-latest
container:
image: pqclean/ci-container:${{ matrix.arch }}
env:
PQCLEAN_ONLY_SCHEMES: rainbowIII-compressed
CC: ccache ${{ matrix.cc }}
CCACHE_NOSTATS: 1
CCACHE_DIR: /ccache
CCACHE_SLOPPINESS: include_file_mtime
strategy:
matrix:
arch:
- amd64
- i386
cc:
- gcc
- clang
steps:
- name: Cancel Previous Runs
uses: thomwiggers/cancel-workflow-action@all_but_latest
with:
all_but_latest: true
access_token: ${{ github.token }}
continue-on-error: true
if: matrix.arch == 'amd64' && matrix.cc == 'gcc'
- uses: actions/checkout@v2
with:
submodules: true
- name: Cache ccache
uses: actions/cache@v2
env:
cache-name: cache-ccache
with:
path: /ccache
key: v1-${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.cc }}-${{ env.GITHUB_WORKFLOW }}-${{ matrix.arch }}
- name: Cache pip
uses: actions/cache@v2
env:
cache-name: cache-python-pip
with:
path: ~/.cache/pip
key: v1-python-pip
- name: Install python dependencies
run: |
python3 -m pip install -U -r requirements.txt
- name: Run tests
run: |
cd test
python3 -m pytest --verbose --numprocesses=auto
test-emulated:
needs:
- test-native
runs-on: ubuntu-latest
strategy:
matrix:
arch:
- armhf
- unstable-ppc
cc:
- gcc
- clang
env:
CC: ${{ matrix.cc }}
steps:
- name: Register qemu-user-static
run: |
docker run --rm --privileged multiarch/qemu-user-static:register --reset
- uses: actions/checkout@v2
with:
submodules: true
- name: Cache ccache
uses: actions/cache@v2
env:
cache-name: cache-ccache
with:
path: ~/ccache
key: v1-${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.cc }}-${{ env.GITHUB_WORKFLOW }}-${{ matrix.arch }}
- name: Cache pip
uses: actions/cache@v2
env:
cache-name: cache-python-pip
with:
path: ~/.cache/pip
key: v1-python-pip
- name: Run tests in container
run: |
docker run --rm -e CI -e CC -e PQCLEAN_ONLY_SCHEMES=rainbowIII-compressed -v $PWD:$PWD -w $PWD -v ~/ccache:/ccache pqclean/ci-container:${{ matrix.arch }} /bin/bash -c "\
export CCACHE_NOSTATS=1 && \
export CCACHE_DIR=/ccache && \
export CCACHE_SLOPPINESS=include_file_mtime && \
export CC=\"ccache $CC\" && \
pip3 install -U -r requirements.txt && \
cd test && \
python3 -m pytest --verbose --numprocesses=auto"
test-windows:
needs:
- test-native
strategy:
matrix:
bits:
- 64
- 32
env:
PQCLEAN_ONLY_SCHEMES: rainbowIII-compressed
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Setup astyle
run: |
# Setup strong crypto
Set-ItemProperty -Path "HKLM:\\SOFTWARE\\Wow6432Node\\Microsoft\\.NetFramework\\v4.0.30319" -Name 'SchUseStrongCrypto' -Value '1' -Type DWord
Set-ItemProperty -Path "HKLM:\\SOFTWARE\\Microsoft\\.NetFramework\\v4.0.30319" -Name "SchUseStrongCrypto" -Value '1' -Type DWord
Invoke-WebRequest -OutFile "test\\astyle.exe" "https://rded.nl/pqclean/AStyle.exe"
shell: powershell
- name: Setup Python
uses: actions/setup-python@main
with:
python-version: "3.x"
- name: Install python requirements
run: python -m pip install -U -r requirements.txt
- name: Run tests
run: |
call "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Auxiliary\\Build\\vcvars${{ matrix.bits }}.bat"
cd test
python -m pytest --verbose --numprocesses=auto
shell: cmd
test-macos:
needs:
- test-native
env:
PQCLEAN_ONLY_SCHEMES: rainbowIII-compressed
CCACHE_NOSTATS: 1
CCACHE_SLOPPINESS: include_file_mtime
# XCode version
DEVELOPER_DIR: /Applications/Xcode_11.5.app/Contents/Developer
strategy:
matrix:
compiler:
- clang # XCode (Apple LLVM/Clang)
- gcc9 # GNU (Homebrew)
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Install astyle
run: |
brew install astyle
- name: Set up GCC9 compiler
run: 'export PATH="/usr/local/bin:$PATH" && export CC=gcc-9'
if: matrix.compiler == 'gcc9'
- name: Setup Python
uses: actions/setup-python@main
with:
python-version: "3.x"
- name: Install Python dependencies
run: python -m pip install -U -r requirements.txt
- name: Run tests
run: |
cd test
python -m pytest --verbose --numprocesses=auto


+ 0
- 204
.github/workflows/sign_rainbowIIIc-cyclic-compressed.yml 查看文件

@@ -1,204 +0,0 @@
on:
push:
paths:
# build if tests change
- 'test/**'
# do not build if other schemes duplicate_consistency files change
- '!test/duplicate_consistency/*.yml'
- 'test/duplicate_consistency/rainbowIIIc-cyclic-compressed*.yml'
# build if common files change
- 'common/**'
# build if scheme changed
- 'crypto_sign/rainbowIIIc-cyclic-compressed/**'
# build if workflow file changed
- '.github/workflows/sign_rainbowIIIc-cyclic-compressed.yml'
# Build if any files in the root change, except .md files
- '*'
- '!*.md'
pull_request:
paths:
# build if tests change
- 'test/**'
# do not build if other schemes duplicate_consistency files change
- '!test/duplicate_consistency/*.yml'
- 'test/duplicate_consistency/rainbowIIIc-cyclic-compressed*.yml'
# build if common files change
- 'common/**'
# build if scheme changed
- 'crypto_sign/rainbowIIIc-cyclic-compressed/**'
# build if workflow file changed
- '.github/workflows/sign_rainbowIIIc-cyclic-compressed.yml'
# Build if any files in the root change, except .md files
- '*'
- '!*.md'
schedule:
- cron: '5 4 * * *'

name: Test rainbowIIIc-cyclic-compressed

jobs:
test-native:
runs-on: ubuntu-latest
container:
image: pqclean/ci-container:${{ matrix.arch }}
env:
PQCLEAN_ONLY_SCHEMES: rainbowIIIc-cyclic-compressed
CC: ccache ${{ matrix.cc }}
CCACHE_NOSTATS: 1
CCACHE_DIR: /ccache
CCACHE_SLOPPINESS: include_file_mtime
strategy:
matrix:
arch:
- amd64
- i386
cc:
- gcc
- clang
steps:
- name: Cancel Previous Runs
uses: thomwiggers/cancel-workflow-action@all_but_latest
with:
all_but_latest: true
access_token: ${{ github.token }}
continue-on-error: true
if: matrix.arch == 'amd64' && matrix.cc == 'gcc'
- uses: actions/checkout@v2
with:
submodules: true
- name: Cache ccache
uses: actions/cache@v2
env:
cache-name: cache-ccache
with:
path: /ccache
key: v1-${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.cc }}-${{ env.GITHUB_WORKFLOW }}-${{ matrix.arch }}
- name: Cache pip
uses: actions/cache@v2
env:
cache-name: cache-python-pip
with:
path: ~/.cache/pip
key: v1-python-pip
- name: Install python dependencies
run: |
python3 -m pip install -U -r requirements.txt
- name: Run tests
run: |
cd test
python3 -m pytest --verbose --numprocesses=auto
test-emulated:
needs:
- test-native
runs-on: ubuntu-latest
strategy:
matrix:
arch:
- armhf
- unstable-ppc
cc:
- gcc
- clang
env:
CC: ${{ matrix.cc }}
steps:
- name: Register qemu-user-static
run: |
docker run --rm --privileged multiarch/qemu-user-static:register --reset
- uses: actions/checkout@v2
with:
submodules: true
- name: Cache ccache
uses: actions/cache@v2
env:
cache-name: cache-ccache
with:
path: ~/ccache
key: v1-${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.cc }}-${{ env.GITHUB_WORKFLOW }}-${{ matrix.arch }}
- name: Cache pip
uses: actions/cache@v2
env:
cache-name: cache-python-pip
with:
path: ~/.cache/pip
key: v1-python-pip
- name: Run tests in container
run: |
docker run --rm -e CI -e CC -e PQCLEAN_ONLY_SCHEMES=rainbowIIIc-cyclic-compressed -v $PWD:$PWD -w $PWD -v ~/ccache:/ccache pqclean/ci-container:${{ matrix.arch }} /bin/bash -c "\
export CCACHE_NOSTATS=1 && \
export CCACHE_DIR=/ccache && \
export CCACHE_SLOPPINESS=include_file_mtime && \
export CC=\"ccache $CC\" && \
pip3 install -U -r requirements.txt && \
cd test && \
python3 -m pytest --verbose --numprocesses=auto"
test-windows:
needs:
- test-native
strategy:
matrix:
bits:
- 64
- 32
env:
PQCLEAN_ONLY_SCHEMES: rainbowIIIc-cyclic-compressed
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Setup astyle
run: |
# Setup strong crypto
Set-ItemProperty -Path "HKLM:\\SOFTWARE\\Wow6432Node\\Microsoft\\.NetFramework\\v4.0.30319" -Name 'SchUseStrongCrypto' -Value '1' -Type DWord
Set-ItemProperty -Path "HKLM:\\SOFTWARE\\Microsoft\\.NetFramework\\v4.0.30319" -Name "SchUseStrongCrypto" -Value '1' -Type DWord
Invoke-WebRequest -OutFile "test\\astyle.exe" "https://rded.nl/pqclean/AStyle.exe"
shell: powershell
- name: Setup Python
uses: actions/setup-python@main
with:
python-version: "3.x"
- name: Install python requirements
run: python -m pip install -U -r requirements.txt
- name: Run tests
run: |
call "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Auxiliary\\Build\\vcvars${{ matrix.bits }}.bat"
cd test
python -m pytest --verbose --numprocesses=auto
shell: cmd
test-macos:
needs:
- test-native
env:
PQCLEAN_ONLY_SCHEMES: rainbowIIIc-cyclic-compressed
CCACHE_NOSTATS: 1
CCACHE_SLOPPINESS: include_file_mtime
# XCode version
DEVELOPER_DIR: /Applications/Xcode_11.5.app/Contents/Developer
strategy:
matrix:
compiler:
- clang # XCode (Apple LLVM/Clang)
- gcc9 # GNU (Homebrew)
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Install astyle
run: |
brew install astyle
- name: Set up GCC9 compiler
run: 'export PATH="/usr/local/bin:$PATH" && export CC=gcc-9'
if: matrix.compiler == 'gcc9'
- name: Setup Python
uses: actions/setup-python@main
with:
python-version: "3.x"
- name: Install Python dependencies
run: python -m pip install -U -r requirements.txt
- name: Run tests
run: |
cd test
python -m pytest --verbose --numprocesses=auto


+ 0
- 204
.github/workflows/sign_rainbowIa-cyclic-compressed.yml 查看文件

@@ -1,204 +0,0 @@
on:
push:
paths:
# build if tests change
- 'test/**'
# do not build if other schemes duplicate_consistency files change
- '!test/duplicate_consistency/*.yml'
- 'test/duplicate_consistency/rainbowIa-cyclic-compressed*.yml'
# build if common files change
- 'common/**'
# build if scheme changed
- 'crypto_sign/rainbowIa-cyclic-compressed/**'
# build if workflow file changed
- '.github/workflows/sign_rainbowIa-cyclic-compressed.yml'
# Build if any files in the root change, except .md files
- '*'
- '!*.md'
pull_request:
paths:
# build if tests change
- 'test/**'
# do not build if other schemes duplicate_consistency files change
- '!test/duplicate_consistency/*.yml'
- 'test/duplicate_consistency/rainbowIa-cyclic-compressed*.yml'
# build if common files change
- 'common/**'
# build if scheme changed
- 'crypto_sign/rainbowIa-cyclic-compressed/**'
# build if workflow file changed
- '.github/workflows/sign_rainbowIa-cyclic-compressed.yml'
# Build if any files in the root change, except .md files
- '*'
- '!*.md'
schedule:
- cron: '5 4 * * *'

name: Test rainbowIa-cyclic-compressed

jobs:
test-native:
runs-on: ubuntu-latest
container:
image: pqclean/ci-container:${{ matrix.arch }}
env:
PQCLEAN_ONLY_SCHEMES: rainbowIa-cyclic-compressed
CC: ccache ${{ matrix.cc }}
CCACHE_NOSTATS: 1
CCACHE_DIR: /ccache
CCACHE_SLOPPINESS: include_file_mtime
strategy:
matrix:
arch:
- amd64
- i386
cc:
- gcc
- clang
steps:
- name: Cancel Previous Runs
uses: thomwiggers/cancel-workflow-action@all_but_latest
with:
all_but_latest: true
access_token: ${{ github.token }}
continue-on-error: true
if: matrix.arch == 'amd64' && matrix.cc == 'gcc'
- uses: actions/checkout@v2
with:
submodules: true
- name: Cache ccache
uses: actions/cache@v2
env:
cache-name: cache-ccache
with:
path: /ccache
key: v1-${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.cc }}-${{ env.GITHUB_WORKFLOW }}-${{ matrix.arch }}
- name: Cache pip
uses: actions/cache@v2
env:
cache-name: cache-python-pip
with:
path: ~/.cache/pip
key: v1-python-pip
- name: Install python dependencies
run: |
python3 -m pip install -U -r requirements.txt
- name: Run tests
run: |
cd test
python3 -m pytest --verbose --numprocesses=auto
test-emulated:
needs:
- test-native
runs-on: ubuntu-latest
strategy:
matrix:
arch:
- armhf
- unstable-ppc
cc:
- gcc
- clang
env:
CC: ${{ matrix.cc }}
steps:
- name: Register qemu-user-static
run: |
docker run --rm --privileged multiarch/qemu-user-static:register --reset
- uses: actions/checkout@v2
with:
submodules: true
- name: Cache ccache
uses: actions/cache@v2
env:
cache-name: cache-ccache
with:
path: ~/ccache
key: v1-${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.cc }}-${{ env.GITHUB_WORKFLOW }}-${{ matrix.arch }}
- name: Cache pip
uses: actions/cache@v2
env:
cache-name: cache-python-pip
with:
path: ~/.cache/pip
key: v1-python-pip
- name: Run tests in container
run: |
docker run --rm -e CI -e CC -e PQCLEAN_ONLY_SCHEMES=rainbowIa-cyclic-compressed -v $PWD:$PWD -w $PWD -v ~/ccache:/ccache pqclean/ci-container:${{ matrix.arch }} /bin/bash -c "\
export CCACHE_NOSTATS=1 && \
export CCACHE_DIR=/ccache && \
export CCACHE_SLOPPINESS=include_file_mtime && \
export CC=\"ccache $CC\" && \
pip3 install -U -r requirements.txt && \
cd test && \
python3 -m pytest --verbose --numprocesses=auto"
test-windows:
needs:
- test-native
strategy:
matrix:
bits:
- 64
- 32
env:
PQCLEAN_ONLY_SCHEMES: rainbowIa-cyclic-compressed
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Setup astyle
run: |
# Setup strong crypto
Set-ItemProperty -Path "HKLM:\\SOFTWARE\\Wow6432Node\\Microsoft\\.NetFramework\\v4.0.30319" -Name 'SchUseStrongCrypto' -Value '1' -Type DWord
Set-ItemProperty -Path "HKLM:\\SOFTWARE\\Microsoft\\.NetFramework\\v4.0.30319" -Name "SchUseStrongCrypto" -Value '1' -Type DWord
Invoke-WebRequest -OutFile "test\\astyle.exe" "https://rded.nl/pqclean/AStyle.exe"
shell: powershell
- name: Setup Python
uses: actions/setup-python@main
with:
python-version: "3.x"
- name: Install python requirements
run: python -m pip install -U -r requirements.txt
- name: Run tests
run: |
call "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Auxiliary\\Build\\vcvars${{ matrix.bits }}.bat"
cd test
python -m pytest --verbose --numprocesses=auto
shell: cmd
test-macos:
needs:
- test-native
env:
PQCLEAN_ONLY_SCHEMES: rainbowIa-cyclic-compressed
CCACHE_NOSTATS: 1
CCACHE_SLOPPINESS: include_file_mtime
# XCode version
DEVELOPER_DIR: /Applications/Xcode_11.5.app/Contents/Developer
strategy:
matrix:
compiler:
- clang # XCode (Apple LLVM/Clang)
- gcc9 # GNU (Homebrew)
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Install astyle
run: |
brew install astyle
- name: Set up GCC9 compiler
run: 'export PATH="/usr/local/bin:$PATH" && export CC=gcc-9'
if: matrix.compiler == 'gcc9'
- name: Setup Python
uses: actions/setup-python@main
with:
python-version: "3.x"
- name: Install Python dependencies
run: python -m pip install -U -r requirements.txt
- name: Run tests
run: |
cd test
python -m pytest --verbose --numprocesses=auto


+ 204
- 0
.github/workflows/sign_rainbowV-circumzenithal.yml 查看文件

@@ -0,0 +1,204 @@
on:
push:
paths:
# build if tests change
- 'test/**'
# do not build if other schemes duplicate_consistency files change
- '!test/duplicate_consistency/*.yml'
- 'test/duplicate_consistency/rainbowV-circumzenithal*.yml'
# build if common files change
- 'common/**'
# build if scheme changed
- 'crypto_sign/rainbowV-circumzenithal/**'
# build if workflow file changed
- '.github/workflows/sign_rainbowV-circumzenithal.yml'
# Build if any files in the root change, except .md files
- '*'
- '!*.md'
pull_request:
paths:
# build if tests change
- 'test/**'
# do not build if other schemes duplicate_consistency files change
- '!test/duplicate_consistency/*.yml'
- 'test/duplicate_consistency/rainbowV-circumzenithal*.yml'
# build if common files change
- 'common/**'
# build if scheme changed
- 'crypto_sign/rainbowV-circumzenithal/**'
# build if workflow file changed
- '.github/workflows/sign_rainbowV-circumzenithal.yml'
# Build if any files in the root change, except .md files
- '*'
- '!*.md'
schedule:
- cron: '5 4 * * *'

name: Test rainbowV-circumzenithal

jobs:
test-native:
runs-on: ubuntu-latest
container:
image: pqclean/ci-container:${{ matrix.arch }}
env:
PQCLEAN_ONLY_SCHEMES: rainbowV-circumzenithal
CC: ccache ${{ matrix.cc }}
CCACHE_NOSTATS: 1
CCACHE_DIR: /ccache
CCACHE_SLOPPINESS: include_file_mtime
strategy:
matrix:
arch:
- amd64
- i386
cc:
- gcc
- clang
steps:
- name: Cancel Previous Runs
uses: thomwiggers/cancel-workflow-action@all_but_latest
with:
all_but_latest: true
access_token: ${{ github.token }}
continue-on-error: true
if: matrix.arch == 'amd64' && matrix.cc == 'gcc'
- uses: actions/checkout@v2
with:
submodules: true
- name: Cache ccache
uses: actions/cache@v2
env:
cache-name: cache-ccache
with:
path: /ccache
key: v1-${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.cc }}-${{ env.GITHUB_WORKFLOW }}-${{ matrix.arch }}
- name: Cache pip
uses: actions/cache@v2
env:
cache-name: cache-python-pip
with:
path: ~/.cache/pip
key: v1-python-pip
- name: Install python dependencies
run: |
python3 -m pip install -U -r requirements.txt
- name: Run tests
run: |
cd test
python3 -m pytest --verbose --numprocesses=auto
test-emulated:
needs:
- test-native
runs-on: ubuntu-latest
strategy:
matrix:
arch:
- armhf
- unstable-ppc
cc:
- gcc
- clang
env:
CC: ${{ matrix.cc }}
steps:
- name: Register qemu-user-static
run: |
docker run --rm --privileged multiarch/qemu-user-static:register --reset
- uses: actions/checkout@v2
with:
submodules: true
- name: Cache ccache
uses: actions/cache@v2
env:
cache-name: cache-ccache
with:
path: ~/ccache
key: v1-${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.cc }}-${{ env.GITHUB_WORKFLOW }}-${{ matrix.arch }}
- name: Cache pip
uses: actions/cache@v2
env:
cache-name: cache-python-pip
with:
path: ~/.cache/pip
key: v1-python-pip
- name: Run tests in container
run: |
docker run --rm -e CI -e CC -e PQCLEAN_ONLY_SCHEMES=rainbowV-circumzenithal -v $PWD:$PWD -w $PWD -v ~/ccache:/ccache pqclean/ci-container:${{ matrix.arch }} /bin/bash -c "\
export CCACHE_NOSTATS=1 && \
export CCACHE_DIR=/ccache && \
export CCACHE_SLOPPINESS=include_file_mtime && \
export CC=\"ccache $CC\" && \
pip3 install -U -r requirements.txt && \
cd test && \
python3 -m pytest --verbose --numprocesses=auto"
test-windows:
needs:
- test-native
strategy:
matrix:
bits:
- 64
- 32
env:
PQCLEAN_ONLY_SCHEMES: rainbowV-circumzenithal
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Setup astyle
run: |
# Setup strong crypto
Set-ItemProperty -Path "HKLM:\\SOFTWARE\\Wow6432Node\\Microsoft\\.NetFramework\\v4.0.30319" -Name 'SchUseStrongCrypto' -Value '1' -Type DWord
Set-ItemProperty -Path "HKLM:\\SOFTWARE\\Microsoft\\.NetFramework\\v4.0.30319" -Name "SchUseStrongCrypto" -Value '1' -Type DWord
Invoke-WebRequest -OutFile "test\\astyle.exe" "https://rded.nl/pqclean/AStyle.exe"
shell: powershell
- name: Setup Python
uses: actions/setup-python@main
with:
python-version: "3.x"
- name: Install python requirements
run: python -m pip install -U -r requirements.txt
- name: Run tests
run: |
call "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Auxiliary\\Build\\vcvars${{ matrix.bits }}.bat"
cd test
python -m pytest --verbose --numprocesses=auto
shell: cmd
test-macos:
needs:
- test-native
env:
PQCLEAN_ONLY_SCHEMES: rainbowV-circumzenithal
CCACHE_NOSTATS: 1
CCACHE_SLOPPINESS: include_file_mtime
# XCode version
DEVELOPER_DIR: /Applications/Xcode_11.5.app/Contents/Developer
strategy:
matrix:
compiler:
- clang # XCode (Apple LLVM/Clang)
- gcc9 # GNU (Homebrew)
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Install astyle
run: |
brew install astyle
- name: Set up GCC9 compiler
run: 'export PATH="/usr/local/bin:$PATH" && export CC=gcc-9'
if: matrix.compiler == 'gcc9'
- name: Setup Python
uses: actions/setup-python@main
with:
python-version: "3.x"
- name: Install Python dependencies
run: python -m pip install -U -r requirements.txt
- name: Run tests
run: |
cd test
python -m pytest --verbose --numprocesses=auto


.github/workflows/sign_rainbowVc-cyclic.yml → .github/workflows/sign_rainbowV-classic.yml 查看文件

@@ -5,13 +5,13 @@ on:
- 'test/**'
# do not build if other schemes duplicate_consistency files change
- '!test/duplicate_consistency/*.yml'
- 'test/duplicate_consistency/rainbowVc-cyclic*.yml'
- 'test/duplicate_consistency/rainbowV-classic*.yml'
# build if common files change
- 'common/**'
# build if scheme changed
- 'crypto_sign/rainbowVc-cyclic/**'
- 'crypto_sign/rainbowV-classic/**'
# build if workflow file changed
- '.github/workflows/sign_rainbowVc-cyclic.yml'
- '.github/workflows/sign_rainbowV-classic.yml'
# Build if any files in the root change, except .md files
- '*'
- '!*.md'
@@ -21,20 +21,20 @@ on:
- 'test/**'
# do not build if other schemes duplicate_consistency files change
- '!test/duplicate_consistency/*.yml'
- 'test/duplicate_consistency/rainbowVc-cyclic*.yml'
- 'test/duplicate_consistency/rainbowV-classic*.yml'
# build if common files change
- 'common/**'
# build if scheme changed
- 'crypto_sign/rainbowVc-cyclic/**'
- 'crypto_sign/rainbowV-classic/**'
# build if workflow file changed
- '.github/workflows/sign_rainbowVc-cyclic.yml'
- '.github/workflows/sign_rainbowV-classic.yml'
# Build if any files in the root change, except .md files
- '*'
- '!*.md'
schedule:
- cron: '5 4 * * *'

name: Test rainbowVc-cyclic
name: Test rainbowV-classic

jobs:
test-native:
@@ -42,7 +42,7 @@ jobs:
container:
image: pqclean/ci-container:${{ matrix.arch }}
env:
PQCLEAN_ONLY_SCHEMES: rainbowVc-cyclic
PQCLEAN_ONLY_SCHEMES: rainbowV-classic
CC: ccache ${{ matrix.cc }}
CCACHE_NOSTATS: 1
CCACHE_DIR: /ccache
@@ -124,7 +124,7 @@ jobs:
key: v1-python-pip
- name: Run tests in container
run: |
docker run --rm -e CI -e CC -e PQCLEAN_ONLY_SCHEMES=rainbowVc-cyclic -v $PWD:$PWD -w $PWD -v ~/ccache:/ccache pqclean/ci-container:${{ matrix.arch }} /bin/bash -c "\
docker run --rm -e CI -e CC -e PQCLEAN_ONLY_SCHEMES=rainbowV-classic -v $PWD:$PWD -w $PWD -v ~/ccache:/ccache pqclean/ci-container:${{ matrix.arch }} /bin/bash -c "\
export CCACHE_NOSTATS=1 && \
export CCACHE_DIR=/ccache && \
export CCACHE_SLOPPINESS=include_file_mtime && \
@@ -141,7 +141,7 @@ jobs:
- 64
- 32
env:
PQCLEAN_ONLY_SCHEMES: rainbowVc-cyclic
PQCLEAN_ONLY_SCHEMES: rainbowV-classic
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
@@ -170,7 +170,7 @@ jobs:
needs:
- test-native
env:
PQCLEAN_ONLY_SCHEMES: rainbowVc-cyclic
PQCLEAN_ONLY_SCHEMES: rainbowV-classic
CCACHE_NOSTATS: 1
CCACHE_SLOPPINESS: include_file_mtime
# XCode version

.github/workflows/sign_rainbowIa-classic.yml → .github/workflows/sign_rainbowV-compressed.yml 查看文件

@@ -5,13 +5,13 @@ on:
- 'test/**'
# do not build if other schemes duplicate_consistency files change
- '!test/duplicate_consistency/*.yml'
- 'test/duplicate_consistency/rainbowIa-classic*.yml'
- 'test/duplicate_consistency/rainbowV-compressed*.yml'
# build if common files change
- 'common/**'
# build if scheme changed
- 'crypto_sign/rainbowIa-classic/**'
- 'crypto_sign/rainbowV-compressed/**'
# build if workflow file changed
- '.github/workflows/sign_rainbowIa-classic.yml'
- '.github/workflows/sign_rainbowV-compressed.yml'
# Build if any files in the root change, except .md files
- '*'
- '!*.md'
@@ -21,20 +21,20 @@ on:
- 'test/**'
# do not build if other schemes duplicate_consistency files change
- '!test/duplicate_consistency/*.yml'
- 'test/duplicate_consistency/rainbowIa-classic*.yml'
- 'test/duplicate_consistency/rainbowV-compressed*.yml'
# build if common files change
- 'common/**'
# build if scheme changed
- 'crypto_sign/rainbowIa-classic/**'
- 'crypto_sign/rainbowV-compressed/**'
# build if workflow file changed
- '.github/workflows/sign_rainbowIa-classic.yml'
- '.github/workflows/sign_rainbowV-compressed.yml'
# Build if any files in the root change, except .md files
- '*'
- '!*.md'
schedule:
- cron: '5 4 * * *'

name: Test rainbowIa-classic
name: Test rainbowV-compressed

jobs:
test-native:
@@ -42,7 +42,7 @@ jobs:
container:
image: pqclean/ci-container:${{ matrix.arch }}
env:
PQCLEAN_ONLY_SCHEMES: rainbowIa-classic
PQCLEAN_ONLY_SCHEMES: rainbowV-compressed
CC: ccache ${{ matrix.cc }}
CCACHE_NOSTATS: 1
CCACHE_DIR: /ccache
@@ -124,7 +124,7 @@ jobs:
key: v1-python-pip
- name: Run tests in container
run: |
docker run --rm -e CI -e CC -e PQCLEAN_ONLY_SCHEMES=rainbowIa-classic -v $PWD:$PWD -w $PWD -v ~/ccache:/ccache pqclean/ci-container:${{ matrix.arch }} /bin/bash -c "\
docker run --rm -e CI -e CC -e PQCLEAN_ONLY_SCHEMES=rainbowV-compressed -v $PWD:$PWD -w $PWD -v ~/ccache:/ccache pqclean/ci-container:${{ matrix.arch }} /bin/bash -c "\
export CCACHE_NOSTATS=1 && \
export CCACHE_DIR=/ccache && \
export CCACHE_SLOPPINESS=include_file_mtime && \
@@ -141,7 +141,7 @@ jobs:
- 64
- 32
env:
PQCLEAN_ONLY_SCHEMES: rainbowIa-classic
PQCLEAN_ONLY_SCHEMES: rainbowV-compressed
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
@@ -170,7 +170,7 @@ jobs:
needs:
- test-native
env:
PQCLEAN_ONLY_SCHEMES: rainbowIa-classic
PQCLEAN_ONLY_SCHEMES: rainbowV-compressed
CCACHE_NOSTATS: 1
CCACHE_SLOPPINESS: include_file_mtime
# XCode version

+ 0
- 204
.github/workflows/sign_rainbowVc-classic.yml 查看文件

@@ -1,204 +0,0 @@
on:
push:
paths:
# build if tests change
- 'test/**'
# do not build if other schemes duplicate_consistency files change
- '!test/duplicate_consistency/*.yml'
- 'test/duplicate_consistency/rainbowVc-classic*.yml'
# build if common files change
- 'common/**'
# build if scheme changed
- 'crypto_sign/rainbowVc-classic/**'
# build if workflow file changed
- '.github/workflows/sign_rainbowVc-classic.yml'
# Build if any files in the root change, except .md files
- '*'
- '!*.md'
pull_request:
paths:
# build if tests change
- 'test/**'
# do not build if other schemes duplicate_consistency files change
- '!test/duplicate_consistency/*.yml'
- 'test/duplicate_consistency/rainbowVc-classic*.yml'
# build if common files change
- 'common/**'
# build if scheme changed
- 'crypto_sign/rainbowVc-classic/**'
# build if workflow file changed
- '.github/workflows/sign_rainbowVc-classic.yml'
# Build if any files in the root change, except .md files
- '*'
- '!*.md'
schedule:
- cron: '5 4 * * *'

name: Test rainbowVc-classic

jobs:
test-native:
runs-on: ubuntu-latest
container:
image: pqclean/ci-container:${{ matrix.arch }}
env:
PQCLEAN_ONLY_SCHEMES: rainbowVc-classic
CC: ccache ${{ matrix.cc }}
CCACHE_NOSTATS: 1
CCACHE_DIR: /ccache
CCACHE_SLOPPINESS: include_file_mtime
strategy:
matrix:
arch:
- amd64
- i386
cc:
- gcc
- clang
steps:
- name: Cancel Previous Runs
uses: thomwiggers/cancel-workflow-action@all_but_latest
with:
all_but_latest: true
access_token: ${{ github.token }}
continue-on-error: true
if: matrix.arch == 'amd64' && matrix.cc == 'gcc'
- uses: actions/checkout@v2
with:
submodules: true
- name: Cache ccache
uses: actions/cache@v2
env:
cache-name: cache-ccache
with:
path: /ccache
key: v1-${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.cc }}-${{ env.GITHUB_WORKFLOW }}-${{ matrix.arch }}
- name: Cache pip
uses: actions/cache@v2
env:
cache-name: cache-python-pip
with:
path: ~/.cache/pip
key: v1-python-pip
- name: Install python dependencies
run: |
python3 -m pip install -U -r requirements.txt
- name: Run tests
run: |
cd test
python3 -m pytest --verbose --numprocesses=auto
test-emulated:
needs:
- test-native
runs-on: ubuntu-latest
strategy:
matrix:
arch:
- armhf
- unstable-ppc
cc:
- gcc
- clang
env:
CC: ${{ matrix.cc }}
steps:
- name: Register qemu-user-static
run: |
docker run --rm --privileged multiarch/qemu-user-static:register --reset
- uses: actions/checkout@v2
with:
submodules: true
- name: Cache ccache
uses: actions/cache@v2
env:
cache-name: cache-ccache
with:
path: ~/ccache
key: v1-${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.cc }}-${{ env.GITHUB_WORKFLOW }}-${{ matrix.arch }}
- name: Cache pip
uses: actions/cache@v2
env:
cache-name: cache-python-pip
with:
path: ~/.cache/pip
key: v1-python-pip
- name: Run tests in container
run: |
docker run --rm -e CI -e CC -e PQCLEAN_ONLY_SCHEMES=rainbowVc-classic -v $PWD:$PWD -w $PWD -v ~/ccache:/ccache pqclean/ci-container:${{ matrix.arch }} /bin/bash -c "\
export CCACHE_NOSTATS=1 && \
export CCACHE_DIR=/ccache && \
export CCACHE_SLOPPINESS=include_file_mtime && \
export CC=\"ccache $CC\" && \
pip3 install -U -r requirements.txt && \
cd test && \
python3 -m pytest --verbose --numprocesses=auto"
test-windows:
needs:
- test-native
strategy:
matrix:
bits:
- 64
- 32
env:
PQCLEAN_ONLY_SCHEMES: rainbowVc-classic
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Setup astyle
run: |
# Setup strong crypto
Set-ItemProperty -Path "HKLM:\\SOFTWARE\\Wow6432Node\\Microsoft\\.NetFramework\\v4.0.30319" -Name 'SchUseStrongCrypto' -Value '1' -Type DWord
Set-ItemProperty -Path "HKLM:\\SOFTWARE\\Microsoft\\.NetFramework\\v4.0.30319" -Name "SchUseStrongCrypto" -Value '1' -Type DWord
Invoke-WebRequest -OutFile "test\\astyle.exe" "https://rded.nl/pqclean/AStyle.exe"
shell: powershell
- name: Setup Python
uses: actions/setup-python@main
with:
python-version: "3.x"
- name: Install python requirements
run: python -m pip install -U -r requirements.txt
- name: Run tests
run: |
call "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Auxiliary\\Build\\vcvars${{ matrix.bits }}.bat"
cd test
python -m pytest --verbose --numprocesses=auto
shell: cmd
test-macos:
needs:
- test-native
env:
PQCLEAN_ONLY_SCHEMES: rainbowVc-classic
CCACHE_NOSTATS: 1
CCACHE_SLOPPINESS: include_file_mtime
# XCode version
DEVELOPER_DIR: /Applications/Xcode_11.5.app/Contents/Developer
strategy:
matrix:
compiler:
- clang # XCode (Apple LLVM/Clang)
- gcc9 # GNU (Homebrew)
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Install astyle
run: |
brew install astyle
- name: Set up GCC9 compiler
run: 'export PATH="/usr/local/bin:$PATH" && export CC=gcc-9'
if: matrix.compiler == 'gcc9'
- name: Setup Python
uses: actions/setup-python@main
with:
python-version: "3.x"
- name: Install Python dependencies
run: python -m pip install -U -r requirements.txt
- name: Run tests
run: |
cd test
python -m pytest --verbose --numprocesses=auto


+ 0
- 204
.github/workflows/sign_rainbowVc-cyclic-compressed.yml 查看文件

@@ -1,204 +0,0 @@
on:
push:
paths:
# build if tests change
- 'test/**'
# do not build if other schemes duplicate_consistency files change
- '!test/duplicate_consistency/*.yml'
- 'test/duplicate_consistency/rainbowVc-cyclic-compressed*.yml'
# build if common files change
- 'common/**'
# build if scheme changed
- 'crypto_sign/rainbowVc-cyclic-compressed/**'
# build if workflow file changed
- '.github/workflows/sign_rainbowVc-cyclic-compressed.yml'
# Build if any files in the root change, except .md files
- '*'
- '!*.md'
pull_request:
paths:
# build if tests change
- 'test/**'
# do not build if other schemes duplicate_consistency files change
- '!test/duplicate_consistency/*.yml'
- 'test/duplicate_consistency/rainbowVc-cyclic-compressed*.yml'
# build if common files change
- 'common/**'
# build if scheme changed
- 'crypto_sign/rainbowVc-cyclic-compressed/**'
# build if workflow file changed
- '.github/workflows/sign_rainbowVc-cyclic-compressed.yml'
# Build if any files in the root change, except .md files
- '*'
- '!*.md'
schedule:
- cron: '5 4 * * *'

name: Test rainbowVc-cyclic-compressed

jobs:
test-native:
runs-on: ubuntu-latest
container:
image: pqclean/ci-container:${{ matrix.arch }}
env:
PQCLEAN_ONLY_SCHEMES: rainbowVc-cyclic-compressed
CC: ccache ${{ matrix.cc }}
CCACHE_NOSTATS: 1
CCACHE_DIR: /ccache
CCACHE_SLOPPINESS: include_file_mtime
strategy:
matrix:
arch:
- amd64
- i386
cc:
- gcc
- clang
steps:
- name: Cancel Previous Runs
uses: thomwiggers/cancel-workflow-action@all_but_latest
with:
all_but_latest: true
access_token: ${{ github.token }}
continue-on-error: true
if: matrix.arch == 'amd64' && matrix.cc == 'gcc'
- uses: actions/checkout@v2
with:
submodules: true
- name: Cache ccache
uses: actions/cache@v2
env:
cache-name: cache-ccache
with:
path: /ccache
key: v1-${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.cc }}-${{ env.GITHUB_WORKFLOW }}-${{ matrix.arch }}
- name: Cache pip
uses: actions/cache@v2
env:
cache-name: cache-python-pip
with:
path: ~/.cache/pip
key: v1-python-pip
- name: Install python dependencies
run: |
python3 -m pip install -U -r requirements.txt
- name: Run tests
run: |
cd test
python3 -m pytest --verbose --numprocesses=auto
test-emulated:
needs:
- test-native
runs-on: ubuntu-latest
strategy:
matrix:
arch:
- armhf
- unstable-ppc
cc:
- gcc
- clang
env:
CC: ${{ matrix.cc }}
steps:
- name: Register qemu-user-static
run: |
docker run --rm --privileged multiarch/qemu-user-static:register --reset
- uses: actions/checkout@v2
with:
submodules: true
- name: Cache ccache
uses: actions/cache@v2
env:
cache-name: cache-ccache
with:
path: ~/ccache
key: v1-${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.cc }}-${{ env.GITHUB_WORKFLOW }}-${{ matrix.arch }}
- name: Cache pip
uses: actions/cache@v2
env:
cache-name: cache-python-pip
with:
path: ~/.cache/pip
key: v1-python-pip
- name: Run tests in container
run: |
docker run --rm -e CI -e CC -e PQCLEAN_ONLY_SCHEMES=rainbowVc-cyclic-compressed -v $PWD:$PWD -w $PWD -v ~/ccache:/ccache pqclean/ci-container:${{ matrix.arch }} /bin/bash -c "\
export CCACHE_NOSTATS=1 && \
export CCACHE_DIR=/ccache && \
export CCACHE_SLOPPINESS=include_file_mtime && \
export CC=\"ccache $CC\" && \
pip3 install -U -r requirements.txt && \
cd test && \
python3 -m pytest --verbose --numprocesses=auto"
test-windows:
needs:
- test-native
strategy:
matrix:
bits:
- 64
- 32
env:
PQCLEAN_ONLY_SCHEMES: rainbowVc-cyclic-compressed
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Setup astyle
run: |
# Setup strong crypto
Set-ItemProperty -Path "HKLM:\\SOFTWARE\\Wow6432Node\\Microsoft\\.NetFramework\\v4.0.30319" -Name 'SchUseStrongCrypto' -Value '1' -Type DWord
Set-ItemProperty -Path "HKLM:\\SOFTWARE\\Microsoft\\.NetFramework\\v4.0.30319" -Name "SchUseStrongCrypto" -Value '1' -Type DWord
Invoke-WebRequest -OutFile "test\\astyle.exe" "https://rded.nl/pqclean/AStyle.exe"
shell: powershell
- name: Setup Python
uses: actions/setup-python@main
with:
python-version: "3.x"
- name: Install python requirements
run: python -m pip install -U -r requirements.txt
- name: Run tests
run: |
call "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Auxiliary\\Build\\vcvars${{ matrix.bits }}.bat"
cd test
python -m pytest --verbose --numprocesses=auto
shell: cmd
test-macos:
needs:
- test-native
env:
PQCLEAN_ONLY_SCHEMES: rainbowVc-cyclic-compressed
CCACHE_NOSTATS: 1
CCACHE_SLOPPINESS: include_file_mtime
# XCode version
DEVELOPER_DIR: /Applications/Xcode_11.5.app/Contents/Developer
strategy:
matrix:
compiler:
- clang # XCode (Apple LLVM/Clang)
- gcc9 # GNU (Homebrew)
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Install astyle
run: |
brew install astyle
- name: Set up GCC9 compiler
run: 'export PATH="/usr/local/bin:$PATH" && export CC=gcc-9'
if: matrix.compiler == 'gcc9'
- name: Setup Python
uses: actions/setup-python@main
with:
python-version: "3.x"
- name: Install Python dependencies
run: python -m pip install -U -r requirements.txt
- name: Run tests
run: |
cd test
python -m pytest --verbose --numprocesses=auto


+ 20
- 0
crypto_sign/rainbowI-circumzenithal/META.yml 查看文件

@@ -0,0 +1,20 @@
name: "RAINBOW(16,36,32,32) - circumzenithal"
type: signature
claimed-nist-level: 1
length-public-key: 60192
length-secret-key: 103648
length-signature: 66
nistkat-sha256: 819bd33be86eea97c3da516b7dfbe4885ea7dfad6c44d196f5fd7c1c8b00b8a7
testvectors-sha256: 2cc6d4b3e394832f19ca312ba1ddefcdade1e105b348782d7c6f201635506307
principal-submitters:
- Jintai Ding
auxiliary-submitters:
- Ming-Shing Chen
- Matthias Kannwischer
- Jacques Patarin
- Albrecht Petzoldt
- Dieter Schmidt
- Bo-Yin Yang
implementations:
- name: clean
version: https://github.com/fast-crypto-lab/rainbow-submission-round2/commit/173ada0e077e1b9dbd8e4a78994f87acc0c92263

crypto_sign/rainbowIIIc-classic/clean/LICENSE → crypto_sign/rainbowI-circumzenithal/clean/LICENSE 查看文件


+ 21
- 0
crypto_sign/rainbowI-circumzenithal/clean/Makefile 查看文件

@@ -0,0 +1,21 @@
# This Makefile can be used with GNU Make or BSD Make

LIB=librainbowI-circumzenithal_clean.a

HEADERS = api.h blas_comm.h blas.h gf.h parallel_matrix_op.h rainbow_blas.h rainbow_config.h rainbow.h rainbow_keypair_computation.h rainbow_keypair.h utils_hash.h utils_prng.h
OBJECTS = blas_comm.o parallel_matrix_op.o rainbow.o rainbow_keypair.o rainbow_keypair_computation.o sign.o utils_hash.o utils_prng.o blas.o gf.o


CFLAGS=-O3 -Wall -Wconversion -Wextra -Wpedantic -Wvla -Werror -Wmissing-prototypes -Wredundant-decls -std=c99 -I../../../common $(EXTRAFLAGS)

all: $(LIB)

%.o: %.c $(HEADERS)
$(CC) $(CFLAGS) -c -o $@ $<

$(LIB): $(OBJECTS)
$(AR) -r $@ $(OBJECTS)

clean:
$(RM) $(OBJECTS)
$(RM) $(LIB)

+ 19
- 0
crypto_sign/rainbowI-circumzenithal/clean/Makefile.Microsoft_nmake 查看文件

@@ -0,0 +1,19 @@
# This Makefile can be used with Microsoft Visual Studio's nmake using the command:
# nmake /f Makefile.Microsoft_nmake

LIBRARY=librainbowI-circumzenithal_clean.lib
OBJECTS = blas_comm.obj parallel_matrix_op.obj rainbow.obj rainbow_keypair.obj rainbow_keypair_computation.obj sign.obj utils_hash.obj utils_prng.obj blas.obj gf.obj

CFLAGS=/nologo /O2 /I ..\..\..\common /W4 /WX

all: $(LIBRARY)

# Make sure objects are recompiled if headers change.
$(OBJECTS): *.h

$(LIBRARY): $(OBJECTS)
LIB.EXE /NOLOGO /WX /OUT:$@ $**

clean:
-DEL $(OBJECTS)
-DEL $(LIBRARY)

+ 32
- 0
crypto_sign/rainbowI-circumzenithal/clean/api.h 查看文件

@@ -0,0 +1,32 @@
#ifndef PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_API_H
#define PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_API_H

#include <stddef.h>
#include <stdint.h>

#define PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_CRYPTO_SECRETKEYBYTES 103648
#define PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_CRYPTO_PUBLICKEYBYTES 60192
#define PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_CRYPTO_BYTES 66
#define PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_CRYPTO_ALGNAME "RAINBOW(16,36,32,32) - circumzenithal"

int PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_crypto_sign_keypair(uint8_t *pk, uint8_t *sk);


int PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_crypto_sign_signature(
uint8_t *sig, size_t *siglen,
const uint8_t *m, size_t mlen, const uint8_t *sk);

int PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_crypto_sign_verify(
const uint8_t *sig, size_t siglen,
const uint8_t *m, size_t mlen, const uint8_t *pk);

int PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_crypto_sign(uint8_t *sm, size_t *smlen,
const uint8_t *m, size_t mlen,
const uint8_t *sk);

int PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_crypto_sign_open(uint8_t *m, size_t *mlen,
const uint8_t *sm, size_t smlen,
const uint8_t *pk);


#endif

+ 43
- 0
crypto_sign/rainbowI-circumzenithal/clean/blas.c 查看文件

@@ -0,0 +1,43 @@
#include "blas.h"
#include "gf.h"

#include <stddef.h>

void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_predicated_add(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, size_t _num_byte) {
uint8_t pr_u8 = (uint8_t) ((uint8_t) 0 - predicate);
for (size_t i = 0; i < _num_byte; i++) {
accu_b[i] ^= (a[i] & pr_u8);
}
}

void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_add(uint8_t *accu_b, const uint8_t *a, size_t _num_byte) {
for (size_t i = 0; i < _num_byte; i++) {
accu_b[i] ^= a[i];
}
}


void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_mul_scalar(uint8_t *a, uint8_t gf16_b, size_t _num_byte) {
uint8_t tmp;
for (size_t i = 0; i < _num_byte; i++) {
tmp = PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16_mul(a[i] & 0xF, gf16_b);
tmp |= (uint8_t) (PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16_mul(a[i] >> 4, gf16_b) << 4);
a[i] = tmp;
}
}

void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_madd(uint8_t *accu_c, const uint8_t *a, uint8_t gf16_b, size_t _num_byte) {
for (size_t i = 0; i < _num_byte; i++) {
accu_c[i] ^= PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16_mul(a[i] & 0xF, gf16_b);
accu_c[i] ^= (uint8_t) (PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16_mul(a[i] >> 4, gf16_b) << 4);
}
}

uint8_t PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_dot(const uint8_t *a, const uint8_t *b, size_t _num_byte) {
uint8_t r = 0;
for (size_t i = 0; i < _num_byte; i++) {
r ^= PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16_mul(a[i], b[i]);
}
return r;
}


+ 20
- 0
crypto_sign/rainbowI-circumzenithal/clean/blas.h 查看文件

@@ -0,0 +1,20 @@
#ifndef _BLAS_H_
#define _BLAS_H_
/// @file blas.h
/// @brief Functions for implementing basic linear algebra functions.
///

#include "rainbow_config.h"
#include <stddef.h>
#include <stdint.h>

void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_predicated_add(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, size_t _num_byte);
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_add(uint8_t *accu_b, const uint8_t *a, size_t _num_byte);


void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_madd(uint8_t *accu_c, const uint8_t *a, uint8_t gf16_b, size_t _num_byte);
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_mul_scalar(uint8_t *a, uint8_t gf16_b, size_t _num_byte);
uint8_t PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_dot(const uint8_t *a, const uint8_t *b, size_t _num_byte);


#endif // _BLAS_H_

crypto_sign/rainbowIa-cyclic-compressed/clean/blas_comm.c → crypto_sign/rainbowI-circumzenithal/clean/blas_comm.c 查看文件

@@ -10,7 +10,7 @@
#include <stdint.h>
#include <string.h>

void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte) {
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte) {
for (size_t i = 0; i < _num_byte; i++) {
b[i] = 0;
}
@@ -22,7 +22,7 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_set_zero(uint8_t *b, unsigne
/// @param[in] i - the index in the vector a.
/// @return the value of the element.
///
uint8_t PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned int i) {
uint8_t PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned int i) {
uint8_t r = a[i >> 1];
uint8_t r0 = r & 0xf;
uint8_t r1 = r >> 4;
@@ -37,7 +37,7 @@ uint8_t PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_get_ele(const uint8_t *a,
/// @param[in] v - the value for the i-th element in vector a.
/// @return the value of the element.
///
static uint8_t PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_set_ele(uint8_t *a, unsigned int i, uint8_t v) {
static uint8_t PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_set_ele(uint8_t *a, unsigned int i, uint8_t v) {
uint8_t m = (uint8_t)(0xf ^ (-((int8_t)i & 1))); /// 1--> 0xf0 , 0--> 0x0f
uint8_t ai_remaining = (uint8_t)(a[i >> 1] & (~m)); /// erase
a[i >> 1] = (uint8_t)(ai_remaining | (m & (v << 4)) | (m & v & 0xf)); /// set
@@ -45,22 +45,22 @@ static uint8_t PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_set_ele(uint8_t *a,
}

static void gf16mat_prod_ref(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b) {
PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_set_zero(c, n_A_vec_byte);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_set_zero(c, n_A_vec_byte);
for (unsigned int i = 0; i < n_A_width; i++) {
uint8_t bb = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_get_ele(b, i);
PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_madd(c, matA, bb, n_A_vec_byte);
uint8_t bb = PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_get_ele(b, i);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_madd(c, matA, bb, n_A_vec_byte);
matA += n_A_vec_byte;
}
}

void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec) {
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec) {
unsigned int n_vec_byte = (len_vec + 1) / 2;
for (unsigned int k = 0; k < len_vec; k++) {
PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_set_zero(c, n_vec_byte);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_set_zero(c, n_vec_byte);
const uint8_t *bk = b + n_vec_byte * k;
for (unsigned int i = 0; i < len_vec; i++) {
uint8_t bb = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_get_ele(bk, i);
PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_madd(c, a + n_vec_byte * i, bb, n_vec_byte);
uint8_t bb = PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_get_ele(bk, i);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_madd(c, a + n_vec_byte * i, bb, n_vec_byte);
}
c += n_vec_byte;
}
@@ -74,19 +74,19 @@ static unsigned int gf16mat_gauss_elim_ref(uint8_t *mat, unsigned int h, unsigne
uint8_t *ai = mat + n_w_byte * i;
for (unsigned int j = i + 1; j < h; j++) {
uint8_t *aj = mat + n_w_byte * j;
PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_predicated_add(ai + offset_byte, 1 ^ PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16_is_nonzero(PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_get_ele(ai, i)), aj + offset_byte, n_w_byte - offset_byte);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_predicated_add(ai + offset_byte, 1 ^ PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16_is_nonzero(PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_get_ele(ai, i)), aj + offset_byte, n_w_byte - offset_byte);
}
uint8_t pivot = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_get_ele(ai, i);
r8 &= PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16_is_nonzero(pivot);
pivot = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16_inv(pivot);
uint8_t pivot = PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_get_ele(ai, i);
r8 &= PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16_is_nonzero(pivot);
pivot = PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16_inv(pivot);
offset_byte = (i + 1) >> 1;
PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_mul_scalar(ai + offset_byte, pivot, n_w_byte - offset_byte);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_mul_scalar(ai + offset_byte, pivot, n_w_byte - offset_byte);
for (unsigned int j = 0; j < h; j++) {
if (i == j) {
continue;
}
uint8_t *aj = mat + n_w_byte * j;
PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_madd(aj + offset_byte, ai + offset_byte, PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_get_ele(aj, i), n_w_byte - offset_byte);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_madd(aj + offset_byte, ai + offset_byte, PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_get_ele(aj, i), n_w_byte - offset_byte);
}
}
return r8;
@@ -97,11 +97,11 @@ static unsigned int gf16mat_solve_linear_eq_ref(uint8_t *sol, const uint8_t *inp
unsigned int n_byte = (n + 1) >> 1;
for (unsigned int i = 0; i < n; i++) {
memcpy(mat + i * (n_byte + 1), inp_mat + i * n_byte, n_byte);
mat[i * (n_byte + 1) + n_byte] = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_get_ele(c_terms, i);
mat[i * (n_byte + 1) + n_byte] = PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_get_ele(c_terms, i);
}
unsigned int r8 = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_gauss_elim(mat, n, n + 2);
unsigned int r8 = PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16mat_gauss_elim(mat, n, n + 2);
for (unsigned int i = 0; i < n; i++) {
PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_set_ele(sol, i, mat[i * (n_byte + 1) + n_byte]);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_set_ele(sol, i, mat[i * (n_byte + 1) + n_byte]);
}
return r8;
}
@@ -117,17 +117,17 @@ static inline void gf16mat_submat(uint8_t *mat2, unsigned int w2, unsigned int s
}
}

unsigned int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer) {
unsigned int PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer) {
unsigned int n_w_byte = (H + 1) / 2;

uint8_t *aa = buffer;
for (unsigned int i = 0; i < H; i++) {
uint8_t *ai = aa + i * 2 * n_w_byte;
PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_set_zero(ai, 2 * n_w_byte);
PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_add(ai, a + i * n_w_byte, n_w_byte);
PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_set_ele(ai + n_w_byte, i, 1);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_set_zero(ai, 2 * n_w_byte);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_add(ai, a + i * n_w_byte, n_w_byte);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_set_ele(ai + n_w_byte, i, 1);
}
unsigned int r8 = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_gauss_elim(aa, H, 2 * H);
unsigned int r8 = PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16mat_gauss_elim(aa, H, 2 * H);
gf16mat_submat(inv_a, H, H, aa, 2 * H, H);
return r8;
}
@@ -138,15 +138,15 @@ unsigned int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_inv(uint8_t *inv_a,
#define gf16mat_gauss_elim_impl gf16mat_gauss_elim_ref
#define gf16mat_solve_linear_eq_impl gf16mat_solve_linear_eq_ref

void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b) {
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b) {
gf16mat_prod_impl(c, matA, n_A_vec_byte, n_A_width, b);
}

unsigned int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w) {
unsigned int PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w) {
return gf16mat_gauss_elim_impl(mat, h, w);
}

unsigned int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n) {
unsigned int PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n) {
return gf16mat_solve_linear_eq_impl(sol, inp_mat, c_terms, n);
}


crypto_sign/rainbowIa-cyclic-compressed/clean/blas_comm.h → crypto_sign/rainbowI-circumzenithal/clean/blas_comm.h 查看文件

@@ -12,7 +12,7 @@
/// @param[in,out] b - the vector b.
/// @param[in] _num_byte - number of bytes for the vector b.
///
void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte);
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte);

/// @brief get an element from GF(16) vector .
///
@@ -20,7 +20,7 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_set_zero(uint8_t *b, unsigne
/// @param[in] i - the index in the vector a.
/// @return the value of the element.
///
uint8_t PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned int i);
uint8_t PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned int i);

/// @brief matrix-matrix multiplication: c = a * b , in GF(16)
///
@@ -29,7 +29,7 @@ uint8_t PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_get_ele(const uint8_t *a,
/// @param[in] b - a matrix b.
/// @param[in] len_vec - the length of column vectors.
///
void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec);
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec);

/// @brief Gauss elimination for a matrix, in GF(16)
///
@@ -38,7 +38,7 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_mul(uint8_t *c, const uint8
/// @param[in] w - the width of the matrix.
/// @return 1(true) if success. 0(false) if the matrix is singular.
///
unsigned int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w);
unsigned int PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w);

/// @brief Solving linear equations, in GF(16)
///
@@ -48,7 +48,7 @@ unsigned int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_gauss_elim(uint8_t
/// @param[in] n - the number of equations.
/// @return 1(true) if success. 0(false) if the matrix is singular.
///
unsigned int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n);
unsigned int PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n);

/// @brief Computing the inverse matrix, in GF(16)
///
@@ -58,7 +58,7 @@ unsigned int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_solve_linear_eq(uin
/// @param[in] buffer - The buffer for computations. it has to be as large as 2 input matrixes.
/// @return 1(true) if success. 0(false) if the matrix is singular.
///
unsigned int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer);
unsigned int PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer);

/// @brief matrix-vector multiplication: c = matA * b , in GF(16)
///
@@ -68,7 +68,7 @@ unsigned int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_inv(uint8_t *inv_a,
/// @param[in] n_A_width - the width of matrix A.
/// @param[in] b - the vector b.
///
void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b);
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b);


#endif // _BLAS_COMM_H_

crypto_sign/rainbowIa-cyclic-compressed/clean/gf.c → crypto_sign/rainbowI-circumzenithal/clean/gf.c 查看文件

@@ -17,7 +17,7 @@ static inline uint8_t gf4_squ(uint8_t a) {
}

//// gf16 := gf4[y]/y^2+y+x
uint8_t PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16_mul(uint8_t a, uint8_t b) {
uint8_t PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16_mul(uint8_t a, uint8_t b) {
uint8_t a0 = a & 3;
uint8_t a1 = (a >> 2);
uint8_t b0 = b & 3;
@@ -37,18 +37,18 @@ static inline uint8_t gf16_squ(uint8_t a) {
return (uint8_t)((a1 << 2) ^ a1squ_x2 ^ gf4_squ(a0));
}

uint8_t PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16_is_nonzero(uint8_t a) {
uint8_t PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16_is_nonzero(uint8_t a) {
unsigned int a4 = a & 0xf;
unsigned int r = ((unsigned int)0) - a4;
r >>= 4;
return r & 1;
}

uint8_t PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16_inv(uint8_t a) {
uint8_t PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16_inv(uint8_t a) {
uint8_t a2 = gf16_squ(a);
uint8_t a4 = gf16_squ(a2);
uint8_t a8 = gf16_squ(a4);
uint8_t a6 = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16_mul(a4, a2);
return PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16_mul(a8, a6);
uint8_t a6 = PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16_mul(a4, a2);
return PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16_mul(a8, a6);
}


+ 18
- 0
crypto_sign/rainbowI-circumzenithal/clean/gf.h 查看文件

@@ -0,0 +1,18 @@
#ifndef _GF16_H_
#define _GF16_H_

#include "rainbow_config.h"
#include <stdint.h>

/// @file gf16.h
/// @brief Library for arithmetics in GF(16) and GF(256)
///

uint8_t PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16_mul(uint8_t a, uint8_t b);


uint8_t PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16_is_nonzero(uint8_t a);
uint8_t PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16_inv(uint8_t a);


#endif // _GF16_H_

+ 182
- 0
crypto_sign/rainbowI-circumzenithal/clean/parallel_matrix_op.c 查看文件

@@ -0,0 +1,182 @@
/// @file parallel_matrix_op.c
/// @brief the standard implementations for functions in parallel_matrix_op.h
///
/// the standard implementations for functions in parallel_matrix_op.h
///

#include "parallel_matrix_op.h"
#include "blas.h"
#include "blas_comm.h"

///
/// @brief Calculate the corresponding index in an array for an upper-triangle(UT) matrix.
///
/// @param[in] i_row - the i-th row in an upper-triangle matrix.
/// @param[in] j_col - the j-th column in an upper-triangle matrix.
/// @param[in] dim - the dimension of the upper-triangle matrix, i.e., an dim x dim matrix.
/// @return the corresponding index in an array storage.
///
unsigned int PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_idx_of_trimat(unsigned int i_row, unsigned int j_col, unsigned int dim) {
return (dim + dim - i_row + 1) * i_row / 2 + j_col - i_row;
}

///
/// @brief Calculate the corresponding index in an array for an upper-triangle or lower-triangle matrix.
///
/// @param[in] i_row - the i-th row in a triangle matrix.
/// @param[in] j_col - the j-th column in a triangle matrix.
/// @param[in] dim - the dimension of the triangle matrix, i.e., an dim x dim matrix.
/// @return the corresponding index in an array storage.
///
static inline unsigned int idx_of_2trimat(unsigned int i_row, unsigned int j_col, unsigned int n_var) {
if (i_row > j_col) {
return PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_idx_of_trimat(j_col, i_row, n_var);
}
return PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_idx_of_trimat(i_row, j_col, n_var);
}

void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned int Awidth, unsigned int size_batch) {
unsigned char *runningC = btriC;
unsigned int Aheight = Awidth;
for (unsigned int i = 0; i < Aheight; i++) {
for (unsigned int j = 0; j < i; j++) {
unsigned int idx = PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_idx_of_trimat(j, i, Aheight);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_add(btriC + idx * size_batch, bA + size_batch * (i * Awidth + j), size_batch);
}
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_add(runningC, bA + size_batch * (i * Awidth + i), size_batch * (Aheight - i));
runningC += size_batch * (Aheight - i);
}
}

void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) {
unsigned int Awidth = Bheight;
unsigned int Aheight = Awidth;
for (unsigned int i = 0; i < Aheight; i++) {
for (unsigned int j = 0; j < Bwidth; j++) {
for (unsigned int k = 0; k < Bheight; k++) {
if (k < i) {
continue;
}
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_madd(bC, &btriA[(k - i) * size_batch], PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch);
}
bC += size_batch;
}
btriA += (Aheight - i) * size_batch;
}
}

void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, const unsigned char *btriA,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) {
unsigned int Aheight = Bheight;
for (unsigned int i = 0; i < Aheight; i++) {
for (unsigned int j = 0; j < Bwidth; j++) {
for (unsigned int k = 0; k < Bheight; k++) {
if (i < k) {
continue;
}
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_madd(bC, &btriA[size_batch * (PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_idx_of_trimat(k, i, Aheight))], PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch);
}
bC += size_batch;
}
}
}

void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) {
unsigned int Aheight = Bheight;
for (unsigned int i = 0; i < Aheight; i++) {
for (unsigned int j = 0; j < Bwidth; j++) {
for (unsigned int k = 0; k < Bheight; k++) {
if (i == k) {
continue;
}
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_madd(bC, &btriA[size_batch * (idx_of_2trimat(i, k, Aheight))], PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch);
}
bC += size_batch;
}
}
}

void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_matTr_madd_gf16(unsigned char *bC, const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth,
const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch) {
unsigned int Atr_height = Awidth;
unsigned int Atr_width = Aheight;
for (unsigned int i = 0; i < Atr_height; i++) {
for (unsigned int j = 0; j < Atr_width; j++) {
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_madd(bC, &bB[j * Bwidth * size_batch], PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_get_ele(&A_to_tr[size_Acolvec * i], j), size_batch * Bwidth);
}
bC += size_batch * Bwidth;
}
}

void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) {
const unsigned char *bA = bA_to_tr;
unsigned int Aheight = Awidth_before_tr;
for (unsigned int i = 0; i < Aheight; i++) {
for (unsigned int j = 0; j < Bwidth; j++) {
for (unsigned int k = 0; k < Bheight; k++) {
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_madd(bC, &bA[size_batch * (i + k * Aheight)], PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch);
}
bC += size_batch;
}
}
}

void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned int Aheight,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) {
unsigned int Awidth = Bheight;
for (unsigned int i = 0; i < Aheight; i++) {
for (unsigned int j = 0; j < Bwidth; j++) {
for (unsigned int k = 0; k < Bheight; k++) {
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_madd(bC, &bA[k * size_batch], PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch);
}
bC += size_batch;
}
bA += (Awidth) * size_batch;
}
}

void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned int dim_y, const unsigned char *mat,
const unsigned char *x, unsigned int dim_x, unsigned int size_batch) {
unsigned char tmp[128];

unsigned char _x[128];
for (unsigned int i = 0; i < dim_x; i++) {
_x[i] = PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_get_ele(x, i);
}
unsigned char _y[128];
for (unsigned int i = 0; i < dim_y; i++) {
_y[i] = PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_get_ele(y, i);
}

PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_set_zero(z, size_batch);
for (unsigned int i = 0; i < dim_y; i++) {
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_set_zero(tmp, size_batch);
for (unsigned int j = 0; j < dim_x; j++) {
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_madd(tmp, mat, _x[j], size_batch);
mat += size_batch;
}
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_madd(z, tmp, _y[i], size_batch);
}
}

void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch) {
unsigned char tmp[256];

unsigned char _x[256];
for (unsigned int i = 0; i < dim; i++) {
_x[i] = PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_get_ele(x, i);
}

PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_set_zero(y, size_batch);
for (unsigned int i = 0; i < dim; i++) {
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_set_zero(tmp, size_batch);
for (unsigned int j = i; j < dim; j++) {
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_madd(tmp, trimat, _x[j], size_batch);
trimat += size_batch;
}
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_madd(y, tmp, _x[i], size_batch);
}
}

+ 260
- 0
crypto_sign/rainbowI-circumzenithal/clean/parallel_matrix_op.h 查看文件

@@ -0,0 +1,260 @@
#ifndef _P_MATRIX_OP_H_
#define _P_MATRIX_OP_H_
/// @file parallel_matrix_op.h
/// @brief Librarys for operations of batched matrixes.
///
///

//////////////// Section: triangle matrix <-> rectangle matrix ///////////////////////////////////

///
/// @brief Calculate the corresponding index in an array for an upper-triangle(UT) matrix.
///
/// @param[in] i_row - the i-th row in an upper-triangle matrix.
/// @param[in] j_col - the j-th column in an upper-triangle matrix.
/// @param[in] dim - the dimension of the upper-triangle matrix, i.e., an dim x dim matrix.
/// @return the corresponding index in an array storage.
///
unsigned int PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_idx_of_trimat(unsigned int i_row, unsigned int j_col, unsigned int dim);

///
/// @brief Upper trianglize a rectangle matrix to the corresponding upper-trangle matrix.
///
/// @param[out] btriC - the batched upper-trianglized matrix C.
/// @param[in] bA - a batched retangle matrix A.
/// @param[in] bwidth - the width of the batched matrix A, i.e., A is a Awidth x Awidth matrix.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned int Awidth, unsigned int size_batch);

//////////////////// Section: matrix multiplications ///////////////////////////////

///
/// @brief bC += btriA * B , in GF(16)
///
/// @param[out] bC - the batched matrix C.
/// @param[in] btriA - a batched UT matrix A.
/// @param[in] B - a column-major matrix B.
/// @param[in] Bheight - the height of B.
/// @param[in] size_Bcolvec - the size of the column vector in B.
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);

///
/// @brief bC += btriA * B , in GF(256)
///
/// @param[out] bC - the batched matrix C.
/// @param[in] btriA - a batched UT matrix A.
/// @param[in] B - a column-major matrix B.
/// @param[in] Bheight - the height of B.
/// @param[in] size_Bcolvec - the size of the column vector in B.
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);

///
/// @brief bC += btriA^Tr * B , in GF(16)
///
/// @param[out] bC - the batched matrix C.
/// @param[in] btriA - a batched UT matrix A. A will be transposed while multiplying.
/// @param[in] B - a column-major matrix B.
/// @param[in] Bheight - the height of B.
/// @param[in] size_Bcolvec - the size of the column vector in B.
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, const unsigned char *btriA,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);

///
/// @brief bC += btriA^Tr * B , in GF(256)
///
/// @param[out] bC - the batched matrix C.
/// @param[in] btriA - a batched UT matrix A, which will be transposed while multiplying.
/// @param[in] B - a column-major matrix B.
/// @param[in] Bheight - the height of B.
/// @param[in] size_Bcolvec - the size of the column vector in B.
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_trimatTr_madd_gf256(unsigned char *bC, const unsigned char *btriA,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);

///
/// @brief bC += (btriA + btriA^Tr) *B , in GF(16)
///
/// @param[out] bC - the batched matrix C.
/// @param[in] btriA - a batched UT matrix A. The operand for multiplication is (btriA + btriA^Tr).
/// @param[in] B - a column-major matrix B.
/// @param[in] Bheight - the height of B.
/// @param[in] size_Bcolvec - the size of the column vector in B.
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);

///
/// @brief bC += (btriA + btriA^Tr) *B , in GF(256)
///
/// @param[out] bC - the batched matrix C.
/// @param[in] btriA - a batched UT matrix A. The operand for multiplication is (btriA + btriA^Tr).
/// @param[in] B - a column-major matrix B.
/// @param[in] Bheight - the height of B.
/// @param[in] size_Bcolvec - the size of the column vector in B.
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);

///
/// @brief bC += A^Tr * bB , in GF(16)
///
/// @param[out] bC - the batched matrix C.
/// @param[in] A_to_tr - a column-major matrix A. The operand for multiplication is A^Tr.
/// @param[in] Aheight - the height of A.
/// @param[in] size_Acolvec - the size of a column vector in A.
/// @param[in] Awidth - the width of A.
/// @param[in] bB - a batched matrix B.
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_matTr_madd_gf16(unsigned char *bC,
const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth,
const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch);

///
/// @brief bC += A^Tr * bB , in GF(256)
///
/// @param[out] bC - the batched matrix C.
/// @param[in] A_to_tr - a column-major matrix A. The operand for multiplication is A^Tr.
/// @param[in] Aheight - the height of A.
/// @param[in] size_Acolvec - the size of a column vector in A.
/// @param[in] Awidth - the width of A.
/// @param[in] bB - a batched matrix B.
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_matTr_madd_gf256(unsigned char *bC,
const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth,
const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch);

///
/// @brief bC += bA^Tr * B , in GF(16)
///
/// @param[out] bC - the batched matrix C.
/// @param[in] bA_to_tr - a batched matrix A. The operand for multiplication is (bA^Tr).
/// @param[in] Awidth_befor_tr - the width of A.
/// @param[in] B - a column-major matrix B.
/// @param[in] Bheight - the height of B.
/// @param[in] size_Bcolvec - the size of the column vector in B.
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);

///
/// @brief bC += bA^Tr * B , in GF(256)
///
/// @param[out] bC - the batched matrix C.
/// @param[in] bA_to_tr - a batched matrix A. The operand for multiplication is (bA^Tr).
/// @param[in] Awidth_befor_tr - the width of A.
/// @param[in] B - a column-major matrix B.
/// @param[in] Bheight - the height of B.
/// @param[in] size_Bcolvec - the size of the column vector in B.
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);

///
/// @brief bC += bA * B , in GF(16)
///
/// @param[out] bC - the batched matrix C.
/// @param[in] bA - a batched matrix A.
/// @param[in] Aheigh - the height of A.
/// @param[in] B - a column-major matrix B.
/// @param[in] Bheight - the height of B.
/// @param[in] size_Bcolvec - the size of the column vector in B.
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned int Aheight,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);

///
/// @brief bC += bA * B , in GF(256)
///
/// @param[out] bC - the batched matrix C.
/// @param[in] bA - a batched matrix A.
/// @param[in] Aheigh - the height of A.
/// @param[in] B - a column-major matrix B.
/// @param[in] Bheight - the height of B.
/// @param[in] size_Bcolvec - the size of the column vector in B.
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned int Aheight,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);

//////////////////// Section: "quadratric" matrix evaluation ///////////////////////////////

///
/// @brief y = x^Tr * trimat * x , in GF(16)
///
/// @param[out] y - the returned batched element y.
/// @param[in] trimat - a batched matrix.
/// @param[in] x - an input vector x.
/// @param[in] dim - the dimension of matrix trimat (and x).
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch);

///
/// @brief y = x^Tr * trimat * x , in GF(256)
///
/// @param[out] y - the returned batched element y.
/// @param[in] trimat - a batched matrix.
/// @param[in] x - an input vector x.
/// @param[in] dim - the dimension of matrix trimat (and x).
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch);

///
/// @brief z = y^Tr * mat * x , in GF(16)
///
/// @param[out] z - the returned batched element z.
/// @param[in] y - an input vector y.
/// @param[in] dim_y - the length of y.
/// @param[in] mat - a batched matrix.
/// @param[in] x - an input vector x.
/// @param[in] dim_x - the length of x.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned int dim_y,
const unsigned char *mat, const unsigned char *x, unsigned int dim_x, unsigned int size_batch);

///
/// @brief z = y^Tr * mat * x , in GF(256)
///
/// @param[out] z - the returned batched element z.
/// @param[in] y - an input vector y.
/// @param[in] dim_y - the length of y.
/// @param[in] mat - a batched matrix.
/// @param[in] x - an input vector x.
/// @param[in] dim_x - the length of x.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned int dim_y,
const unsigned char *mat, const unsigned char *x, unsigned int dim_x, unsigned int size_batch);

#endif // _P_MATRIX_OP_H_

crypto_sign/rainbowIa-classic/clean/rainbow.c → crypto_sign/rainbowI-circumzenithal/clean/rainbow.c 查看文件

@@ -16,7 +16,7 @@

#define MAX_ATTEMPT_FRMAT 128

int PQCLEAN_RAINBOWIACLASSIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t *sk, const uint8_t *_digest) {
int PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_rainbow_sign(uint8_t *signature, const sk_t *sk, const uint8_t *_digest) {
uint8_t mat_l1[_O1 * _O1_BYTE];
uint8_t mat_l2[_O2 * _O2_BYTE];
uint8_t mat_buffer[2 * _MAX_O * _MAX_O_BYTE];
@@ -27,8 +27,8 @@ int PQCLEAN_RAINBOWIACLASSIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t *
memcpy(prng_preseed, sk->sk_seed, LEN_SKSEED);
memcpy(prng_preseed + LEN_SKSEED, _digest, _HASH_LEN); // prng_preseed = sk_seed || digest
uint8_t prng_seed[_HASH_LEN];
PQCLEAN_RAINBOWIACLASSIC_CLEAN_hash_msg(prng_seed, _HASH_LEN, prng_preseed, _HASH_LEN + LEN_SKSEED);
PQCLEAN_RAINBOWIACLASSIC_CLEAN_prng_set(&prng_sign, prng_seed, _HASH_LEN); // seed = H( sk_seed || digest )
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_hash_msg(prng_seed, _HASH_LEN, prng_preseed, _HASH_LEN + LEN_SKSEED);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_prng_set(&prng_sign, prng_seed, _HASH_LEN); // seed = H( sk_seed || digest )
for (unsigned int i = 0; i < LEN_SKSEED + _HASH_LEN; i++) {
prng_preseed[i] ^= prng_preseed[i]; // clean
}
@@ -44,7 +44,7 @@ int PQCLEAN_RAINBOWIACLASSIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t *
if (MAX_ATTEMPT_FRMAT <= n_attempt) {
break;
}
PQCLEAN_RAINBOWIACLASSIC_CLEAN_prng_gen(&prng_sign, vinegar, _V1_BYTE); // generating vinegars
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_prng_gen(&prng_sign, vinegar, _V1_BYTE); // generating vinegars
gfmat_prod(mat_l1, sk->l1_F2, _O1 * _O1_BYTE, _V1, vinegar); // generating the linear equations for layer 1
l1_succ = gfmat_inv(mat_l1, mat_l1, _O1, mat_buffer); // check if the linear equation solvable
n_attempt++;
@@ -65,7 +65,7 @@ int PQCLEAN_RAINBOWIACLASSIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t *
uint8_t y[_PUB_M_BYTE];
uint8_t *x_v1 = vinegar;
uint8_t x_o1[_O1_BYTE];
uint8_t x_o2[_O1_BYTE];
uint8_t x_o2[_O2_BYTE];

uint8_t digest_salt[_HASH_LEN + _SALT_BYTE];
memcpy(digest_salt, _digest, _HASH_LEN);
@@ -79,31 +79,31 @@ int PQCLEAN_RAINBOWIACLASSIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t *
}
// The computation: H(digest||salt) --> z --S--> y --C-map--> x --T--> w

PQCLEAN_RAINBOWIACLASSIC_CLEAN_prng_gen(&prng_sign, salt, _SALT_BYTE); // roll the salt
PQCLEAN_RAINBOWIACLASSIC_CLEAN_hash_msg(_z, _PUB_M_BYTE, digest_salt, _HASH_LEN + _SALT_BYTE); // H(digest||salt)
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_prng_gen(&prng_sign, salt, _SALT_BYTE); // roll the salt
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_hash_msg(_z, _PUB_M_BYTE, digest_salt, _HASH_LEN + _SALT_BYTE); // H(digest||salt)

// y = S^-1 * z
memcpy(y, _z, _PUB_M_BYTE); // identity part of S
gfmat_prod(temp_o, sk->s1, _O1_BYTE, _O2, _z + _O1_BYTE);
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_add(y, temp_o, _O1_BYTE);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_add(y, temp_o, _O1_BYTE);

// Central Map:
// layer 1: calculate x_o1
memcpy(temp_o, r_l1_F1, _O1_BYTE);
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_add(temp_o, y, _O1_BYTE);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_add(temp_o, y, _O1_BYTE);
gfmat_prod(x_o1, mat_l1, _O1_BYTE, _O1, temp_o);

// layer 2: calculate x_o2
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_set_zero(temp_o, _O2_BYTE);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_set_zero(temp_o, _O2_BYTE);
gfmat_prod(temp_o, mat_l2_F2, _O2_BYTE, _O1, x_o1); // F2
batch_quad_trimat_eval(mat_l2, sk->l2_F5, x_o1, _O1, _O2_BYTE); // F5
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_add(temp_o, mat_l2, _O2_BYTE);
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_add(temp_o, r_l2_F1, _O2_BYTE); // F1
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_add(temp_o, y + _O1_BYTE, _O2_BYTE);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_add(temp_o, mat_l2, _O2_BYTE);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_add(temp_o, r_l2_F1, _O2_BYTE); // F1
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_add(temp_o, y + _O1_BYTE, _O2_BYTE);

// generate the linear equations of the 2nd layer
gfmat_prod(mat_l2, sk->l2_F6, _O2 * _O2_BYTE, _O1, x_o1); // F6
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_add(mat_l2, mat_l2_F3, _O2 * _O2_BYTE); // F3
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_add(mat_l2, mat_l2_F3, _O2 * _O2_BYTE); // F3
succ = gfmat_inv(mat_l2, mat_l2, _O2, mat_buffer);
gfmat_prod(x_o2, mat_l2, _O2_BYTE, _O2, temp_o); // solve l2 eqs

@@ -117,13 +117,13 @@ int PQCLEAN_RAINBOWIACLASSIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t *
memcpy(w + _V2_BYTE, x_o2, _O2_BYTE);
// Computing the t1 part.
gfmat_prod(y, sk->t1, _V1_BYTE, _O1, x_o1);
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_add(w, y, _V1_BYTE);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_add(w, y, _V1_BYTE);
// Computing the t4 part.
gfmat_prod(y, sk->t4, _V1_BYTE, _O2, x_o2);
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_add(w, y, _V1_BYTE);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_add(w, y, _V1_BYTE);
// Computing the t3 part.
gfmat_prod(y, sk->t3, _O1_BYTE, _O2, x_o2);
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_add(w + _V1_BYTE, y, _O1_BYTE);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_add(w + _V1_BYTE, y, _O1_BYTE);

memset(signature, 0, _SIGNATURE_BYTE); // set the output 0
// clean
@@ -141,12 +141,12 @@ int PQCLEAN_RAINBOWIACLASSIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t *
if (MAX_ATTEMPT_FRMAT <= n_attempt) {
return -1;
}
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_add(signature, w, _PUB_N_BYTE);
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_add(signature + _PUB_N_BYTE, salt, _SALT_BYTE);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_add(signature, w, _PUB_N_BYTE);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_add(signature + _PUB_N_BYTE, salt, _SALT_BYTE);
return 0;
}

int PQCLEAN_RAINBOWIACLASSIC_CLEAN_rainbow_verify(const uint8_t *digest, const uint8_t *signature, const pk_t *pk) {
int PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_rainbow_verify(const uint8_t *digest, const uint8_t *signature, const pk_t *pk) {
unsigned char digest_ck[_PUB_M_BYTE];
// public_map( digest_ck , pk , signature ); Evaluating the quadratic public polynomials.
batch_quad_trimat_eval(digest_ck, pk->pk, signature, _PUB_N, _PUB_M_BYTE);
@@ -155,7 +155,7 @@ int PQCLEAN_RAINBOWIACLASSIC_CLEAN_rainbow_verify(const uint8_t *digest, const u
unsigned char digest_salt[_HASH_LEN + _SALT_BYTE];
memcpy(digest_salt, digest, _HASH_LEN);
memcpy(digest_salt + _HASH_LEN, signature + _PUB_N_BYTE, _SALT_BYTE);
PQCLEAN_RAINBOWIACLASSIC_CLEAN_hash_msg(correct, _PUB_M_BYTE, digest_salt, _HASH_LEN + _SALT_BYTE); // H( digest || salt )
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_hash_msg(correct, _PUB_M_BYTE, digest_salt, _HASH_LEN + _SALT_BYTE); // H( digest || salt )

// check consistancy.
unsigned char cc = 0;
@@ -166,3 +166,8 @@ int PQCLEAN_RAINBOWIACLASSIC_CLEAN_rainbow_verify(const uint8_t *digest, const u
}


int PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_rainbow_verify_cyclic(const uint8_t *digest, const uint8_t *signature, const cpk_t *_pk) {
unsigned char pk[sizeof(pk_t) + 32];
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_cpk_to_pk((pk_t *)pk, _pk); // generating classic public key.
return PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_rainbow_verify(digest, signature, (pk_t *)pk);
}

crypto_sign/rainbowVc-cyclic/clean/rainbow.h → crypto_sign/rainbowI-circumzenithal/clean/rainbow.h 查看文件

@@ -16,7 +16,7 @@
/// @param[in] sk - the secret key.
/// @param[in] digest - the digest.
///
int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t *sk, const uint8_t *digest);
int PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_rainbow_sign(uint8_t *signature, const sk_t *sk, const uint8_t *digest);

///
/// @brief Verifying function.
@@ -26,7 +26,7 @@ int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t *s
/// @param[in] pk - the public key.
/// @return 0 for successful verified. -1 for failed verification.
///
int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_rainbow_verify(const uint8_t *digest, const uint8_t *signature, const pk_t *pk);
int PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_rainbow_verify(const uint8_t *digest, const uint8_t *signature, const pk_t *pk);


///
@@ -37,6 +37,6 @@ int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_rainbow_verify(const uint8_t *digest, const ui
/// @param[in] pk - the public key of cyclic rainbow.
/// @return 0 for successful verified. -1 for failed verification.
///
int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_rainbow_verify_cyclic(const uint8_t *digest, const uint8_t *signature, const cpk_t *pk);
int PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_rainbow_verify_cyclic(const uint8_t *digest, const uint8_t *signature, const cpk_t *pk);

#endif // _RAINBOW_H_

+ 32
- 0
crypto_sign/rainbowI-circumzenithal/clean/rainbow_blas.h 查看文件

@@ -0,0 +1,32 @@
#ifndef _RAINBOW_BLAS_H_
#define _RAINBOW_BLAS_H_
/// @file rainbow_blas.h
/// @brief Defining the functions used in rainbow.c acconding to the definitions in rainbow_config.h
///
/// Defining the functions used in rainbow.c acconding to the definitions in rainbow_config.h

#include "blas.h"
#include "blas_comm.h"
#include "parallel_matrix_op.h"
#include "rainbow_config.h"


#define gfv_get_ele PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_get_ele
#define gfv_mul_scalar PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_mul_scalar
#define gfv_madd PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16v_madd

#define gfmat_prod PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16mat_prod
#define gfmat_inv PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf16mat_inv

#define batch_trimat_madd PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_trimat_madd_gf16
#define batch_trimatTr_madd PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_trimatTr_madd_gf16
#define batch_2trimat_madd PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_2trimat_madd_gf16
#define batch_matTr_madd PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_matTr_madd_gf16
#define batch_bmatTr_madd PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_bmatTr_madd_gf16
#define batch_mat_madd PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_mat_madd_gf16

#define batch_quad_trimat_eval PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_quad_trimat_eval_gf16
#define batch_quad_recmat_eval PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_batch_quad_recmat_eval_gf16


#endif // _RAINBOW_BLAS_H_

crypto_sign/rainbowIa-cyclic-compressed/clean/rainbow_config.h → crypto_sign/rainbowI-circumzenithal/clean/rainbow_config.h 查看文件

@@ -7,7 +7,7 @@

#define _USE_GF16
#define _GFSIZE 16
#define _V1 32
#define _V1 36
#define _O1 32
#define _O2 32
#define _MAX_O 32

crypto_sign/rainbowVc-cyclic/clean/rainbow_keypair.c → crypto_sign/rainbowI-circumzenithal/clean/rainbow_keypair.c 查看文件

@@ -12,52 +12,81 @@
#include <stdlib.h>
#include <string.h>

static void generate_S_T(unsigned char *s_and_t, prng_t *prng0) {
PQCLEAN_RAINBOWVCCYCLIC_CLEAN_prng_gen(prng0, s_and_t, _O1_BYTE * _O2); // S1
s_and_t += _O1_BYTE * _O2;
PQCLEAN_RAINBOWVCCYCLIC_CLEAN_prng_gen(prng0, s_and_t, _V1_BYTE * _O1); // T1
s_and_t += _V1_BYTE * _O1;
PQCLEAN_RAINBOWVCCYCLIC_CLEAN_prng_gen(prng0, s_and_t, _V1_BYTE * _O2); // T2
s_and_t += _V1_BYTE * _O2;
PQCLEAN_RAINBOWVCCYCLIC_CLEAN_prng_gen(prng0, s_and_t, _O1_BYTE * _O2); // T3
static
void generate_S_T( unsigned char *s_and_t, prng_t *prng0 ) {
sk_t *_sk;
unsigned size;

size = sizeof(_sk->s1);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_prng_gen( prng0, s_and_t, size );
s_and_t += size;

size = sizeof(_sk->t1);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_prng_gen( prng0, s_and_t, size );
s_and_t += size;

size = sizeof(_sk->t4);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_prng_gen( prng0, s_and_t, size );
s_and_t += size;

size = sizeof(_sk->t3);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_prng_gen( prng0, s_and_t, size );
}

static unsigned int generate_l1_F12(unsigned char *sk, prng_t *prng0) {
unsigned int n_byte_generated = 0;
PQCLEAN_RAINBOWVCCYCLIC_CLEAN_prng_gen(prng0, sk, _O1_BYTE * N_TRIANGLE_TERMS(_V1)); // l1_F1
sk += _O1_BYTE * N_TRIANGLE_TERMS(_V1);
n_byte_generated += _O1_BYTE * N_TRIANGLE_TERMS(_V1);

PQCLEAN_RAINBOWVCCYCLIC_CLEAN_prng_gen(prng0, sk, _O1_BYTE * _V1 * _O1); // l1_F2
n_byte_generated += _O1_BYTE * _V1 * _O1;
static
unsigned generate_l1_F12( unsigned char *sk, prng_t *prng0 ) {
unsigned n_byte_generated = 0;
sk_t *_sk;
unsigned size;

size = sizeof(_sk->l1_F1);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_prng_gen( prng0, sk, size );
sk += size;
n_byte_generated += size;

size = sizeof(_sk->l1_F2);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_prng_gen( prng0, sk, size );
n_byte_generated += size;

return n_byte_generated;
}

static unsigned int generate_l2_F12356(unsigned char *sk, prng_t *prng0) {
unsigned int n_byte_generated = 0;

PQCLEAN_RAINBOWVCCYCLIC_CLEAN_prng_gen(prng0, sk, _O2_BYTE * N_TRIANGLE_TERMS(_V1)); // l2_F1
sk += _O2_BYTE * N_TRIANGLE_TERMS(_V1);
n_byte_generated += _O2_BYTE * N_TRIANGLE_TERMS(_V1);
static
unsigned generate_l2_F12356( unsigned char *sk, prng_t *prng0 ) {
unsigned n_byte_generated = 0;
sk_t *_sk;
unsigned size;

PQCLEAN_RAINBOWVCCYCLIC_CLEAN_prng_gen(prng0, sk, _O2_BYTE * _V1 * _O1); // l2_F2
sk += _O2_BYTE * _V1 * _O1;
n_byte_generated += _O2_BYTE * _V1 * _O1;
size = sizeof(_sk->l2_F1);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_prng_gen( prng0, sk, size );
sk += size;
n_byte_generated += size;

PQCLEAN_RAINBOWVCCYCLIC_CLEAN_prng_gen(prng0, sk, _O2_BYTE * _V1 * _O2); // l2_F3
sk += _O2_BYTE * _V1 * _O1;
n_byte_generated += _O2_BYTE * _V1 * _O1;
size = sizeof(_sk->l2_F2);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_prng_gen( prng0, sk, size );
sk += size;
n_byte_generated += size;

PQCLEAN_RAINBOWVCCYCLIC_CLEAN_prng_gen(prng0, sk, _O2_BYTE * N_TRIANGLE_TERMS(_O1)); // l2_F5
sk += _O2_BYTE * N_TRIANGLE_TERMS(_O1);
n_byte_generated += _O2_BYTE * N_TRIANGLE_TERMS(_O1);
size = sizeof(_sk->l2_F3);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_prng_gen( prng0, sk, size );
sk += size;
n_byte_generated += size;

PQCLEAN_RAINBOWVCCYCLIC_CLEAN_prng_gen(prng0, sk, _O2_BYTE * _O1 * _O2); // l2_F6
n_byte_generated += _O2_BYTE * _O1 * _O2;
size = sizeof(_sk->l2_F5);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_prng_gen( prng0, sk, size );
sk += size;
n_byte_generated += size;

size = sizeof(_sk->l2_F6);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_prng_gen( prng0, sk, size );
n_byte_generated += size;

return n_byte_generated;
}


static void generate_B1_B2(unsigned char *sk, prng_t *prng0) {
sk += generate_l1_F12(sk, prng0);
generate_l2_F12356(sk, prng0);
@@ -69,7 +98,7 @@ static void calculate_t4(unsigned char *t2_to_t4, const unsigned char *t1, const
unsigned char *t4 = t2_to_t4;
for (unsigned int i = 0; i < _O2; i++) { /// t3 width
gfmat_prod(temp, t1, _V1_BYTE, _O1, t3);
PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_add(t4, temp, _V1_BYTE);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_add(t4, temp, _V1_BYTE);
t4 += _V1_BYTE;
t3 += _O1_BYTE;
}
@@ -79,7 +108,7 @@ static void obsfucate_l1_polys(unsigned char *l1_polys, const unsigned char *l2_
unsigned char temp[_O1_BYTE + 32];
while (n_terms--) {
gfmat_prod(temp, s1, _O1_BYTE, _O2, l2_polys);
PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_add(l1_polys, temp, _O1_BYTE);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_gf256v_add(l1_polys, temp, _O1_BYTE);
l1_polys += _O1_BYTE;
l2_polys += _O2_BYTE;
}
@@ -89,14 +118,14 @@ static void obsfucate_l1_polys(unsigned char *l1_polys, const unsigned char *l2_


///////////////////// Cyclic //////////////////////////////////
void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_generate_keypair_cyclic(cpk_t *pk, sk_t *sk, const unsigned char *pk_seed, const unsigned char *sk_seed) {
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_generate_keypair_cyclic(cpk_t *pk, sk_t *sk, const unsigned char *pk_seed, const unsigned char *sk_seed) {
memcpy(pk->pk_seed, pk_seed, LEN_PKSEED);
memcpy(sk->sk_seed, sk_seed, LEN_SKSEED);

// prng for sk
prng_t prng;
prng_t *prng0 = &prng;
PQCLEAN_RAINBOWVCCYCLIC_CLEAN_prng_set(prng0, sk_seed, LEN_SKSEED);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_prng_set(prng0, sk_seed, LEN_SKSEED);
generate_S_T(sk->s1, prng0); // S,T: only a part of sk

unsigned char t2[sizeof(sk->t4)];
@@ -107,18 +136,18 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_generate_keypair_cyclic(cpk_t *pk, sk_t *sk,
sk_t inst_Qs;
sk_t *Qs = &inst_Qs;
prng_t *prng1 = &prng;
PQCLEAN_RAINBOWVCCYCLIC_CLEAN_prng_set(prng1, pk_seed, LEN_PKSEED);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_prng_set(prng1, pk_seed, LEN_PKSEED);
generate_B1_B2(Qs->l1_F1, prng1); // generating l1_Q1, l1_Q2, l2_Q1, l2_Q2, l2_Q3, l2_Q5, l2_Q6
obsfucate_l1_polys(Qs->l1_F1, Qs->l2_F1, N_TRIANGLE_TERMS(_V1), sk->s1);
obsfucate_l1_polys(Qs->l1_F2, Qs->l2_F2, _V1 * _O1, sk->s1);
// so far, the Qs contains l1_F1, l1_F2, l2_F1, l2_F2, l2_F3, l2_F5, l2_F6.

PQCLEAN_RAINBOWVCCYCLIC_CLEAN_calculate_F_from_Q(sk, Qs, sk); // calcuate the rest parts of secret key from Qs and S,T
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_calculate_F_from_Q(sk, Qs, sk); // calcuate the rest parts of secret key from Qs and S,T

unsigned char t4[sizeof(sk->t4)];
memcpy(t4, sk->t4, _V1_BYTE * _O2); // temporarily store t4
memcpy(sk->t4, t2, _V1_BYTE * _O2); // restore t2
PQCLEAN_RAINBOWVCCYCLIC_CLEAN_calculate_Q_from_F_cyclic(pk, sk, sk); // calculate the rest parts of public key: l1_Q3, l1_Q5, l1_Q6, l1_Q9, l2_Q9
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_calculate_Q_from_F_cyclic(pk, sk, sk); // calculate the rest parts of public key: l1_Q3, l1_Q5, l1_Q6, l1_Q9, l2_Q9
memcpy(sk->t4, t4, _V1_BYTE * _O2); // restore t4

obsfucate_l1_polys(pk->l1_Q3, Qs->l2_F3, _V1 * _O2, sk->s1);
@@ -132,7 +161,7 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_generate_keypair_cyclic(cpk_t *pk, sk_t *sk,



void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_cpk_to_pk(pk_t *rpk, const cpk_t *cpk) {
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_cpk_to_pk(pk_t *rpk, const cpk_t *cpk) {
// procedure: cpk_t --> extcpk_t --> pk_t

// convert from cpk_t to extcpk_t
@@ -140,7 +169,7 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_cpk_to_pk(pk_t *rpk, const cpk_t *cpk) {

// setup prng
prng_t prng0;
PQCLEAN_RAINBOWVCCYCLIC_CLEAN_prng_set(&prng0, cpk->pk_seed, LEN_SKSEED);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_prng_set(&prng0, cpk->pk_seed, LEN_SKSEED);

// generating parts of key with prng
generate_l1_F12(pk.l1_Q1, &prng0);
@@ -153,5 +182,5 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_cpk_to_pk(pk_t *rpk, const cpk_t *cpk) {
memcpy(pk.l2_Q9, cpk->l2_Q9, _O2_BYTE * N_TRIANGLE_TERMS(_O2));

// convert from extcpk_t to pk_t
PQCLEAN_RAINBOWVCCYCLIC_CLEAN_extcpk_to_pk(rpk, &pk);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_extcpk_to_pk(rpk, &pk);
}

crypto_sign/rainbowVc-cyclic/clean/rainbow_keypair.h → crypto_sign/rainbowI-circumzenithal/clean/rainbow_keypair.h 查看文件

@@ -77,7 +77,7 @@ typedef struct rainbow_secretkey_cyclic {
/// @param[in] pk_seed - seed for generating parts of public key.
/// @param[in] sk_seed - seed for generating secret key.
///
void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_generate_keypair_cyclic(cpk_t *pk, sk_t *sk, const unsigned char *pk_seed, const unsigned char *sk_seed);
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_generate_keypair_cyclic(cpk_t *pk, sk_t *sk, const unsigned char *pk_seed, const unsigned char *sk_seed);



@@ -89,6 +89,6 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_generate_keypair_cyclic(cpk_t *pk, sk_t *sk,
/// @param[out] pk - the classic public key.
/// @param[in] cpk - the cyclic public key.
///
void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_cpk_to_pk(pk_t *pk, const cpk_t *cpk);
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_cpk_to_pk(pk_t *pk, const cpk_t *cpk);

#endif // _RAINBOW_KEYPAIR_H_

crypto_sign/rainbowVc-cyclic-compressed/clean/rainbow_keypair_computation.c → crypto_sign/rainbowI-circumzenithal/clean/rainbow_keypair_computation.c 查看文件

@@ -11,12 +11,12 @@
#include <stdlib.h>
#include <string.h>

void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) {
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) {
const unsigned char *idx_l1 = cpk->l1_Q1;
const unsigned char *idx_l2 = cpk->l2_Q1;
for (unsigned int i = 0; i < _V1; i++) {
for (unsigned int j = i; j < _V1; j++) {
unsigned int pub_idx = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N);
unsigned int pub_idx = PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_idx_of_trimat(i, j, _PUB_N);
memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE);
memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE);
idx_l1 += _O1_BYTE;
@@ -27,7 +27,7 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cp
idx_l2 = cpk->l2_Q2;
for (unsigned int i = 0; i < _V1; i++) {
for (unsigned int j = _V1; j < _V1 + _O1; j++) {
unsigned int pub_idx = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N);
unsigned int pub_idx = PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_idx_of_trimat(i, j, _PUB_N);
memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE);
memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE);
idx_l1 += _O1_BYTE;
@@ -38,7 +38,7 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cp
idx_l2 = cpk->l2_Q3;
for (unsigned int i = 0; i < _V1; i++) {
for (unsigned int j = _V1 + _O1; j < _PUB_N; j++) {
unsigned int pub_idx = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N);
unsigned int pub_idx = PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_idx_of_trimat(i, j, _PUB_N);
memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE);
memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE);
idx_l1 += _O1_BYTE;
@@ -49,7 +49,7 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cp
idx_l2 = cpk->l2_Q5;
for (unsigned int i = _V1; i < _V1 + _O1; i++) {
for (unsigned int j = i; j < _V1 + _O1; j++) {
unsigned int pub_idx = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N);
unsigned int pub_idx = PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_idx_of_trimat(i, j, _PUB_N);
memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE);
memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE);
idx_l1 += _O1_BYTE;
@@ -60,7 +60,7 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cp
idx_l2 = cpk->l2_Q6;
for (unsigned int i = _V1; i < _V1 + _O1; i++) {
for (unsigned int j = _V1 + _O1; j < _PUB_N; j++) {
unsigned int pub_idx = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N);
unsigned int pub_idx = PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_idx_of_trimat(i, j, _PUB_N);
memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE);
memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE);
idx_l1 += _O1_BYTE;
@@ -71,7 +71,7 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cp
idx_l2 = cpk->l2_Q9;
for (unsigned int i = _V1 + _O1; i < _PUB_N; i++) {
for (unsigned int j = i; j < _PUB_N; j++) {
unsigned int pub_idx = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N);
unsigned int pub_idx = PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_idx_of_trimat(i, j, _PUB_N);
memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE);
memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE);
idx_l1 += _O1_BYTE;
@@ -119,7 +119,7 @@ static void calculate_F_from_Q_ref(sk_t *Fs, const sk_t *Qs, sk_t *Ts) {
memset(tempQ, 0, _O1 * _O1 * _O2_BYTE);
batch_matTr_madd(tempQ, Ts->t1, _V1, _V1_BYTE, _O1, Fs->l2_F2, _O1, _O2_BYTE); // t1_tr*(Q1_T1+Q2)
memcpy(Fs->l2_F5, Qs->l2_F5, _O2_BYTE * N_TRIANGLE_TERMS(_O1)); // F5
PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_UpperTrianglize(Fs->l2_F5, tempQ, _O1, _O2_BYTE); // UT( ... )
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_UpperTrianglize(Fs->l2_F5, tempQ, _O1, _O2_BYTE); // UT( ... )

batch_trimatTr_madd(Fs->l2_F2, Qs->l2_F1, Ts->t1, _V1, _V1_BYTE, _O1, _O2_BYTE); // F2 = Q1_T1 + Q2 + Q1^tr*t1

@@ -151,7 +151,7 @@ static void calculate_Q_from_F_cyclic_ref(cpk_t *Qs, const sk_t *Fs, const sk_t
memset(tempQ.l2_F2, 0, sizeof(tempQ.l2_F2));
batch_matTr_madd(tempQ.l2_F1, Ts->t1, _V1, _V1_BYTE, _O1, tempQ.l1_F2, _O1, _O1_BYTE); // T1tr*(F1*T1 + F2)
memset(Qs->l1_Q5, 0, _O1_BYTE * N_TRIANGLE_TERMS(_O1));
PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_UpperTrianglize(Qs->l1_Q5, tempQ.l2_F1, _O1, _O1_BYTE); // UT( ... ) // Q5
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_UpperTrianglize(Qs->l1_Q5, tempQ.l2_F1, _O1, _O1_BYTE); // UT( ... ) // Q5

/*
F1_T2 = F1 * t2
@@ -170,7 +170,7 @@ static void calculate_Q_from_F_cyclic_ref(cpk_t *Qs, const sk_t *Fs, const sk_t

memset(tempQ.l1_F2, 0, _O1_BYTE * _V1 * _O2); // should be F3. assuming: _O1 >= _O2
batch_matTr_madd(tempQ.l1_F2, t2, _V1, _V1_BYTE, _O2, Qs->l1_Q3, _O2, _O1_BYTE); // T2tr * ( F1_T2 + F2_T3 )
PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_UpperTrianglize(Qs->l1_Q9, tempQ.l1_F2, _O2, _O1_BYTE); // Q9
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_UpperTrianglize(Qs->l1_Q9, tempQ.l1_F2, _O2, _O1_BYTE); // Q9

batch_trimatTr_madd(Qs->l1_Q3, Fs->l1_F1, t2, _V1, _V1_BYTE, _O2, _O1_BYTE); // F1_F1T_T2 + F2_T3 // Q3

@@ -197,17 +197,17 @@ static void calculate_Q_from_F_cyclic_ref(cpk_t *Qs, const sk_t *Fs, const sk_t

batch_matTr_madd(tempQ.l2_F3, Ts->t3, _O1, _O1_BYTE, _O2, tempQ.l2_F6, _O2, _O2_BYTE); // T2tr*( ..... ) + T3tr*( ..... )
memset(Qs->l2_Q9, 0, _O2_BYTE * N_TRIANGLE_TERMS(_O2));
PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_UpperTrianglize(Qs->l2_Q9, tempQ.l2_F3, _O2, _O2_BYTE); // Q9
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_UpperTrianglize(Qs->l2_Q9, tempQ.l2_F3, _O2, _O2_BYTE); // Q9
}

// Choosing implementations depends on the macros: _BLAS_SSE_ and _BLAS_AVX2_
#define calculate_F_from_Q_impl calculate_F_from_Q_ref
#define calculate_Q_from_F_cyclic_impl calculate_Q_from_F_cyclic_ref

void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_calculate_F_from_Q(sk_t *Fs, const sk_t *Qs, sk_t *Ts) {
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_calculate_F_from_Q(sk_t *Fs, const sk_t *Qs, sk_t *Ts) {
calculate_F_from_Q_impl(Fs, Qs, Ts);
}

void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_calculate_Q_from_F_cyclic(cpk_t *Qs, const sk_t *Fs, const sk_t *Ts) {
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_calculate_Q_from_F_cyclic(cpk_t *Qs, const sk_t *Fs, const sk_t *Ts) {
calculate_Q_from_F_cyclic_impl(Qs, Fs, Ts);
}

crypto_sign/rainbowIa-cyclic-compressed/clean/rainbow_keypair_computation.h → crypto_sign/rainbowI-circumzenithal/clean/rainbow_keypair_computation.h 查看文件

@@ -37,7 +37,7 @@ typedef struct rainbow_extend_publickey {
/// @param[out] pk - the classic public key.
/// @param[in] cpk - the internel public key.
///
void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk);
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk);
/////////////////////////////////////////////////

///
@@ -47,7 +47,7 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cp
/// @param[in] Fs - parts of the secret key: l1_F1, l1_F2, l2_F1, l2_F2, l2_F3, l2_F5, l2_F6
/// @param[in] Ts - parts of the secret key: T1, T4, T3
///
void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_calculate_Q_from_F(ext_cpk_t *Qs, const sk_t *Fs, const sk_t *Ts);
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_calculate_Q_from_F(ext_cpk_t *Qs, const sk_t *Fs, const sk_t *Ts);


///
@@ -57,7 +57,7 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_calculate_Q_from_F(ext_cpk_t *Qs, c
/// @param[in] Qs - parts of the pk: l1_Q1, l1_Q2, l2_Q1, l2_Q2, l2_Q3, l2_Q5, l2_Q6
/// @param[in] Ts - parts of the sk: T1, T4, T3
///
void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_calculate_F_from_Q(sk_t *Fs, const sk_t *Qs, sk_t *Ts);
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_calculate_F_from_Q(sk_t *Fs, const sk_t *Qs, sk_t *Ts);

///
/// @brief Computing parts of the pk from the secret key
@@ -66,6 +66,6 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_calculate_F_from_Q(sk_t *Fs, const
/// @param[in] Fs - parts of the sk: l1_F1, l1_F2, l2_F1, l2_F2, l2_F3, l2_F5, l2_F6
/// @param[in] Ts - parts of the sk: T1, T4, T3
///
void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_calculate_Q_from_F_cyclic(cpk_t *Qs, const sk_t *Fs, const sk_t *Ts);
void PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_calculate_Q_from_F_cyclic(cpk_t *Qs, const sk_t *Fs, const sk_t *Ts);

#endif // _RAINBOW_KEYPAIR_COMP_H_

+ 76
- 0
crypto_sign/rainbowI-circumzenithal/clean/sign.c 查看文件

@@ -0,0 +1,76 @@
/// @file sign.c
/// @brief the implementations for functions in api.h
///
///

#include "api.h"
#include "rainbow.h"
#include "rainbow_config.h"
#include "rainbow_keypair.h"
#include "randombytes.h"
#include "utils_hash.h"
#include <stdlib.h>
#include <string.h>

int PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_crypto_sign_keypair(unsigned char *pk, unsigned char *sk) {
unsigned char sk_seed[LEN_SKSEED] = {0};
randombytes(sk_seed, LEN_SKSEED);

unsigned char pk_seed[LEN_PKSEED] = {0};
randombytes(pk_seed, LEN_PKSEED);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_generate_keypair_cyclic((cpk_t *)pk, (sk_t *)sk, pk_seed, sk_seed);
return 0;
}

int PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_crypto_sign(unsigned char *sm, size_t *smlen, const unsigned char *m, size_t mlen, const unsigned char *sk) {
unsigned char digest[_HASH_LEN];

PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_hash_msg(digest, _HASH_LEN, m, mlen);

memcpy(sm, m, mlen);
smlen[0] = mlen + _SIGNATURE_BYTE;

return PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_rainbow_sign(sm + mlen, (const sk_t *)sk, digest);
}

int PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_crypto_sign_open(unsigned char *m, size_t *mlen, const unsigned char *sm, size_t smlen, const unsigned char *pk) {
int rc;
if (_SIGNATURE_BYTE > smlen) {
rc = -1;
} else {
*mlen = smlen - _SIGNATURE_BYTE;

unsigned char digest[_HASH_LEN];
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_hash_msg(digest, _HASH_LEN, sm, *mlen);

rc = PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_rainbow_verify_cyclic(digest, sm + mlen[0], (const cpk_t *)pk);
}
if (!rc) {
memmove(m, sm, smlen - _SIGNATURE_BYTE);
} else { // bad signature
*mlen = (size_t) -1;
memset(m, 0, smlen);
}
return rc;
}

int PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_crypto_sign_signature(
uint8_t *sig, size_t *siglen,
const uint8_t *m, size_t mlen, const uint8_t *sk) {
unsigned char digest[_HASH_LEN];

PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_hash_msg(digest, _HASH_LEN, m, mlen);
*siglen = _SIGNATURE_BYTE;
return PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_rainbow_sign(sig, (const sk_t *)sk, digest);
}

int PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_crypto_sign_verify(
const uint8_t *sig, size_t siglen,
const uint8_t *m, size_t mlen, const uint8_t *pk) {
if (siglen != _SIGNATURE_BYTE) {
return -1;
}
unsigned char digest[_HASH_LEN];
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_hash_msg(digest, _HASH_LEN, m, mlen);
return PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_rainbow_verify_cyclic(digest, sig, (const cpk_t *)pk);
}

crypto_sign/rainbowIa-classic/clean/utils_hash.c → crypto_sign/rainbowI-circumzenithal/clean/utils_hash.c 查看文件

@@ -7,7 +7,7 @@
#include "rainbow_config.h"
#include "sha2.h"

static inline int _hash(unsigned char *digest, const unsigned char *m, size_t mlen) {
static inline int h(unsigned char *digest, const unsigned char *m, size_t mlen) {
sha256(digest, m, mlen);
return 0;
}
@@ -25,14 +25,14 @@ static inline int expand_hash(unsigned char *digest, size_t n_digest, const unsi
n_digest -= _HASH_LEN;

while (_HASH_LEN <= n_digest) {
_hash(digest + _HASH_LEN, digest, _HASH_LEN);
h(digest + _HASH_LEN, digest, _HASH_LEN);

n_digest -= _HASH_LEN;
digest += _HASH_LEN;
}
unsigned char temp[_HASH_LEN];
if (n_digest) {
_hash(temp, digest, _HASH_LEN);
h(temp, digest, _HASH_LEN);
for (size_t i = 0; i < n_digest; i++) {
digest[_HASH_LEN + i] = temp[i];
}
@@ -40,11 +40,11 @@ static inline int expand_hash(unsigned char *digest, size_t n_digest, const unsi
return 0;
}

int PQCLEAN_RAINBOWIACLASSIC_CLEAN_hash_msg(unsigned char *digest,
int PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_hash_msg(unsigned char *digest,
size_t len_digest,
const unsigned char *m,
size_t mlen) {
unsigned char buf[_HASH_LEN];
_hash(buf, m, mlen);
h(buf, m, mlen);
return expand_hash(digest, len_digest, buf);
}

+ 11
- 0
crypto_sign/rainbowI-circumzenithal/clean/utils_hash.h 查看文件

@@ -0,0 +1,11 @@
#ifndef _UTILS_HASH_H_
#define _UTILS_HASH_H_
/// @file utils_hash.h
/// @brief the interface for adapting hash functions.
///

#include <stddef.h>

int PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_hash_msg(unsigned char *digest, size_t len_digest, const unsigned char *m, size_t mlen);

#endif // _UTILS_HASH_H_

+ 97
- 0
crypto_sign/rainbowI-circumzenithal/clean/utils_prng.c 查看文件

@@ -0,0 +1,97 @@
/// @file utils_prng.c
/// @brief The implementation of PRNG related functions.
///

#include "utils_prng.h"
#include "aes.h"
#include "randombytes.h"
#include "utils_hash.h"
#include <stdlib.h>
#include <string.h>

static void prng_update(const unsigned char *provided_data,
unsigned char *Key,
unsigned char *V) {
unsigned char temp[48];
aes256ctx ctx;
aes256_ecb_keyexp(&ctx, Key);
for (int i = 0; i < 3; i++) {
//increment V
for (int j = 15; j >= 0; j--) {
if (V[j] == 0xff) {
V[j] = 0x00;
} else {
V[j]++;
break;
}
}
aes256_ecb(temp + 16 * i, V, 1, &ctx);
}
if (provided_data != NULL) {
for (int i = 0; i < 48; i++) {
temp[i] ^= provided_data[i];
}
}
aes256_ctx_release(&ctx);
memcpy(Key, temp, 32);
memcpy(V, temp + 32, 16);
}
static void randombytes_init_with_state(prng_t *state,
unsigned char *entropy_input_48bytes) {
memset(state->Key, 0x00, 32);
memset(state->V, 0x00, 16);
prng_update(entropy_input_48bytes, state->Key, state->V);
}

static int randombytes_with_state(prng_t *state,
unsigned char *x,
size_t xlen) {

unsigned char block[16];
int i = 0;

aes256ctx ctx;
aes256_ecb_keyexp(&ctx, state->Key);

while (xlen > 0) {
//increment V
for (int j = 15; j >= 0; j--) {
if (state->V[j] == 0xff) {
state->V[j] = 0x00;
} else {
state->V[j]++;
break;
}
}
aes256_ecb(block, state->V, 1, &ctx);
if (xlen > 15) {
memcpy(x + i, block, 16);
i += 16;
xlen -= 16;
} else {
memcpy(x + i, block, xlen);
xlen = 0;
}
}
aes256_ctx_release(&ctx);
prng_update(NULL, state->Key, state->V);
return 0;
}

int PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_prng_set(prng_t *ctx, const void *prng_seed, unsigned long prng_seedlen) {
unsigned char seed[48];
if (prng_seedlen >= 48) {
memcpy(seed, prng_seed, 48);
} else {
memcpy(seed, prng_seed, prng_seedlen);
PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_hash_msg(seed + prng_seedlen, 48 - (unsigned)prng_seedlen, (const unsigned char *)prng_seed, prng_seedlen);
}

randombytes_init_with_state(ctx, seed);

return 0;
}

int PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_prng_gen(prng_t *ctx, unsigned char *out, unsigned long outlen) {
return randombytes_with_state(ctx, out, outlen);
}

+ 18
- 0
crypto_sign/rainbowI-circumzenithal/clean/utils_prng.h 查看文件

@@ -0,0 +1,18 @@
#ifndef _UTILS_PRNG_H_
#define _UTILS_PRNG_H_
/// @file utils_prng.h
/// @brief the interface for adapting PRNG functions.
///
///

#include "randombytes.h"

typedef struct {
unsigned char Key[32];
unsigned char V[16];
} prng_t;

int PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_prng_set(prng_t *ctx, const void *prng_seed, unsigned long prng_seedlen);
int PQCLEAN_RAINBOWICIRCUMZENITHAL_CLEAN_prng_gen(prng_t *ctx, unsigned char *out, unsigned long outlen);

#endif // _UTILS_PRNG_H_

+ 20
- 0
crypto_sign/rainbowI-classic/META.yml 查看文件

@@ -0,0 +1,20 @@
name: "RAINBOW(16,36,32,32) - classic"
type: signature
claimed-nist-level: 1
length-public-key: 161600
length-secret-key: 103648
length-signature: 66
nistkat-sha256: 5cef855ed222382139f2fd91a84c3c651c5c4f8f59f5bb9cb3c8648b6ca34c52
testvectors-sha256: 4896b97fee529f932396734f8bae1bd11ddf99d77586f7b96a7d87ada3a37ac2
principal-submitters:
- Jintai Ding
auxiliary-submitters:
- Ming-Shing Chen
- Matthias Kannwischer
- Jacques Patarin
- Albrecht Petzoldt
- Dieter Schmidt
- Bo-Yin Yang
implementations:
- name: clean
version: https://github.com/fast-crypto-lab/rainbow-submission-round2/commit/173ada0e077e1b9dbd8e4a78994f87acc0c92263

crypto_sign/rainbowIIIc-cyclic-compressed/clean/LICENSE → crypto_sign/rainbowI-classic/clean/LICENSE 查看文件


crypto_sign/rainbowVc-cyclic/clean/Makefile → crypto_sign/rainbowI-classic/clean/Makefile 查看文件

@@ -1,6 +1,6 @@
# This Makefile can be used with GNU Make or BSD Make

LIB=librainbowVc-cyclic_clean.a
LIB=librainbowI-classic_clean.a

HEADERS = api.h blas_comm.h blas.h gf.h parallel_matrix_op.h rainbow_blas.h rainbow_config.h rainbow.h rainbow_keypair_computation.h rainbow_keypair.h utils_hash.h utils_prng.h
OBJECTS = blas_comm.o parallel_matrix_op.o rainbow.o rainbow_keypair.o rainbow_keypair_computation.o sign.o utils_hash.o utils_prng.o blas.o gf.o

crypto_sign/rainbowVc-cyclic/clean/Makefile.Microsoft_nmake → crypto_sign/rainbowI-classic/clean/Makefile.Microsoft_nmake 查看文件

@@ -1,7 +1,7 @@
# This Makefile can be used with Microsoft Visual Studio's nmake using the command:
# nmake /f Makefile.Microsoft_nmake

LIBRARY=librainbowVc-cyclic_clean.lib
LIBRARY=librainbowI-classic_clean.lib
OBJECTS = blas_comm.obj parallel_matrix_op.obj rainbow.obj rainbow_keypair.obj rainbow_keypair_computation.obj sign.obj utils_hash.obj utils_prng.obj blas.obj gf.obj

CFLAGS=/nologo /O2 /I ..\..\..\common /W4 /WX

+ 32
- 0
crypto_sign/rainbowI-classic/clean/api.h 查看文件

@@ -0,0 +1,32 @@
#ifndef PQCLEAN_RAINBOWICLASSIC_CLEAN_API_H
#define PQCLEAN_RAINBOWICLASSIC_CLEAN_API_H

#include <stddef.h>
#include <stdint.h>

#define PQCLEAN_RAINBOWICLASSIC_CLEAN_CRYPTO_SECRETKEYBYTES 103648
#define PQCLEAN_RAINBOWICLASSIC_CLEAN_CRYPTO_PUBLICKEYBYTES 161600
#define PQCLEAN_RAINBOWICLASSIC_CLEAN_CRYPTO_BYTES 66
#define PQCLEAN_RAINBOWICLASSIC_CLEAN_CRYPTO_ALGNAME "RAINBOW(16,36,32,32) - classic"

int PQCLEAN_RAINBOWICLASSIC_CLEAN_crypto_sign_keypair(uint8_t *pk, uint8_t *sk);


int PQCLEAN_RAINBOWICLASSIC_CLEAN_crypto_sign_signature(
uint8_t *sig, size_t *siglen,
const uint8_t *m, size_t mlen, const uint8_t *sk);

int PQCLEAN_RAINBOWICLASSIC_CLEAN_crypto_sign_verify(
const uint8_t *sig, size_t siglen,
const uint8_t *m, size_t mlen, const uint8_t *pk);

int PQCLEAN_RAINBOWICLASSIC_CLEAN_crypto_sign(uint8_t *sm, size_t *smlen,
const uint8_t *m, size_t mlen,
const uint8_t *sk);

int PQCLEAN_RAINBOWICLASSIC_CLEAN_crypto_sign_open(uint8_t *m, size_t *mlen,
const uint8_t *sm, size_t smlen,
const uint8_t *pk);


#endif

crypto_sign/rainbowIa-cyclic/clean/blas.c → crypto_sign/rainbowI-classic/clean/blas.c 查看文件

@@ -3,40 +3,40 @@

#include <stddef.h>

void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_predicated_add(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, size_t _num_byte) {
void PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_predicated_add(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, size_t _num_byte) {
uint8_t pr_u8 = (uint8_t) ((uint8_t) 0 - predicate);
for (size_t i = 0; i < _num_byte; i++) {
accu_b[i] ^= (a[i] & pr_u8);
}
}

void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_add(uint8_t *accu_b, const uint8_t *a, size_t _num_byte) {
void PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_add(uint8_t *accu_b, const uint8_t *a, size_t _num_byte) {
for (size_t i = 0; i < _num_byte; i++) {
accu_b[i] ^= a[i];
}
}


void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_mul_scalar(uint8_t *a, uint8_t gf16_b, size_t _num_byte) {
void PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_mul_scalar(uint8_t *a, uint8_t gf16_b, size_t _num_byte) {
uint8_t tmp;
for (size_t i = 0; i < _num_byte; i++) {
tmp = PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16_mul(a[i] & 0xF, gf16_b);
tmp |= (uint8_t) (PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16_mul(a[i] >> 4, gf16_b) << 4);
tmp = PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16_mul(a[i] & 0xF, gf16_b);
tmp |= (uint8_t) (PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16_mul(a[i] >> 4, gf16_b) << 4);
a[i] = tmp;
}
}

void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_madd(uint8_t *accu_c, const uint8_t *a, uint8_t gf16_b, size_t _num_byte) {
void PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_madd(uint8_t *accu_c, const uint8_t *a, uint8_t gf16_b, size_t _num_byte) {
for (size_t i = 0; i < _num_byte; i++) {
accu_c[i] ^= PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16_mul(a[i] & 0xF, gf16_b);
accu_c[i] ^= (uint8_t) (PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16_mul(a[i] >> 4, gf16_b) << 4);
accu_c[i] ^= PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16_mul(a[i] & 0xF, gf16_b);
accu_c[i] ^= (uint8_t) (PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16_mul(a[i] >> 4, gf16_b) << 4);
}
}

uint8_t PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_dot(const uint8_t *a, const uint8_t *b, size_t _num_byte) {
uint8_t PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_dot(const uint8_t *a, const uint8_t *b, size_t _num_byte) {
uint8_t r = 0;
for (size_t i = 0; i < _num_byte; i++) {
r ^= PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16_mul(a[i], b[i]);
r ^= PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16_mul(a[i], b[i]);
}
return r;
}

crypto_sign/rainbowIa-cyclic/clean/blas.h → crypto_sign/rainbowI-classic/clean/blas.h 查看文件

@@ -8,13 +8,13 @@
#include <stddef.h>
#include <stdint.h>

void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_predicated_add(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, size_t _num_byte);
void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_add(uint8_t *accu_b, const uint8_t *a, size_t _num_byte);
void PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_predicated_add(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, size_t _num_byte);
void PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_add(uint8_t *accu_b, const uint8_t *a, size_t _num_byte);


void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_madd(uint8_t *accu_c, const uint8_t *a, uint8_t gf16_b, size_t _num_byte);
void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_mul_scalar(uint8_t *a, uint8_t gf16_b, size_t _num_byte);
uint8_t PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_dot(const uint8_t *a, const uint8_t *b, size_t _num_byte);
void PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_madd(uint8_t *accu_c, const uint8_t *a, uint8_t gf16_b, size_t _num_byte);
void PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_mul_scalar(uint8_t *a, uint8_t gf16_b, size_t _num_byte);
uint8_t PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_dot(const uint8_t *a, const uint8_t *b, size_t _num_byte);


#endif // _BLAS_H_

crypto_sign/rainbowIa-cyclic/clean/blas_comm.c → crypto_sign/rainbowI-classic/clean/blas_comm.c 查看文件

@@ -10,7 +10,7 @@
#include <stdint.h>
#include <string.h>

void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte) {
void PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte) {
for (size_t i = 0; i < _num_byte; i++) {
b[i] = 0;
}
@@ -22,7 +22,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num
/// @param[in] i - the index in the vector a.
/// @return the value of the element.
///
uint8_t PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned int i) {
uint8_t PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned int i) {
uint8_t r = a[i >> 1];
uint8_t r0 = r & 0xf;
uint8_t r1 = r >> 4;
@@ -37,7 +37,7 @@ uint8_t PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned i
/// @param[in] v - the value for the i-th element in vector a.
/// @return the value of the element.
///
static uint8_t PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_set_ele(uint8_t *a, unsigned int i, uint8_t v) {
static uint8_t PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_set_ele(uint8_t *a, unsigned int i, uint8_t v) {
uint8_t m = (uint8_t)(0xf ^ (-((int8_t)i & 1))); /// 1--> 0xf0 , 0--> 0x0f
uint8_t ai_remaining = (uint8_t)(a[i >> 1] & (~m)); /// erase
a[i >> 1] = (uint8_t)(ai_remaining | (m & (v << 4)) | (m & v & 0xf)); /// set
@@ -45,22 +45,22 @@ static uint8_t PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_set_ele(uint8_t *a, unsigned
}

static void gf16mat_prod_ref(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b) {
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_set_zero(c, n_A_vec_byte);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_set_zero(c, n_A_vec_byte);
for (unsigned int i = 0; i < n_A_width; i++) {
uint8_t bb = PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(b, i);
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_madd(c, matA, bb, n_A_vec_byte);
uint8_t bb = PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_get_ele(b, i);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_madd(c, matA, bb, n_A_vec_byte);
matA += n_A_vec_byte;
}
}

void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec) {
void PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec) {
unsigned int n_vec_byte = (len_vec + 1) / 2;
for (unsigned int k = 0; k < len_vec; k++) {
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_set_zero(c, n_vec_byte);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_set_zero(c, n_vec_byte);
const uint8_t *bk = b + n_vec_byte * k;
for (unsigned int i = 0; i < len_vec; i++) {
uint8_t bb = PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(bk, i);
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_madd(c, a + n_vec_byte * i, bb, n_vec_byte);
uint8_t bb = PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_get_ele(bk, i);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_madd(c, a + n_vec_byte * i, bb, n_vec_byte);
}
c += n_vec_byte;
}
@@ -74,19 +74,19 @@ static unsigned int gf16mat_gauss_elim_ref(uint8_t *mat, unsigned int h, unsigne
uint8_t *ai = mat + n_w_byte * i;
for (unsigned int j = i + 1; j < h; j++) {
uint8_t *aj = mat + n_w_byte * j;
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_predicated_add(ai + offset_byte, 1 ^ PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16_is_nonzero(PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(ai, i)), aj + offset_byte, n_w_byte - offset_byte);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_predicated_add(ai + offset_byte, 1 ^ PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16_is_nonzero(PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_get_ele(ai, i)), aj + offset_byte, n_w_byte - offset_byte);
}
uint8_t pivot = PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(ai, i);
r8 &= PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16_is_nonzero(pivot);
pivot = PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16_inv(pivot);
uint8_t pivot = PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_get_ele(ai, i);
r8 &= PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16_is_nonzero(pivot);
pivot = PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16_inv(pivot);
offset_byte = (i + 1) >> 1;
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_mul_scalar(ai + offset_byte, pivot, n_w_byte - offset_byte);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_mul_scalar(ai + offset_byte, pivot, n_w_byte - offset_byte);
for (unsigned int j = 0; j < h; j++) {
if (i == j) {
continue;
}
uint8_t *aj = mat + n_w_byte * j;
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_madd(aj + offset_byte, ai + offset_byte, PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(aj, i), n_w_byte - offset_byte);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_madd(aj + offset_byte, ai + offset_byte, PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_get_ele(aj, i), n_w_byte - offset_byte);
}
}
return r8;
@@ -97,11 +97,11 @@ static unsigned int gf16mat_solve_linear_eq_ref(uint8_t *sol, const uint8_t *inp
unsigned int n_byte = (n + 1) >> 1;
for (unsigned int i = 0; i < n; i++) {
memcpy(mat + i * (n_byte + 1), inp_mat + i * n_byte, n_byte);
mat[i * (n_byte + 1) + n_byte] = PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(c_terms, i);
mat[i * (n_byte + 1) + n_byte] = PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_get_ele(c_terms, i);
}
unsigned int r8 = PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_gauss_elim(mat, n, n + 2);
unsigned int r8 = PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16mat_gauss_elim(mat, n, n + 2);
for (unsigned int i = 0; i < n; i++) {
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_set_ele(sol, i, mat[i * (n_byte + 1) + n_byte]);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_set_ele(sol, i, mat[i * (n_byte + 1) + n_byte]);
}
return r8;
}
@@ -117,17 +117,17 @@ static inline void gf16mat_submat(uint8_t *mat2, unsigned int w2, unsigned int s
}
}

unsigned int PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer) {
unsigned int PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer) {
unsigned int n_w_byte = (H + 1) / 2;

uint8_t *aa = buffer;
for (unsigned int i = 0; i < H; i++) {
uint8_t *ai = aa + i * 2 * n_w_byte;
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_set_zero(ai, 2 * n_w_byte);
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_add(ai, a + i * n_w_byte, n_w_byte);
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_set_ele(ai + n_w_byte, i, 1);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_set_zero(ai, 2 * n_w_byte);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_add(ai, a + i * n_w_byte, n_w_byte);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_set_ele(ai + n_w_byte, i, 1);
}
unsigned int r8 = PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_gauss_elim(aa, H, 2 * H);
unsigned int r8 = PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16mat_gauss_elim(aa, H, 2 * H);
gf16mat_submat(inv_a, H, H, aa, 2 * H, H);
return r8;
}
@@ -138,15 +138,15 @@ unsigned int PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_inv(uint8_t *inv_a, const uin
#define gf16mat_gauss_elim_impl gf16mat_gauss_elim_ref
#define gf16mat_solve_linear_eq_impl gf16mat_solve_linear_eq_ref

void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b) {
void PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b) {
gf16mat_prod_impl(c, matA, n_A_vec_byte, n_A_width, b);
}

unsigned int PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w) {
unsigned int PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w) {
return gf16mat_gauss_elim_impl(mat, h, w);
}

unsigned int PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n) {
unsigned int PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n) {
return gf16mat_solve_linear_eq_impl(sol, inp_mat, c_terms, n);
}


crypto_sign/rainbowIa-cyclic/clean/blas_comm.h → crypto_sign/rainbowI-classic/clean/blas_comm.h 查看文件

@@ -12,7 +12,7 @@
/// @param[in,out] b - the vector b.
/// @param[in] _num_byte - number of bytes for the vector b.
///
void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte);
void PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte);

/// @brief get an element from GF(16) vector .
///
@@ -20,7 +20,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num
/// @param[in] i - the index in the vector a.
/// @return the value of the element.
///
uint8_t PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned int i);
uint8_t PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned int i);

/// @brief matrix-matrix multiplication: c = a * b , in GF(16)
///
@@ -29,7 +29,7 @@ uint8_t PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned i
/// @param[in] b - a matrix b.
/// @param[in] len_vec - the length of column vectors.
///
void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec);
void PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec);

/// @brief Gauss elimination for a matrix, in GF(16)
///
@@ -38,7 +38,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_mul(uint8_t *c, const uint8_t *a, con
/// @param[in] w - the width of the matrix.
/// @return 1(true) if success. 0(false) if the matrix is singular.
///
unsigned int PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w);
unsigned int PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w);

/// @brief Solving linear equations, in GF(16)
///
@@ -48,7 +48,7 @@ unsigned int PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_gauss_elim(uint8_t *mat, unsi
/// @param[in] n - the number of equations.
/// @return 1(true) if success. 0(false) if the matrix is singular.
///
unsigned int PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n);
unsigned int PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n);

/// @brief Computing the inverse matrix, in GF(16)
///
@@ -58,7 +58,7 @@ unsigned int PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_solve_linear_eq(uint8_t *sol,
/// @param[in] buffer - The buffer for computations. it has to be as large as 2 input matrixes.
/// @return 1(true) if success. 0(false) if the matrix is singular.
///
unsigned int PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer);
unsigned int PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer);

/// @brief matrix-vector multiplication: c = matA * b , in GF(16)
///
@@ -68,7 +68,7 @@ unsigned int PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_inv(uint8_t *inv_a, const uin
/// @param[in] n_A_width - the width of matrix A.
/// @param[in] b - the vector b.
///
void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b);
void PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b);


#endif // _BLAS_COMM_H_

crypto_sign/rainbowIa-cyclic/clean/gf.c → crypto_sign/rainbowI-classic/clean/gf.c 查看文件

@@ -17,7 +17,7 @@ static inline uint8_t gf4_squ(uint8_t a) {
}

//// gf16 := gf4[y]/y^2+y+x
uint8_t PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16_mul(uint8_t a, uint8_t b) {
uint8_t PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16_mul(uint8_t a, uint8_t b) {
uint8_t a0 = a & 3;
uint8_t a1 = (a >> 2);
uint8_t b0 = b & 3;
@@ -37,18 +37,18 @@ static inline uint8_t gf16_squ(uint8_t a) {
return (uint8_t)((a1 << 2) ^ a1squ_x2 ^ gf4_squ(a0));
}

uint8_t PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16_is_nonzero(uint8_t a) {
uint8_t PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16_is_nonzero(uint8_t a) {
unsigned int a4 = a & 0xf;
unsigned int r = ((unsigned int)0) - a4;
r >>= 4;
return r & 1;
}

uint8_t PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16_inv(uint8_t a) {
uint8_t PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16_inv(uint8_t a) {
uint8_t a2 = gf16_squ(a);
uint8_t a4 = gf16_squ(a2);
uint8_t a8 = gf16_squ(a4);
uint8_t a6 = PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16_mul(a4, a2);
return PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16_mul(a8, a6);
uint8_t a6 = PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16_mul(a4, a2);
return PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16_mul(a8, a6);
}


crypto_sign/rainbowIa-cyclic/clean/gf.h → crypto_sign/rainbowI-classic/clean/gf.h 查看文件

@@ -8,11 +8,11 @@
/// @brief Library for arithmetics in GF(16) and GF(256)
///

uint8_t PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16_mul(uint8_t a, uint8_t b);
uint8_t PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16_mul(uint8_t a, uint8_t b);


uint8_t PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16_is_nonzero(uint8_t a);
uint8_t PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16_inv(uint8_t a);
uint8_t PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16_is_nonzero(uint8_t a);
uint8_t PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16_inv(uint8_t a);


#endif // _GF16_H_

crypto_sign/rainbowIa-cyclic/clean/parallel_matrix_op.c → crypto_sign/rainbowI-classic/clean/parallel_matrix_op.c 查看文件

@@ -16,7 +16,7 @@
/// @param[in] dim - the dimension of the upper-triangle matrix, i.e., an dim x dim matrix.
/// @return the corresponding index in an array storage.
///
unsigned int PQCLEAN_RAINBOWIACYCLIC_CLEAN_idx_of_trimat(unsigned int i_row, unsigned int j_col, unsigned int dim) {
unsigned int PQCLEAN_RAINBOWICLASSIC_CLEAN_idx_of_trimat(unsigned int i_row, unsigned int j_col, unsigned int dim) {
return (dim + dim - i_row + 1) * i_row / 2 + j_col - i_row;
}

@@ -30,25 +30,25 @@ unsigned int PQCLEAN_RAINBOWIACYCLIC_CLEAN_idx_of_trimat(unsigned int i_row, uns
///
static inline unsigned int idx_of_2trimat(unsigned int i_row, unsigned int j_col, unsigned int n_var) {
if (i_row > j_col) {
return PQCLEAN_RAINBOWIACYCLIC_CLEAN_idx_of_trimat(j_col, i_row, n_var);
return PQCLEAN_RAINBOWICLASSIC_CLEAN_idx_of_trimat(j_col, i_row, n_var);
}
return PQCLEAN_RAINBOWIACYCLIC_CLEAN_idx_of_trimat(i_row, j_col, n_var);
return PQCLEAN_RAINBOWICLASSIC_CLEAN_idx_of_trimat(i_row, j_col, n_var);
}

void PQCLEAN_RAINBOWIACYCLIC_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned int Awidth, unsigned int size_batch) {
void PQCLEAN_RAINBOWICLASSIC_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned int Awidth, unsigned int size_batch) {
unsigned char *runningC = btriC;
unsigned int Aheight = Awidth;
for (unsigned int i = 0; i < Aheight; i++) {
for (unsigned int j = 0; j < i; j++) {
unsigned int idx = PQCLEAN_RAINBOWIACYCLIC_CLEAN_idx_of_trimat(j, i, Aheight);
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_add(btriC + idx * size_batch, bA + size_batch * (i * Awidth + j), size_batch);
unsigned int idx = PQCLEAN_RAINBOWICLASSIC_CLEAN_idx_of_trimat(j, i, Aheight);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_add(btriC + idx * size_batch, bA + size_batch * (i * Awidth + j), size_batch);
}
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_add(runningC, bA + size_batch * (i * Awidth + i), size_batch * (Aheight - i));
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_add(runningC, bA + size_batch * (i * Awidth + i), size_batch * (Aheight - i));
runningC += size_batch * (Aheight - i);
}
}

void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA,
void PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) {
unsigned int Awidth = Bheight;
unsigned int Aheight = Awidth;
@@ -58,7 +58,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, con
if (k < i) {
continue;
}
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_madd(bC, &btriA[(k - i) * size_batch], PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_madd(bC, &btriA[(k - i) * size_batch], PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch);
}
bC += size_batch;
}
@@ -66,7 +66,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, con
}
}

void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, const unsigned char *btriA,
void PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, const unsigned char *btriA,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) {
unsigned int Aheight = Bheight;
for (unsigned int i = 0; i < Aheight; i++) {
@@ -75,14 +75,14 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, c
if (i < k) {
continue;
}
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_madd(bC, &btriA[size_batch * (PQCLEAN_RAINBOWIACYCLIC_CLEAN_idx_of_trimat(k, i, Aheight))], PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_madd(bC, &btriA[size_batch * (PQCLEAN_RAINBOWICLASSIC_CLEAN_idx_of_trimat(k, i, Aheight))], PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch);
}
bC += size_batch;
}
}
}

void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA,
void PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) {
unsigned int Aheight = Bheight;
for (unsigned int i = 0; i < Aheight; i++) {
@@ -91,46 +91,46 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, co
if (i == k) {
continue;
}
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_madd(bC, &btriA[size_batch * (idx_of_2trimat(i, k, Aheight))], PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_madd(bC, &btriA[size_batch * (idx_of_2trimat(i, k, Aheight))], PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch);
}
bC += size_batch;
}
}
}

void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_matTr_madd_gf16(unsigned char *bC, const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth,
void PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_matTr_madd_gf16(unsigned char *bC, const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth,
const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch) {
unsigned int Atr_height = Awidth;
unsigned int Atr_width = Aheight;
for (unsigned int i = 0; i < Atr_height; i++) {
for (unsigned int j = 0; j < Atr_width; j++) {
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_madd(bC, &bB[j * Bwidth * size_batch], PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(&A_to_tr[size_Acolvec * i], j), size_batch * Bwidth);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_madd(bC, &bB[j * Bwidth * size_batch], PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_get_ele(&A_to_tr[size_Acolvec * i], j), size_batch * Bwidth);
}
bC += size_batch * Bwidth;
}
}

void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr,
void PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) {
const unsigned char *bA = bA_to_tr;
unsigned int Aheight = Awidth_before_tr;
for (unsigned int i = 0; i < Aheight; i++) {
for (unsigned int j = 0; j < Bwidth; j++) {
for (unsigned int k = 0; k < Bheight; k++) {
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_madd(bC, &bA[size_batch * (i + k * Aheight)], PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_madd(bC, &bA[size_batch * (i + k * Aheight)], PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch);
}
bC += size_batch;
}
}
}

void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned int Aheight,
void PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned int Aheight,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) {
unsigned int Awidth = Bheight;
for (unsigned int i = 0; i < Aheight; i++) {
for (unsigned int j = 0; j < Bwidth; j++) {
for (unsigned int k = 0; k < Bheight; k++) {
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_madd(bC, &bA[k * size_batch], PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_madd(bC, &bA[k * size_batch], PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch);
}
bC += size_batch;
}
@@ -138,45 +138,45 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const
}
}

void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned int dim_y, const unsigned char *mat,
void PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned int dim_y, const unsigned char *mat,
const unsigned char *x, unsigned int dim_x, unsigned int size_batch) {
unsigned char tmp[128];

unsigned char _x[128];
for (unsigned int i = 0; i < dim_x; i++) {
_x[i] = PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(x, i);
_x[i] = PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_get_ele(x, i);
}
unsigned char _y[128];
for (unsigned int i = 0; i < dim_y; i++) {
_y[i] = PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(y, i);
_y[i] = PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_get_ele(y, i);
}

PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_set_zero(z, size_batch);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_set_zero(z, size_batch);
for (unsigned int i = 0; i < dim_y; i++) {
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_set_zero(tmp, size_batch);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_set_zero(tmp, size_batch);
for (unsigned int j = 0; j < dim_x; j++) {
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_madd(tmp, mat, _x[j], size_batch);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_madd(tmp, mat, _x[j], size_batch);
mat += size_batch;
}
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_madd(z, tmp, _y[i], size_batch);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_madd(z, tmp, _y[i], size_batch);
}
}

void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch) {
void PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch) {
unsigned char tmp[256];

unsigned char _x[256];
for (unsigned int i = 0; i < dim; i++) {
_x[i] = PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(x, i);
_x[i] = PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_get_ele(x, i);
}

PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_set_zero(y, size_batch);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_set_zero(y, size_batch);
for (unsigned int i = 0; i < dim; i++) {
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_set_zero(tmp, size_batch);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_set_zero(tmp, size_batch);
for (unsigned int j = i; j < dim; j++) {
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_madd(tmp, trimat, _x[j], size_batch);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_madd(tmp, trimat, _x[j], size_batch);
trimat += size_batch;
}
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_madd(y, tmp, _x[i], size_batch);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_madd(y, tmp, _x[i], size_batch);
}
}

crypto_sign/rainbowIa-cyclic/clean/parallel_matrix_op.h → crypto_sign/rainbowI-classic/clean/parallel_matrix_op.h 查看文件

@@ -15,7 +15,7 @@
/// @param[in] dim - the dimension of the upper-triangle matrix, i.e., an dim x dim matrix.
/// @return the corresponding index in an array storage.
///
unsigned int PQCLEAN_RAINBOWIACYCLIC_CLEAN_idx_of_trimat(unsigned int i_row, unsigned int j_col, unsigned int dim);
unsigned int PQCLEAN_RAINBOWICLASSIC_CLEAN_idx_of_trimat(unsigned int i_row, unsigned int j_col, unsigned int dim);

///
/// @brief Upper trianglize a rectangle matrix to the corresponding upper-trangle matrix.
@@ -25,7 +25,7 @@ unsigned int PQCLEAN_RAINBOWIACYCLIC_CLEAN_idx_of_trimat(unsigned int i_row, uns
/// @param[in] bwidth - the width of the batched matrix A, i.e., A is a Awidth x Awidth matrix.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIACYCLIC_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned int Awidth, unsigned int size_batch);
void PQCLEAN_RAINBOWICLASSIC_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned int Awidth, unsigned int size_batch);

//////////////////// Section: matrix multiplications ///////////////////////////////

@@ -40,7 +40,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_UpperTrianglize(unsigned char *btriC, const u
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA,
void PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);

///
@@ -54,7 +54,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, con
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA,
void PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);

///
@@ -68,7 +68,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, co
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, const unsigned char *btriA,
void PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, const unsigned char *btriA,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);

///
@@ -82,7 +82,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, c
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_trimatTr_madd_gf256(unsigned char *bC, const unsigned char *btriA,
void PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_trimatTr_madd_gf256(unsigned char *bC, const unsigned char *btriA,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);

///
@@ -96,7 +96,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_trimatTr_madd_gf256(unsigned char *bC,
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA,
void PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);

///
@@ -110,7 +110,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, co
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA,
void PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);

///
@@ -125,7 +125,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC, c
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_matTr_madd_gf16(unsigned char *bC,
void PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_matTr_madd_gf16(unsigned char *bC,
const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth,
const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch);

@@ -141,7 +141,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_matTr_madd_gf16(unsigned char *bC,
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_matTr_madd_gf256(unsigned char *bC,
void PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_matTr_madd_gf256(unsigned char *bC,
const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth,
const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch);

@@ -157,7 +157,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_matTr_madd_gf256(unsigned char *bC,
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr,
void PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);

///
@@ -172,7 +172,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, con
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr,
void PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);

///
@@ -187,7 +187,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, co
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned int Aheight,
void PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned int Aheight,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);

///
@@ -202,7 +202,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned int Aheight,
void PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned int Aheight,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);

//////////////////// Section: "quadratric" matrix evaluation ///////////////////////////////
@@ -216,7 +216,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const
/// @param[in] dim - the dimension of matrix trimat (and x).
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch);
void PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch);

///
/// @brief y = x^Tr * trimat * x , in GF(256)
@@ -227,7 +227,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y,
/// @param[in] dim - the dimension of matrix trimat (and x).
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch);
void PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch);

///
/// @brief z = y^Tr * mat * x , in GF(16)
@@ -240,7 +240,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y
/// @param[in] dim_x - the length of x.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned int dim_y,
void PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned int dim_y,
const unsigned char *mat, const unsigned char *x, unsigned int dim_x, unsigned int size_batch);

///
@@ -254,7 +254,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z,
/// @param[in] dim_x - the length of x.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned int dim_y,
void PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned int dim_y,
const unsigned char *mat, const unsigned char *x, unsigned int dim_x, unsigned int size_batch);

#endif // _P_MATRIX_OP_H_

crypto_sign/rainbowIa-cyclic/clean/rainbow.c → crypto_sign/rainbowI-classic/clean/rainbow.c 查看文件

@@ -16,7 +16,7 @@

#define MAX_ATTEMPT_FRMAT 128

int PQCLEAN_RAINBOWIACYCLIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t *sk, const uint8_t *_digest) {
int PQCLEAN_RAINBOWICLASSIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t *sk, const uint8_t *_digest) {
uint8_t mat_l1[_O1 * _O1_BYTE];
uint8_t mat_l2[_O2 * _O2_BYTE];
uint8_t mat_buffer[2 * _MAX_O * _MAX_O_BYTE];
@@ -27,8 +27,8 @@ int PQCLEAN_RAINBOWIACYCLIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t *s
memcpy(prng_preseed, sk->sk_seed, LEN_SKSEED);
memcpy(prng_preseed + LEN_SKSEED, _digest, _HASH_LEN); // prng_preseed = sk_seed || digest
uint8_t prng_seed[_HASH_LEN];
PQCLEAN_RAINBOWIACYCLIC_CLEAN_hash_msg(prng_seed, _HASH_LEN, prng_preseed, _HASH_LEN + LEN_SKSEED);
PQCLEAN_RAINBOWIACYCLIC_CLEAN_prng_set(&prng_sign, prng_seed, _HASH_LEN); // seed = H( sk_seed || digest )
PQCLEAN_RAINBOWICLASSIC_CLEAN_hash_msg(prng_seed, _HASH_LEN, prng_preseed, _HASH_LEN + LEN_SKSEED);
PQCLEAN_RAINBOWICLASSIC_CLEAN_prng_set(&prng_sign, prng_seed, _HASH_LEN); // seed = H( sk_seed || digest )
for (unsigned int i = 0; i < LEN_SKSEED + _HASH_LEN; i++) {
prng_preseed[i] ^= prng_preseed[i]; // clean
}
@@ -44,7 +44,7 @@ int PQCLEAN_RAINBOWIACYCLIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t *s
if (MAX_ATTEMPT_FRMAT <= n_attempt) {
break;
}
PQCLEAN_RAINBOWIACYCLIC_CLEAN_prng_gen(&prng_sign, vinegar, _V1_BYTE); // generating vinegars
PQCLEAN_RAINBOWICLASSIC_CLEAN_prng_gen(&prng_sign, vinegar, _V1_BYTE); // generating vinegars
gfmat_prod(mat_l1, sk->l1_F2, _O1 * _O1_BYTE, _V1, vinegar); // generating the linear equations for layer 1
l1_succ = gfmat_inv(mat_l1, mat_l1, _O1, mat_buffer); // check if the linear equation solvable
n_attempt++;
@@ -65,7 +65,7 @@ int PQCLEAN_RAINBOWIACYCLIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t *s
uint8_t y[_PUB_M_BYTE];
uint8_t *x_v1 = vinegar;
uint8_t x_o1[_O1_BYTE];
uint8_t x_o2[_O1_BYTE];
uint8_t x_o2[_O2_BYTE];

uint8_t digest_salt[_HASH_LEN + _SALT_BYTE];
memcpy(digest_salt, _digest, _HASH_LEN);
@@ -79,31 +79,31 @@ int PQCLEAN_RAINBOWIACYCLIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t *s
}
// The computation: H(digest||salt) --> z --S--> y --C-map--> x --T--> w

PQCLEAN_RAINBOWIACYCLIC_CLEAN_prng_gen(&prng_sign, salt, _SALT_BYTE); // roll the salt
PQCLEAN_RAINBOWIACYCLIC_CLEAN_hash_msg(_z, _PUB_M_BYTE, digest_salt, _HASH_LEN + _SALT_BYTE); // H(digest||salt)
PQCLEAN_RAINBOWICLASSIC_CLEAN_prng_gen(&prng_sign, salt, _SALT_BYTE); // roll the salt
PQCLEAN_RAINBOWICLASSIC_CLEAN_hash_msg(_z, _PUB_M_BYTE, digest_salt, _HASH_LEN + _SALT_BYTE); // H(digest||salt)

// y = S^-1 * z
memcpy(y, _z, _PUB_M_BYTE); // identity part of S
gfmat_prod(temp_o, sk->s1, _O1_BYTE, _O2, _z + _O1_BYTE);
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_add(y, temp_o, _O1_BYTE);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_add(y, temp_o, _O1_BYTE);

// Central Map:
// layer 1: calculate x_o1
memcpy(temp_o, r_l1_F1, _O1_BYTE);
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_add(temp_o, y, _O1_BYTE);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_add(temp_o, y, _O1_BYTE);
gfmat_prod(x_o1, mat_l1, _O1_BYTE, _O1, temp_o);

// layer 2: calculate x_o2
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_set_zero(temp_o, _O2_BYTE);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_set_zero(temp_o, _O2_BYTE);
gfmat_prod(temp_o, mat_l2_F2, _O2_BYTE, _O1, x_o1); // F2
batch_quad_trimat_eval(mat_l2, sk->l2_F5, x_o1, _O1, _O2_BYTE); // F5
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_add(temp_o, mat_l2, _O2_BYTE);
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_add(temp_o, r_l2_F1, _O2_BYTE); // F1
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_add(temp_o, y + _O1_BYTE, _O2_BYTE);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_add(temp_o, mat_l2, _O2_BYTE);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_add(temp_o, r_l2_F1, _O2_BYTE); // F1
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_add(temp_o, y + _O1_BYTE, _O2_BYTE);

// generate the linear equations of the 2nd layer
gfmat_prod(mat_l2, sk->l2_F6, _O2 * _O2_BYTE, _O1, x_o1); // F6
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_add(mat_l2, mat_l2_F3, _O2 * _O2_BYTE); // F3
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_add(mat_l2, mat_l2_F3, _O2 * _O2_BYTE); // F3
succ = gfmat_inv(mat_l2, mat_l2, _O2, mat_buffer);
gfmat_prod(x_o2, mat_l2, _O2_BYTE, _O2, temp_o); // solve l2 eqs

@@ -117,13 +117,13 @@ int PQCLEAN_RAINBOWIACYCLIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t *s
memcpy(w + _V2_BYTE, x_o2, _O2_BYTE);
// Computing the t1 part.
gfmat_prod(y, sk->t1, _V1_BYTE, _O1, x_o1);
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_add(w, y, _V1_BYTE);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_add(w, y, _V1_BYTE);
// Computing the t4 part.
gfmat_prod(y, sk->t4, _V1_BYTE, _O2, x_o2);
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_add(w, y, _V1_BYTE);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_add(w, y, _V1_BYTE);
// Computing the t3 part.
gfmat_prod(y, sk->t3, _O1_BYTE, _O2, x_o2);
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_add(w + _V1_BYTE, y, _O1_BYTE);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_add(w + _V1_BYTE, y, _O1_BYTE);

memset(signature, 0, _SIGNATURE_BYTE); // set the output 0
// clean
@@ -141,12 +141,12 @@ int PQCLEAN_RAINBOWIACYCLIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t *s
if (MAX_ATTEMPT_FRMAT <= n_attempt) {
return -1;
}
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_add(signature, w, _PUB_N_BYTE);
PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_add(signature + _PUB_N_BYTE, salt, _SALT_BYTE);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_add(signature, w, _PUB_N_BYTE);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_add(signature + _PUB_N_BYTE, salt, _SALT_BYTE);
return 0;
}

int PQCLEAN_RAINBOWIACYCLIC_CLEAN_rainbow_verify(const uint8_t *digest, const uint8_t *signature, const pk_t *pk) {
int PQCLEAN_RAINBOWICLASSIC_CLEAN_rainbow_verify(const uint8_t *digest, const uint8_t *signature, const pk_t *pk) {
unsigned char digest_ck[_PUB_M_BYTE];
// public_map( digest_ck , pk , signature ); Evaluating the quadratic public polynomials.
batch_quad_trimat_eval(digest_ck, pk->pk, signature, _PUB_N, _PUB_M_BYTE);
@@ -155,7 +155,7 @@ int PQCLEAN_RAINBOWIACYCLIC_CLEAN_rainbow_verify(const uint8_t *digest, const ui
unsigned char digest_salt[_HASH_LEN + _SALT_BYTE];
memcpy(digest_salt, digest, _HASH_LEN);
memcpy(digest_salt + _HASH_LEN, signature + _PUB_N_BYTE, _SALT_BYTE);
PQCLEAN_RAINBOWIACYCLIC_CLEAN_hash_msg(correct, _PUB_M_BYTE, digest_salt, _HASH_LEN + _SALT_BYTE); // H( digest || salt )
PQCLEAN_RAINBOWICLASSIC_CLEAN_hash_msg(correct, _PUB_M_BYTE, digest_salt, _HASH_LEN + _SALT_BYTE); // H( digest || salt )

// check consistancy.
unsigned char cc = 0;
@@ -166,8 +166,3 @@ int PQCLEAN_RAINBOWIACYCLIC_CLEAN_rainbow_verify(const uint8_t *digest, const ui
}


int PQCLEAN_RAINBOWIACYCLIC_CLEAN_rainbow_verify_cyclic(const uint8_t *digest, const uint8_t *signature, const cpk_t *_pk) {
unsigned char pk[sizeof(pk_t) + 32];
PQCLEAN_RAINBOWIACYCLIC_CLEAN_cpk_to_pk((pk_t *)pk, _pk); // generating classic public key.
return PQCLEAN_RAINBOWIACYCLIC_CLEAN_rainbow_verify(digest, signature, (pk_t *)pk);
}

crypto_sign/rainbowVc-classic/clean/rainbow.h → crypto_sign/rainbowI-classic/clean/rainbow.h 查看文件

@@ -16,7 +16,7 @@
/// @param[in] sk - the secret key.
/// @param[in] digest - the digest.
///
int PQCLEAN_RAINBOWVCCLASSIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t *sk, const uint8_t *digest);
int PQCLEAN_RAINBOWICLASSIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t *sk, const uint8_t *digest);

///
/// @brief Verifying function.
@@ -26,7 +26,7 @@ int PQCLEAN_RAINBOWVCCLASSIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t *
/// @param[in] pk - the public key.
/// @return 0 for successful verified. -1 for failed verification.
///
int PQCLEAN_RAINBOWVCCLASSIC_CLEAN_rainbow_verify(const uint8_t *digest, const uint8_t *signature, const pk_t *pk);
int PQCLEAN_RAINBOWICLASSIC_CLEAN_rainbow_verify(const uint8_t *digest, const uint8_t *signature, const pk_t *pk);




+ 32
- 0
crypto_sign/rainbowI-classic/clean/rainbow_blas.h 查看文件

@@ -0,0 +1,32 @@
#ifndef _RAINBOW_BLAS_H_
#define _RAINBOW_BLAS_H_
/// @file rainbow_blas.h
/// @brief Defining the functions used in rainbow.c acconding to the definitions in rainbow_config.h
///
/// Defining the functions used in rainbow.c acconding to the definitions in rainbow_config.h

#include "blas.h"
#include "blas_comm.h"
#include "parallel_matrix_op.h"
#include "rainbow_config.h"


#define gfv_get_ele PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_get_ele
#define gfv_mul_scalar PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_mul_scalar
#define gfv_madd PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16v_madd

#define gfmat_prod PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16mat_prod
#define gfmat_inv PQCLEAN_RAINBOWICLASSIC_CLEAN_gf16mat_inv

#define batch_trimat_madd PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_trimat_madd_gf16
#define batch_trimatTr_madd PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_trimatTr_madd_gf16
#define batch_2trimat_madd PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_2trimat_madd_gf16
#define batch_matTr_madd PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_matTr_madd_gf16
#define batch_bmatTr_madd PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_bmatTr_madd_gf16
#define batch_mat_madd PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_mat_madd_gf16

#define batch_quad_trimat_eval PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_quad_trimat_eval_gf16
#define batch_quad_recmat_eval PQCLEAN_RAINBOWICLASSIC_CLEAN_batch_quad_recmat_eval_gf16


#endif // _RAINBOW_BLAS_H_

crypto_sign/rainbowIa-cyclic/clean/rainbow_config.h → crypto_sign/rainbowI-classic/clean/rainbow_config.h 查看文件

@@ -7,7 +7,7 @@

#define _USE_GF16
#define _GFSIZE 16
#define _V1 32
#define _V1 36
#define _O1 32
#define _O2 32
#define _MAX_O 32

+ 155
- 0
crypto_sign/rainbowI-classic/clean/rainbow_keypair.c 查看文件

@@ -0,0 +1,155 @@
/// @file rainbow_keypair.c
/// @brief implementations of functions in rainbow_keypair.h
///

#include "rainbow_keypair.h"
#include "blas.h"
#include "blas_comm.h"
#include "rainbow_blas.h"
#include "rainbow_keypair_computation.h"
#include "utils_prng.h"
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

static
void generate_S_T( unsigned char *s_and_t, prng_t *prng0 ) {
sk_t *_sk;
unsigned size;

size = sizeof(_sk->s1);
PQCLEAN_RAINBOWICLASSIC_CLEAN_prng_gen( prng0, s_and_t, size );
s_and_t += size;

size = sizeof(_sk->t1);
PQCLEAN_RAINBOWICLASSIC_CLEAN_prng_gen( prng0, s_and_t, size );
s_and_t += size;

size = sizeof(_sk->t4);
PQCLEAN_RAINBOWICLASSIC_CLEAN_prng_gen( prng0, s_and_t, size );
s_and_t += size;

size = sizeof(_sk->t3);
PQCLEAN_RAINBOWICLASSIC_CLEAN_prng_gen( prng0, s_and_t, size );
}


static
unsigned generate_l1_F12( unsigned char *sk, prng_t *prng0 ) {
unsigned n_byte_generated = 0;
sk_t *_sk;
unsigned size;

size = sizeof(_sk->l1_F1);
PQCLEAN_RAINBOWICLASSIC_CLEAN_prng_gen( prng0, sk, size );
sk += size;
n_byte_generated += size;

size = sizeof(_sk->l1_F2);
PQCLEAN_RAINBOWICLASSIC_CLEAN_prng_gen( prng0, sk, size );
n_byte_generated += size;

return n_byte_generated;
}


static
unsigned generate_l2_F12356( unsigned char *sk, prng_t *prng0 ) {
unsigned n_byte_generated = 0;
sk_t *_sk;
unsigned size;

size = sizeof(_sk->l2_F1);
PQCLEAN_RAINBOWICLASSIC_CLEAN_prng_gen( prng0, sk, size );
sk += size;
n_byte_generated += size;

size = sizeof(_sk->l2_F2);
PQCLEAN_RAINBOWICLASSIC_CLEAN_prng_gen( prng0, sk, size );
sk += size;
n_byte_generated += size;

size = sizeof(_sk->l2_F3);
PQCLEAN_RAINBOWICLASSIC_CLEAN_prng_gen( prng0, sk, size );
sk += size;
n_byte_generated += size;

size = sizeof(_sk->l2_F5);
PQCLEAN_RAINBOWICLASSIC_CLEAN_prng_gen( prng0, sk, size );
sk += size;
n_byte_generated += size;

size = sizeof(_sk->l2_F6);
PQCLEAN_RAINBOWICLASSIC_CLEAN_prng_gen( prng0, sk, size );
n_byte_generated += size;

return n_byte_generated;
}


static void generate_B1_B2(unsigned char *sk, prng_t *prng0) {
sk += generate_l1_F12(sk, prng0);
generate_l2_F12356(sk, prng0);
}

static void calculate_t4(unsigned char *t2_to_t4, const unsigned char *t1, const unsigned char *t3) {
// t4 = T_sk.t1 * T_sk.t3 - T_sk.t2
unsigned char temp[_V1_BYTE + 32];
unsigned char *t4 = t2_to_t4;
for (unsigned int i = 0; i < _O2; i++) { /// t3 width
gfmat_prod(temp, t1, _V1_BYTE, _O1, t3);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_add(t4, temp, _V1_BYTE);
t4 += _V1_BYTE;
t3 += _O1_BYTE;
}
}

static void obsfucate_l1_polys(unsigned char *l1_polys, const unsigned char *l2_polys, unsigned int n_terms, const unsigned char *s1) {
unsigned char temp[_O1_BYTE + 32];
while (n_terms--) {
gfmat_prod(temp, s1, _O1_BYTE, _O2, l2_polys);
PQCLEAN_RAINBOWICLASSIC_CLEAN_gf256v_add(l1_polys, temp, _O1_BYTE);
l1_polys += _O1_BYTE;
l2_polys += _O2_BYTE;
}
}

/////////////////// Classic //////////////////////////////////

static void generate_secretkey(sk_t *sk, const unsigned char *sk_seed) {
memcpy(sk->sk_seed, sk_seed, LEN_SKSEED);

// set up prng
prng_t prng0;
PQCLEAN_RAINBOWICLASSIC_CLEAN_prng_set(&prng0, sk_seed, LEN_SKSEED);

// generating secret key with prng.
generate_S_T(sk->s1, &prng0);
generate_B1_B2(sk->l1_F1, &prng0);

// clean prng
memset(&prng0, 0, sizeof(prng_t));
}

void PQCLEAN_RAINBOWICLASSIC_CLEAN_generate_keypair(pk_t *rpk, sk_t *sk, const unsigned char *sk_seed) {
generate_secretkey(sk, sk_seed);

// set up a temporary structure ext_cpk_t for calculating public key.
ext_cpk_t pk;

PQCLEAN_RAINBOWICLASSIC_CLEAN_calculate_Q_from_F(&pk, sk, sk); // compute the public key in ext_cpk_t format.
calculate_t4(sk->t4, sk->t1, sk->t3);

obsfucate_l1_polys(pk.l1_Q1, pk.l2_Q1, N_TRIANGLE_TERMS(_V1), sk->s1);
obsfucate_l1_polys(pk.l1_Q2, pk.l2_Q2, _V1 * _O1, sk->s1);
obsfucate_l1_polys(pk.l1_Q3, pk.l2_Q3, _V1 * _O2, sk->s1);
obsfucate_l1_polys(pk.l1_Q5, pk.l2_Q5, N_TRIANGLE_TERMS(_O1), sk->s1);
obsfucate_l1_polys(pk.l1_Q6, pk.l2_Q6, _O1 * _O2, sk->s1);
obsfucate_l1_polys(pk.l1_Q9, pk.l2_Q9, N_TRIANGLE_TERMS(_O2), sk->s1);
// so far, the pk contains the full pk but in ext_cpk_t format.

PQCLEAN_RAINBOWICLASSIC_CLEAN_extcpk_to_pk(rpk, &pk); // convert the public key from ext_cpk_t to pk_t.
}




crypto_sign/rainbowIa-classic/clean/rainbow_keypair.h → crypto_sign/rainbowI-classic/clean/rainbow_keypair.h 查看文件

@@ -52,7 +52,7 @@ typedef struct rainbow_secretkey {
/// @param[out] sk - the secret key.
/// @param[in] sk_seed - seed for generating the secret key.
///
void PQCLEAN_RAINBOWIACLASSIC_CLEAN_generate_keypair(pk_t *pk, sk_t *sk, const unsigned char *sk_seed);
void PQCLEAN_RAINBOWICLASSIC_CLEAN_generate_keypair(pk_t *pk, sk_t *sk, const unsigned char *sk_seed);




crypto_sign/rainbowVc-classic/clean/rainbow_keypair_computation.c → crypto_sign/rainbowI-classic/clean/rainbow_keypair_computation.c 查看文件

@@ -11,12 +11,12 @@
#include <stdlib.h>
#include <string.h>

void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) {
void PQCLEAN_RAINBOWICLASSIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) {
const unsigned char *idx_l1 = cpk->l1_Q1;
const unsigned char *idx_l2 = cpk->l2_Q1;
for (unsigned int i = 0; i < _V1; i++) {
for (unsigned int j = i; j < _V1; j++) {
unsigned int pub_idx = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N);
unsigned int pub_idx = PQCLEAN_RAINBOWICLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N);
memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE);
memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE);
idx_l1 += _O1_BYTE;
@@ -27,7 +27,7 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk)
idx_l2 = cpk->l2_Q2;
for (unsigned int i = 0; i < _V1; i++) {
for (unsigned int j = _V1; j < _V1 + _O1; j++) {
unsigned int pub_idx = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N);
unsigned int pub_idx = PQCLEAN_RAINBOWICLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N);
memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE);
memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE);
idx_l1 += _O1_BYTE;
@@ -38,7 +38,7 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk)
idx_l2 = cpk->l2_Q3;
for (unsigned int i = 0; i < _V1; i++) {
for (unsigned int j = _V1 + _O1; j < _PUB_N; j++) {
unsigned int pub_idx = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N);
unsigned int pub_idx = PQCLEAN_RAINBOWICLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N);
memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE);
memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE);
idx_l1 += _O1_BYTE;
@@ -49,7 +49,7 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk)
idx_l2 = cpk->l2_Q5;
for (unsigned int i = _V1; i < _V1 + _O1; i++) {
for (unsigned int j = i; j < _V1 + _O1; j++) {
unsigned int pub_idx = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N);
unsigned int pub_idx = PQCLEAN_RAINBOWICLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N);
memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE);
memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE);
idx_l1 += _O1_BYTE;
@@ -60,7 +60,7 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk)
idx_l2 = cpk->l2_Q6;
for (unsigned int i = _V1; i < _V1 + _O1; i++) {
for (unsigned int j = _V1 + _O1; j < _PUB_N; j++) {
unsigned int pub_idx = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N);
unsigned int pub_idx = PQCLEAN_RAINBOWICLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N);
memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE);
memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE);
idx_l1 += _O1_BYTE;
@@ -71,7 +71,7 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk)
idx_l2 = cpk->l2_Q9;
for (unsigned int i = _V1 + _O1; i < _PUB_N; i++) {
for (unsigned int j = i; j < _PUB_N; j++) {
unsigned int pub_idx = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N);
unsigned int pub_idx = PQCLEAN_RAINBOWICLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N);
memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE);
memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE);
idx_l1 += _O1_BYTE;
@@ -106,11 +106,11 @@ static void calculate_Q_from_F_ref(ext_cpk_t *Qs, const sk_t *Fs, const sk_t *Ts
// l2_Q5 : _O2_BYTE * _V1 * _O1
// l2_Q9 : _O2_BYTE * _V1 * _O2

unsigned char tempQ[_O1_BYTE * _O1 * _O1 + 32];
unsigned char tempQ[_MAX_O_BYTE * _MAX_O * _MAX_O + 32];

memset(tempQ, 0, _O1_BYTE * _O1 * _O1); // l1_Q5
batch_matTr_madd(tempQ, Ts->t1, _V1, _V1_BYTE, _O1, Qs->l1_Q2, _O1, _O1_BYTE); // t1_tr*(F1*T1 + F2)
PQCLEAN_RAINBOWVCCLASSIC_CLEAN_UpperTrianglize(Qs->l1_Q5, tempQ, _O1, _O1_BYTE); // UT( ... ) // Q5
PQCLEAN_RAINBOWICLASSIC_CLEAN_UpperTrianglize(Qs->l1_Q5, tempQ, _O1, _O1_BYTE); // UT( ... ) // Q5

batch_trimatTr_madd(Qs->l1_Q2, Fs->l1_F1, Ts->t1, _V1, _V1_BYTE, _O1, _O1_BYTE); // Q2
/*
@@ -127,7 +127,7 @@ static void calculate_Q_from_F_ref(ext_cpk_t *Qs, const sk_t *Fs, const sk_t *Ts

memset(tempQ, 0, _O1_BYTE * _O2 * _O2); // l1_Q9
batch_matTr_madd(tempQ, t2, _V1, _V1_BYTE, _O2, Qs->l1_Q3, _O2, _O1_BYTE); // T2tr * ( F1_T2 + F2_T3 )
PQCLEAN_RAINBOWVCCLASSIC_CLEAN_UpperTrianglize(Qs->l1_Q9, tempQ, _O2, _O1_BYTE); // Q9
PQCLEAN_RAINBOWICLASSIC_CLEAN_UpperTrianglize(Qs->l1_Q9, tempQ, _O2, _O1_BYTE); // Q9

batch_trimatTr_madd(Qs->l1_Q3, Fs->l1_F1, t2, _V1, _V1_BYTE, _O2, _O1_BYTE); // F1_F1T_T2 + F2_T3 // Q3

@@ -149,7 +149,7 @@ static void calculate_Q_from_F_ref(ext_cpk_t *Qs, const sk_t *Fs, const sk_t *Ts
memcpy(Qs->l2_Q5, Fs->l2_F5, _O2_BYTE * N_TRIANGLE_TERMS(_O1));
memset(tempQ, 0, _O2_BYTE * _O1 * _O1); // l2_Q5
batch_matTr_madd(tempQ, Ts->t1, _V1, _V1_BYTE, _O1, Qs->l2_Q2, _O1, _O2_BYTE); // t1_tr*(F1*T1 + F2)
PQCLEAN_RAINBOWVCCLASSIC_CLEAN_UpperTrianglize(Qs->l2_Q5, tempQ, _O1, _O2_BYTE); // UT( ... ) // Q5
PQCLEAN_RAINBOWICLASSIC_CLEAN_UpperTrianglize(Qs->l2_Q5, tempQ, _O1, _O2_BYTE); // UT( ... ) // Q5

batch_trimatTr_madd(Qs->l2_Q2, Fs->l2_F1, Ts->t1, _V1, _V1_BYTE, _O1, _O2_BYTE); // Q2

@@ -175,7 +175,7 @@ static void calculate_Q_from_F_ref(ext_cpk_t *Qs, const sk_t *Fs, const sk_t *Ts
batch_trimat_madd(Qs->l2_Q6, Fs->l2_F5, Ts->t3, _O1, _O1_BYTE, _O2, _O2_BYTE); // F5*T3 + F6
batch_matTr_madd(tempQ, Ts->t3, _O1, _O1_BYTE, _O2, Qs->l2_Q6, _O2, _O2_BYTE); // T2tr*( ..... ) + T3tr*( ..... )
memset(Qs->l2_Q9, 0, _O2_BYTE * N_TRIANGLE_TERMS(_O2));
PQCLEAN_RAINBOWVCCLASSIC_CLEAN_UpperTrianglize(Qs->l2_Q9, tempQ, _O2, _O2_BYTE); // Q9
PQCLEAN_RAINBOWICLASSIC_CLEAN_UpperTrianglize(Qs->l2_Q9, tempQ, _O2, _O2_BYTE); // Q9

batch_trimatTr_madd(Qs->l2_Q3, Fs->l2_F1, t2, _V1, _V1_BYTE, _O2, _O2_BYTE); // F1_F1T_T2 + F2_T3 + F3 // Q3

@@ -184,6 +184,6 @@ static void calculate_Q_from_F_ref(ext_cpk_t *Qs, const sk_t *Fs, const sk_t *Ts
batch_matTr_madd(Qs->l2_Q6, Ts->t1, _V1, _V1_BYTE, _O1, Qs->l2_Q3, _O2, _O2_BYTE); // Q6
}
#define calculate_Q_from_F_impl calculate_Q_from_F_ref
void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_calculate_Q_from_F(ext_cpk_t *Qs, const sk_t *Fs, const sk_t *Ts) {
void PQCLEAN_RAINBOWICLASSIC_CLEAN_calculate_Q_from_F(ext_cpk_t *Qs, const sk_t *Fs, const sk_t *Ts) {
calculate_Q_from_F_impl(Qs, Fs, Ts);
}

crypto_sign/rainbowVc-classic/clean/rainbow_keypair_computation.h → crypto_sign/rainbowI-classic/clean/rainbow_keypair_computation.h 查看文件

@@ -37,7 +37,7 @@ typedef struct rainbow_extend_publickey {
/// @param[out] pk - the classic public key.
/// @param[in] cpk - the internel public key.
///
void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk);
void PQCLEAN_RAINBOWICLASSIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk);
/////////////////////////////////////////////////

///
@@ -47,7 +47,7 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk)
/// @param[in] Fs - parts of the secret key: l1_F1, l1_F2, l2_F1, l2_F2, l2_F3, l2_F5, l2_F6
/// @param[in] Ts - parts of the secret key: T1, T4, T3
///
void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_calculate_Q_from_F(ext_cpk_t *Qs, const sk_t *Fs, const sk_t *Ts);
void PQCLEAN_RAINBOWICLASSIC_CLEAN_calculate_Q_from_F(ext_cpk_t *Qs, const sk_t *Fs, const sk_t *Ts);


#endif // _RAINBOW_KEYPAIR_COMP_H_

crypto_sign/rainbowVc-cyclic/clean/sign.c → crypto_sign/rainbowI-classic/clean/sign.c 查看文件

@@ -12,28 +12,26 @@
#include <stdlib.h>
#include <string.h>

int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_crypto_sign_keypair(unsigned char *pk, unsigned char *sk) {
int PQCLEAN_RAINBOWICLASSIC_CLEAN_crypto_sign_keypair(unsigned char *pk, unsigned char *sk) {
unsigned char sk_seed[LEN_SKSEED] = {0};
randombytes(sk_seed, LEN_SKSEED);

unsigned char pk_seed[LEN_PKSEED] = {0};
randombytes(pk_seed, LEN_PKSEED);
PQCLEAN_RAINBOWVCCYCLIC_CLEAN_generate_keypair_cyclic((cpk_t *)pk, (sk_t *)sk, pk_seed, sk_seed);
PQCLEAN_RAINBOWICLASSIC_CLEAN_generate_keypair((pk_t *)pk, (sk_t *)sk, sk_seed);
return 0;
}

int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_crypto_sign(unsigned char *sm, size_t *smlen, const unsigned char *m, size_t mlen, const unsigned char *sk) {
int PQCLEAN_RAINBOWICLASSIC_CLEAN_crypto_sign(unsigned char *sm, size_t *smlen, const unsigned char *m, size_t mlen, const unsigned char *sk) {
unsigned char digest[_HASH_LEN];

PQCLEAN_RAINBOWVCCYCLIC_CLEAN_hash_msg(digest, _HASH_LEN, m, mlen);
PQCLEAN_RAINBOWICLASSIC_CLEAN_hash_msg(digest, _HASH_LEN, m, mlen);

memcpy(sm, m, mlen);
smlen[0] = mlen + _SIGNATURE_BYTE;

return PQCLEAN_RAINBOWVCCYCLIC_CLEAN_rainbow_sign(sm + mlen, (const sk_t *)sk, digest);
return PQCLEAN_RAINBOWICLASSIC_CLEAN_rainbow_sign(sm + mlen, (const sk_t *)sk, digest);
}

int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_crypto_sign_open(unsigned char *m, size_t *mlen, const unsigned char *sm, size_t smlen, const unsigned char *pk) {
int PQCLEAN_RAINBOWICLASSIC_CLEAN_crypto_sign_open(unsigned char *m, size_t *mlen, const unsigned char *sm, size_t smlen, const unsigned char *pk) {
int rc;
if (_SIGNATURE_BYTE > smlen) {
rc = -1;
@@ -41,9 +39,9 @@ int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_crypto_sign_open(unsigned char *m, size_t *mle
*mlen = smlen - _SIGNATURE_BYTE;

unsigned char digest[_HASH_LEN];
PQCLEAN_RAINBOWVCCYCLIC_CLEAN_hash_msg(digest, _HASH_LEN, sm, *mlen);
PQCLEAN_RAINBOWICLASSIC_CLEAN_hash_msg(digest, _HASH_LEN, sm, *mlen);

rc = PQCLEAN_RAINBOWVCCYCLIC_CLEAN_rainbow_verify_cyclic(digest, sm + mlen[0], (const cpk_t *)pk);
rc = PQCLEAN_RAINBOWICLASSIC_CLEAN_rainbow_verify(digest, sm + mlen[0], (const pk_t *)pk);
}
if (!rc) {
memmove(m, sm, smlen - _SIGNATURE_BYTE);
@@ -54,23 +52,23 @@ int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_crypto_sign_open(unsigned char *m, size_t *mle
return rc;
}

int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_crypto_sign_signature(
int PQCLEAN_RAINBOWICLASSIC_CLEAN_crypto_sign_signature(
uint8_t *sig, size_t *siglen,
const uint8_t *m, size_t mlen, const uint8_t *sk) {
unsigned char digest[_HASH_LEN];

PQCLEAN_RAINBOWVCCYCLIC_CLEAN_hash_msg(digest, _HASH_LEN, m, mlen);
PQCLEAN_RAINBOWICLASSIC_CLEAN_hash_msg(digest, _HASH_LEN, m, mlen);
*siglen = _SIGNATURE_BYTE;
return PQCLEAN_RAINBOWVCCYCLIC_CLEAN_rainbow_sign(sig, (const sk_t *)sk, digest);
return PQCLEAN_RAINBOWICLASSIC_CLEAN_rainbow_sign(sig, (const sk_t *)sk, digest);
}

int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_crypto_sign_verify(
int PQCLEAN_RAINBOWICLASSIC_CLEAN_crypto_sign_verify(
const uint8_t *sig, size_t siglen,
const uint8_t *m, size_t mlen, const uint8_t *pk) {
if (siglen != _SIGNATURE_BYTE) {
return -1;
}
unsigned char digest[_HASH_LEN];
PQCLEAN_RAINBOWVCCYCLIC_CLEAN_hash_msg(digest, _HASH_LEN, m, mlen);
return PQCLEAN_RAINBOWVCCYCLIC_CLEAN_rainbow_verify_cyclic(digest, sig, (const cpk_t *)pk);
PQCLEAN_RAINBOWICLASSIC_CLEAN_hash_msg(digest, _HASH_LEN, m, mlen);
return PQCLEAN_RAINBOWICLASSIC_CLEAN_rainbow_verify(digest, sig, (const pk_t *)pk);
}

crypto_sign/rainbowIa-cyclic/clean/utils_hash.c → crypto_sign/rainbowI-classic/clean/utils_hash.c 查看文件

@@ -7,7 +7,7 @@
#include "rainbow_config.h"
#include "sha2.h"

static inline int _hash(unsigned char *digest, const unsigned char *m, size_t mlen) {
static inline int h(unsigned char *digest, const unsigned char *m, size_t mlen) {
sha256(digest, m, mlen);
return 0;
}
@@ -25,14 +25,14 @@ static inline int expand_hash(unsigned char *digest, size_t n_digest, const unsi
n_digest -= _HASH_LEN;

while (_HASH_LEN <= n_digest) {
_hash(digest + _HASH_LEN, digest, _HASH_LEN);
h(digest + _HASH_LEN, digest, _HASH_LEN);

n_digest -= _HASH_LEN;
digest += _HASH_LEN;
}
unsigned char temp[_HASH_LEN];
if (n_digest) {
_hash(temp, digest, _HASH_LEN);
h(temp, digest, _HASH_LEN);
for (size_t i = 0; i < n_digest; i++) {
digest[_HASH_LEN + i] = temp[i];
}
@@ -40,11 +40,11 @@ static inline int expand_hash(unsigned char *digest, size_t n_digest, const unsi
return 0;
}

int PQCLEAN_RAINBOWIACYCLIC_CLEAN_hash_msg(unsigned char *digest,
int PQCLEAN_RAINBOWICLASSIC_CLEAN_hash_msg(unsigned char *digest,
size_t len_digest,
const unsigned char *m,
size_t mlen) {
unsigned char buf[_HASH_LEN];
_hash(buf, m, mlen);
h(buf, m, mlen);
return expand_hash(digest, len_digest, buf);
}

crypto_sign/rainbowIa-cyclic/clean/utils_hash.h → crypto_sign/rainbowI-classic/clean/utils_hash.h 查看文件

@@ -6,6 +6,6 @@

#include <stddef.h>

int PQCLEAN_RAINBOWIACYCLIC_CLEAN_hash_msg(unsigned char *digest, size_t len_digest, const unsigned char *m, size_t mlen);
int PQCLEAN_RAINBOWICLASSIC_CLEAN_hash_msg(unsigned char *digest, size_t len_digest, const unsigned char *m, size_t mlen);

#endif // _UTILS_HASH_H_

crypto_sign/rainbowVc-cyclic/clean/utils_prng.c → crypto_sign/rainbowI-classic/clean/utils_prng.c 查看文件

@@ -78,13 +78,13 @@ static int randombytes_with_state(prng_t *state,
return 0;
}

int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_prng_set(prng_t *ctx, const void *prng_seed, unsigned long prng_seedlen) {
int PQCLEAN_RAINBOWICLASSIC_CLEAN_prng_set(prng_t *ctx, const void *prng_seed, unsigned long prng_seedlen) {
unsigned char seed[48];
if (prng_seedlen >= 48) {
memcpy(seed, prng_seed, 48);
} else {
memcpy(seed, prng_seed, prng_seedlen);
PQCLEAN_RAINBOWVCCYCLIC_CLEAN_hash_msg(seed + prng_seedlen, 48 - (unsigned)prng_seedlen, (const unsigned char *)prng_seed, prng_seedlen);
PQCLEAN_RAINBOWICLASSIC_CLEAN_hash_msg(seed + prng_seedlen, 48 - (unsigned)prng_seedlen, (const unsigned char *)prng_seed, prng_seedlen);
}

randombytes_init_with_state(ctx, seed);
@@ -92,6 +92,6 @@ int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_prng_set(prng_t *ctx, const void *prng_seed, u
return 0;
}

int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_prng_gen(prng_t *ctx, unsigned char *out, unsigned long outlen) {
int PQCLEAN_RAINBOWICLASSIC_CLEAN_prng_gen(prng_t *ctx, unsigned char *out, unsigned long outlen) {
return randombytes_with_state(ctx, out, outlen);
}

crypto_sign/rainbowVc-cyclic/clean/utils_prng.h → crypto_sign/rainbowI-classic/clean/utils_prng.h 查看文件

@@ -12,7 +12,7 @@ typedef struct {
unsigned char V[16];
} prng_t;

int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_prng_set(prng_t *ctx, const void *prng_seed, unsigned long prng_seedlen);
int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_prng_gen(prng_t *ctx, unsigned char *out, unsigned long outlen);
int PQCLEAN_RAINBOWICLASSIC_CLEAN_prng_set(prng_t *ctx, const void *prng_seed, unsigned long prng_seedlen);
int PQCLEAN_RAINBOWICLASSIC_CLEAN_prng_gen(prng_t *ctx, unsigned char *out, unsigned long outlen);

#endif // _UTILS_PRNG_H_

+ 20
- 0
crypto_sign/rainbowI-compressed/META.yml 查看文件

@@ -0,0 +1,20 @@
name: "RAINBOW(16,36,32,32) - compressed"
type: signature
claimed-nist-level: 1
length-public-key: 60192
length-secret-key: 64
length-signature: 66
nistkat-sha256: 6ff3ff91f17c85593317f18a9de09acf4204c45d620250cb948c9fbc9042f1e9
testvectors-sha256: 0a2ebcb8cf748ea51510eecc17d7af73d1f831fbe0db9330fbab9b4916d0c57b
principal-submitters:
- Jintai Ding
auxiliary-submitters:
- Ming-Shing Chen
- Matthias Kannwischer
- Jacques Patarin
- Albrecht Petzoldt
- Dieter Schmidt
- Bo-Yin Yang
implementations:
- name: clean
version: https://github.com/fast-crypto-lab/rainbow-submission-round2/commit/173ada0e077e1b9dbd8e4a78994f87acc0c92263

crypto_sign/rainbowIIIc-cyclic/clean/LICENSE → crypto_sign/rainbowI-compressed/clean/LICENSE 查看文件


crypto_sign/rainbowIIIc-classic/clean/Makefile → crypto_sign/rainbowI-compressed/clean/Makefile 查看文件

@@ -1,6 +1,6 @@
# This Makefile can be used with GNU Make or BSD Make

LIB=librainbowIIIc-classic_clean.a
LIB=librainbowI-compressed_clean.a

HEADERS = api.h blas_comm.h blas.h gf.h parallel_matrix_op.h rainbow_blas.h rainbow_config.h rainbow.h rainbow_keypair_computation.h rainbow_keypair.h utils_hash.h utils_prng.h
OBJECTS = blas_comm.o parallel_matrix_op.o rainbow.o rainbow_keypair.o rainbow_keypair_computation.o sign.o utils_hash.o utils_prng.o blas.o gf.o

crypto_sign/rainbowIIIc-classic/clean/Makefile.Microsoft_nmake → crypto_sign/rainbowI-compressed/clean/Makefile.Microsoft_nmake 查看文件

@@ -1,7 +1,7 @@
# This Makefile can be used with Microsoft Visual Studio's nmake using the command:
# nmake /f Makefile.Microsoft_nmake

LIBRARY=librainbowIIIc-classic_clean.lib
LIBRARY=librainbowI-compressed_clean.lib
OBJECTS = blas_comm.obj parallel_matrix_op.obj rainbow.obj rainbow_keypair.obj rainbow_keypair_computation.obj sign.obj utils_hash.obj utils_prng.obj blas.obj gf.obj

CFLAGS=/nologo /O2 /I ..\..\..\common /W4 /WX

+ 32
- 0
crypto_sign/rainbowI-compressed/clean/api.h 查看文件

@@ -0,0 +1,32 @@
#ifndef PQCLEAN_RAINBOWICOMPRESSED_CLEAN_API_H
#define PQCLEAN_RAINBOWICOMPRESSED_CLEAN_API_H

#include <stddef.h>
#include <stdint.h>

#define PQCLEAN_RAINBOWICOMPRESSED_CLEAN_CRYPTO_SECRETKEYBYTES 64
#define PQCLEAN_RAINBOWICOMPRESSED_CLEAN_CRYPTO_PUBLICKEYBYTES 60192
#define PQCLEAN_RAINBOWICOMPRESSED_CLEAN_CRYPTO_BYTES 66
#define PQCLEAN_RAINBOWICOMPRESSED_CLEAN_CRYPTO_ALGNAME "RAINBOW(16,36,32,32) - compressed"

int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_crypto_sign_keypair(uint8_t *pk, uint8_t *sk);


int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_crypto_sign_signature(
uint8_t *sig, size_t *siglen,
const uint8_t *m, size_t mlen, const uint8_t *sk);

int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_crypto_sign_verify(
const uint8_t *sig, size_t siglen,
const uint8_t *m, size_t mlen, const uint8_t *pk);

int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_crypto_sign(uint8_t *sm, size_t *smlen,
const uint8_t *m, size_t mlen,
const uint8_t *sk);

int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_crypto_sign_open(uint8_t *m, size_t *mlen,
const uint8_t *sm, size_t smlen,
const uint8_t *pk);


#endif

+ 43
- 0
crypto_sign/rainbowI-compressed/clean/blas.c 查看文件

@@ -0,0 +1,43 @@
#include "blas.h"
#include "gf.h"

#include <stddef.h>

void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_predicated_add(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, size_t _num_byte) {
uint8_t pr_u8 = (uint8_t) ((uint8_t) 0 - predicate);
for (size_t i = 0; i < _num_byte; i++) {
accu_b[i] ^= (a[i] & pr_u8);
}
}

void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_add(uint8_t *accu_b, const uint8_t *a, size_t _num_byte) {
for (size_t i = 0; i < _num_byte; i++) {
accu_b[i] ^= a[i];
}
}


void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_mul_scalar(uint8_t *a, uint8_t gf16_b, size_t _num_byte) {
uint8_t tmp;
for (size_t i = 0; i < _num_byte; i++) {
tmp = PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16_mul(a[i] & 0xF, gf16_b);
tmp |= (uint8_t) (PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16_mul(a[i] >> 4, gf16_b) << 4);
a[i] = tmp;
}
}

void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_madd(uint8_t *accu_c, const uint8_t *a, uint8_t gf16_b, size_t _num_byte) {
for (size_t i = 0; i < _num_byte; i++) {
accu_c[i] ^= PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16_mul(a[i] & 0xF, gf16_b);
accu_c[i] ^= (uint8_t) (PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16_mul(a[i] >> 4, gf16_b) << 4);
}
}

uint8_t PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_dot(const uint8_t *a, const uint8_t *b, size_t _num_byte) {
uint8_t r = 0;
for (size_t i = 0; i < _num_byte; i++) {
r ^= PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16_mul(a[i], b[i]);
}
return r;
}


+ 20
- 0
crypto_sign/rainbowI-compressed/clean/blas.h 查看文件

@@ -0,0 +1,20 @@
#ifndef _BLAS_H_
#define _BLAS_H_
/// @file blas.h
/// @brief Functions for implementing basic linear algebra functions.
///

#include "rainbow_config.h"
#include <stddef.h>
#include <stdint.h>

void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_predicated_add(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, size_t _num_byte);
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_add(uint8_t *accu_b, const uint8_t *a, size_t _num_byte);


void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_madd(uint8_t *accu_c, const uint8_t *a, uint8_t gf16_b, size_t _num_byte);
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_mul_scalar(uint8_t *a, uint8_t gf16_b, size_t _num_byte);
uint8_t PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_dot(const uint8_t *a, const uint8_t *b, size_t _num_byte);


#endif // _BLAS_H_

crypto_sign/rainbowIa-classic/clean/blas_comm.c → crypto_sign/rainbowI-compressed/clean/blas_comm.c 查看文件

@@ -10,7 +10,7 @@
#include <stdint.h>
#include <string.h>

void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte) {
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte) {
for (size_t i = 0; i < _num_byte; i++) {
b[i] = 0;
}
@@ -22,7 +22,7 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _nu
/// @param[in] i - the index in the vector a.
/// @return the value of the element.
///
uint8_t PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned int i) {
uint8_t PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned int i) {
uint8_t r = a[i >> 1];
uint8_t r0 = r & 0xf;
uint8_t r1 = r >> 4;
@@ -37,7 +37,7 @@ uint8_t PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned
/// @param[in] v - the value for the i-th element in vector a.
/// @return the value of the element.
///
static uint8_t PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_set_ele(uint8_t *a, unsigned int i, uint8_t v) {
static uint8_t PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_set_ele(uint8_t *a, unsigned int i, uint8_t v) {
uint8_t m = (uint8_t)(0xf ^ (-((int8_t)i & 1))); /// 1--> 0xf0 , 0--> 0x0f
uint8_t ai_remaining = (uint8_t)(a[i >> 1] & (~m)); /// erase
a[i >> 1] = (uint8_t)(ai_remaining | (m & (v << 4)) | (m & v & 0xf)); /// set
@@ -45,22 +45,22 @@ static uint8_t PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_set_ele(uint8_t *a, unsigned
}

static void gf16mat_prod_ref(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b) {
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_set_zero(c, n_A_vec_byte);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_set_zero(c, n_A_vec_byte);
for (unsigned int i = 0; i < n_A_width; i++) {
uint8_t bb = PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(b, i);
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_madd(c, matA, bb, n_A_vec_byte);
uint8_t bb = PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_get_ele(b, i);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_madd(c, matA, bb, n_A_vec_byte);
matA += n_A_vec_byte;
}
}

void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec) {
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec) {
unsigned int n_vec_byte = (len_vec + 1) / 2;
for (unsigned int k = 0; k < len_vec; k++) {
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_set_zero(c, n_vec_byte);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_set_zero(c, n_vec_byte);
const uint8_t *bk = b + n_vec_byte * k;
for (unsigned int i = 0; i < len_vec; i++) {
uint8_t bb = PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(bk, i);
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_madd(c, a + n_vec_byte * i, bb, n_vec_byte);
uint8_t bb = PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_get_ele(bk, i);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_madd(c, a + n_vec_byte * i, bb, n_vec_byte);
}
c += n_vec_byte;
}
@@ -74,19 +74,19 @@ static unsigned int gf16mat_gauss_elim_ref(uint8_t *mat, unsigned int h, unsigne
uint8_t *ai = mat + n_w_byte * i;
for (unsigned int j = i + 1; j < h; j++) {
uint8_t *aj = mat + n_w_byte * j;
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_predicated_add(ai + offset_byte, 1 ^ PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16_is_nonzero(PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(ai, i)), aj + offset_byte, n_w_byte - offset_byte);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_predicated_add(ai + offset_byte, 1 ^ PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16_is_nonzero(PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_get_ele(ai, i)), aj + offset_byte, n_w_byte - offset_byte);
}
uint8_t pivot = PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(ai, i);
r8 &= PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16_is_nonzero(pivot);
pivot = PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16_inv(pivot);
uint8_t pivot = PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_get_ele(ai, i);
r8 &= PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16_is_nonzero(pivot);
pivot = PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16_inv(pivot);
offset_byte = (i + 1) >> 1;
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_mul_scalar(ai + offset_byte, pivot, n_w_byte - offset_byte);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_mul_scalar(ai + offset_byte, pivot, n_w_byte - offset_byte);
for (unsigned int j = 0; j < h; j++) {
if (i == j) {
continue;
}
uint8_t *aj = mat + n_w_byte * j;
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_madd(aj + offset_byte, ai + offset_byte, PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(aj, i), n_w_byte - offset_byte);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_madd(aj + offset_byte, ai + offset_byte, PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_get_ele(aj, i), n_w_byte - offset_byte);
}
}
return r8;
@@ -97,11 +97,11 @@ static unsigned int gf16mat_solve_linear_eq_ref(uint8_t *sol, const uint8_t *inp
unsigned int n_byte = (n + 1) >> 1;
for (unsigned int i = 0; i < n; i++) {
memcpy(mat + i * (n_byte + 1), inp_mat + i * n_byte, n_byte);
mat[i * (n_byte + 1) + n_byte] = PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(c_terms, i);
mat[i * (n_byte + 1) + n_byte] = PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_get_ele(c_terms, i);
}
unsigned int r8 = PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_gauss_elim(mat, n, n + 2);
unsigned int r8 = PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16mat_gauss_elim(mat, n, n + 2);
for (unsigned int i = 0; i < n; i++) {
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_set_ele(sol, i, mat[i * (n_byte + 1) + n_byte]);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_set_ele(sol, i, mat[i * (n_byte + 1) + n_byte]);
}
return r8;
}
@@ -117,17 +117,17 @@ static inline void gf16mat_submat(uint8_t *mat2, unsigned int w2, unsigned int s
}
}

unsigned int PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer) {
unsigned int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer) {
unsigned int n_w_byte = (H + 1) / 2;

uint8_t *aa = buffer;
for (unsigned int i = 0; i < H; i++) {
uint8_t *ai = aa + i * 2 * n_w_byte;
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_set_zero(ai, 2 * n_w_byte);
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_add(ai, a + i * n_w_byte, n_w_byte);
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_set_ele(ai + n_w_byte, i, 1);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_set_zero(ai, 2 * n_w_byte);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_add(ai, a + i * n_w_byte, n_w_byte);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_set_ele(ai + n_w_byte, i, 1);
}
unsigned int r8 = PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_gauss_elim(aa, H, 2 * H);
unsigned int r8 = PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16mat_gauss_elim(aa, H, 2 * H);
gf16mat_submat(inv_a, H, H, aa, 2 * H, H);
return r8;
}
@@ -138,15 +138,15 @@ unsigned int PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_inv(uint8_t *inv_a, const ui
#define gf16mat_gauss_elim_impl gf16mat_gauss_elim_ref
#define gf16mat_solve_linear_eq_impl gf16mat_solve_linear_eq_ref

void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b) {
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b) {
gf16mat_prod_impl(c, matA, n_A_vec_byte, n_A_width, b);
}

unsigned int PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w) {
unsigned int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w) {
return gf16mat_gauss_elim_impl(mat, h, w);
}

unsigned int PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n) {
unsigned int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n) {
return gf16mat_solve_linear_eq_impl(sol, inp_mat, c_terms, n);
}


crypto_sign/rainbowIa-classic/clean/blas_comm.h → crypto_sign/rainbowI-compressed/clean/blas_comm.h 查看文件

@@ -12,7 +12,7 @@
/// @param[in,out] b - the vector b.
/// @param[in] _num_byte - number of bytes for the vector b.
///
void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte);
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte);

/// @brief get an element from GF(16) vector .
///
@@ -20,7 +20,7 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _nu
/// @param[in] i - the index in the vector a.
/// @return the value of the element.
///
uint8_t PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned int i);
uint8_t PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned int i);

/// @brief matrix-matrix multiplication: c = a * b , in GF(16)
///
@@ -29,7 +29,7 @@ uint8_t PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned
/// @param[in] b - a matrix b.
/// @param[in] len_vec - the length of column vectors.
///
void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec);
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec);

/// @brief Gauss elimination for a matrix, in GF(16)
///
@@ -38,7 +38,7 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_mul(uint8_t *c, const uint8_t *a, co
/// @param[in] w - the width of the matrix.
/// @return 1(true) if success. 0(false) if the matrix is singular.
///
unsigned int PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w);
unsigned int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w);

/// @brief Solving linear equations, in GF(16)
///
@@ -48,7 +48,7 @@ unsigned int PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_gauss_elim(uint8_t *mat, uns
/// @param[in] n - the number of equations.
/// @return 1(true) if success. 0(false) if the matrix is singular.
///
unsigned int PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n);
unsigned int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n);

/// @brief Computing the inverse matrix, in GF(16)
///
@@ -58,7 +58,7 @@ unsigned int PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_solve_linear_eq(uint8_t *sol
/// @param[in] buffer - The buffer for computations. it has to be as large as 2 input matrixes.
/// @return 1(true) if success. 0(false) if the matrix is singular.
///
unsigned int PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer);
unsigned int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer);

/// @brief matrix-vector multiplication: c = matA * b , in GF(16)
///
@@ -68,7 +68,7 @@ unsigned int PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_inv(uint8_t *inv_a, const ui
/// @param[in] n_A_width - the width of matrix A.
/// @param[in] b - the vector b.
///
void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b);
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b);


#endif // _BLAS_COMM_H_

crypto_sign/rainbowIa-classic/clean/gf.c → crypto_sign/rainbowI-compressed/clean/gf.c 查看文件

@@ -17,7 +17,7 @@ static inline uint8_t gf4_squ(uint8_t a) {
}

//// gf16 := gf4[y]/y^2+y+x
uint8_t PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16_mul(uint8_t a, uint8_t b) {
uint8_t PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16_mul(uint8_t a, uint8_t b) {
uint8_t a0 = a & 3;
uint8_t a1 = (a >> 2);
uint8_t b0 = b & 3;
@@ -37,18 +37,18 @@ static inline uint8_t gf16_squ(uint8_t a) {
return (uint8_t)((a1 << 2) ^ a1squ_x2 ^ gf4_squ(a0));
}

uint8_t PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16_is_nonzero(uint8_t a) {
uint8_t PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16_is_nonzero(uint8_t a) {
unsigned int a4 = a & 0xf;
unsigned int r = ((unsigned int)0) - a4;
r >>= 4;
return r & 1;
}

uint8_t PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16_inv(uint8_t a) {
uint8_t PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16_inv(uint8_t a) {
uint8_t a2 = gf16_squ(a);
uint8_t a4 = gf16_squ(a2);
uint8_t a8 = gf16_squ(a4);
uint8_t a6 = PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16_mul(a4, a2);
return PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16_mul(a8, a6);
uint8_t a6 = PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16_mul(a4, a2);
return PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16_mul(a8, a6);
}


+ 18
- 0
crypto_sign/rainbowI-compressed/clean/gf.h 查看文件

@@ -0,0 +1,18 @@
#ifndef _GF16_H_
#define _GF16_H_

#include "rainbow_config.h"
#include <stdint.h>

/// @file gf16.h
/// @brief Library for arithmetics in GF(16) and GF(256)
///

uint8_t PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16_mul(uint8_t a, uint8_t b);


uint8_t PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16_is_nonzero(uint8_t a);
uint8_t PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16_inv(uint8_t a);


#endif // _GF16_H_

crypto_sign/rainbowIa-classic/clean/parallel_matrix_op.c → crypto_sign/rainbowI-compressed/clean/parallel_matrix_op.c 查看文件

@@ -16,7 +16,7 @@
/// @param[in] dim - the dimension of the upper-triangle matrix, i.e., an dim x dim matrix.
/// @return the corresponding index in an array storage.
///
unsigned int PQCLEAN_RAINBOWIACLASSIC_CLEAN_idx_of_trimat(unsigned int i_row, unsigned int j_col, unsigned int dim) {
unsigned int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_idx_of_trimat(unsigned int i_row, unsigned int j_col, unsigned int dim) {
return (dim + dim - i_row + 1) * i_row / 2 + j_col - i_row;
}

@@ -30,25 +30,25 @@ unsigned int PQCLEAN_RAINBOWIACLASSIC_CLEAN_idx_of_trimat(unsigned int i_row, un
///
static inline unsigned int idx_of_2trimat(unsigned int i_row, unsigned int j_col, unsigned int n_var) {
if (i_row > j_col) {
return PQCLEAN_RAINBOWIACLASSIC_CLEAN_idx_of_trimat(j_col, i_row, n_var);
return PQCLEAN_RAINBOWICOMPRESSED_CLEAN_idx_of_trimat(j_col, i_row, n_var);
}
return PQCLEAN_RAINBOWIACLASSIC_CLEAN_idx_of_trimat(i_row, j_col, n_var);
return PQCLEAN_RAINBOWICOMPRESSED_CLEAN_idx_of_trimat(i_row, j_col, n_var);
}

void PQCLEAN_RAINBOWIACLASSIC_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned int Awidth, unsigned int size_batch) {
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned int Awidth, unsigned int size_batch) {
unsigned char *runningC = btriC;
unsigned int Aheight = Awidth;
for (unsigned int i = 0; i < Aheight; i++) {
for (unsigned int j = 0; j < i; j++) {
unsigned int idx = PQCLEAN_RAINBOWIACLASSIC_CLEAN_idx_of_trimat(j, i, Aheight);
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_add(btriC + idx * size_batch, bA + size_batch * (i * Awidth + j), size_batch);
unsigned int idx = PQCLEAN_RAINBOWICOMPRESSED_CLEAN_idx_of_trimat(j, i, Aheight);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_add(btriC + idx * size_batch, bA + size_batch * (i * Awidth + j), size_batch);
}
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_add(runningC, bA + size_batch * (i * Awidth + i), size_batch * (Aheight - i));
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_add(runningC, bA + size_batch * (i * Awidth + i), size_batch * (Aheight - i));
runningC += size_batch * (Aheight - i);
}
}

void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA,
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) {
unsigned int Awidth = Bheight;
unsigned int Aheight = Awidth;
@@ -58,7 +58,7 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, co
if (k < i) {
continue;
}
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_madd(bC, &btriA[(k - i) * size_batch], PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_madd(bC, &btriA[(k - i) * size_batch], PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch);
}
bC += size_batch;
}
@@ -66,7 +66,7 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, co
}
}

void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, const unsigned char *btriA,
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, const unsigned char *btriA,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) {
unsigned int Aheight = Bheight;
for (unsigned int i = 0; i < Aheight; i++) {
@@ -75,14 +75,14 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC,
if (i < k) {
continue;
}
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_madd(bC, &btriA[size_batch * (PQCLEAN_RAINBOWIACLASSIC_CLEAN_idx_of_trimat(k, i, Aheight))], PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_madd(bC, &btriA[size_batch * (PQCLEAN_RAINBOWICOMPRESSED_CLEAN_idx_of_trimat(k, i, Aheight))], PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch);
}
bC += size_batch;
}
}
}

void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA,
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) {
unsigned int Aheight = Bheight;
for (unsigned int i = 0; i < Aheight; i++) {
@@ -91,46 +91,46 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, c
if (i == k) {
continue;
}
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_madd(bC, &btriA[size_batch * (idx_of_2trimat(i, k, Aheight))], PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_madd(bC, &btriA[size_batch * (idx_of_2trimat(i, k, Aheight))], PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch);
}
bC += size_batch;
}
}
}

void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_matTr_madd_gf16(unsigned char *bC, const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth,
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_matTr_madd_gf16(unsigned char *bC, const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth,
const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch) {
unsigned int Atr_height = Awidth;
unsigned int Atr_width = Aheight;
for (unsigned int i = 0; i < Atr_height; i++) {
for (unsigned int j = 0; j < Atr_width; j++) {
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_madd(bC, &bB[j * Bwidth * size_batch], PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(&A_to_tr[size_Acolvec * i], j), size_batch * Bwidth);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_madd(bC, &bB[j * Bwidth * size_batch], PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_get_ele(&A_to_tr[size_Acolvec * i], j), size_batch * Bwidth);
}
bC += size_batch * Bwidth;
}
}

void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr,
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) {
const unsigned char *bA = bA_to_tr;
unsigned int Aheight = Awidth_before_tr;
for (unsigned int i = 0; i < Aheight; i++) {
for (unsigned int j = 0; j < Bwidth; j++) {
for (unsigned int k = 0; k < Bheight; k++) {
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_madd(bC, &bA[size_batch * (i + k * Aheight)], PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_madd(bC, &bA[size_batch * (i + k * Aheight)], PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch);
}
bC += size_batch;
}
}
}

void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned int Aheight,
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned int Aheight,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) {
unsigned int Awidth = Bheight;
for (unsigned int i = 0; i < Aheight; i++) {
for (unsigned int j = 0; j < Bwidth; j++) {
for (unsigned int k = 0; k < Bheight; k++) {
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_madd(bC, &bA[k * size_batch], PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_madd(bC, &bA[k * size_batch], PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch);
}
bC += size_batch;
}
@@ -138,45 +138,45 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const
}
}

void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned int dim_y, const unsigned char *mat,
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned int dim_y, const unsigned char *mat,
const unsigned char *x, unsigned int dim_x, unsigned int size_batch) {
unsigned char tmp[128];

unsigned char _x[128];
for (unsigned int i = 0; i < dim_x; i++) {
_x[i] = PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(x, i);
_x[i] = PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_get_ele(x, i);
}
unsigned char _y[128];
for (unsigned int i = 0; i < dim_y; i++) {
_y[i] = PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(y, i);
_y[i] = PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_get_ele(y, i);
}

PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_set_zero(z, size_batch);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_set_zero(z, size_batch);
for (unsigned int i = 0; i < dim_y; i++) {
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_set_zero(tmp, size_batch);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_set_zero(tmp, size_batch);
for (unsigned int j = 0; j < dim_x; j++) {
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_madd(tmp, mat, _x[j], size_batch);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_madd(tmp, mat, _x[j], size_batch);
mat += size_batch;
}
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_madd(z, tmp, _y[i], size_batch);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_madd(z, tmp, _y[i], size_batch);
}
}

void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch) {
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch) {
unsigned char tmp[256];

unsigned char _x[256];
for (unsigned int i = 0; i < dim; i++) {
_x[i] = PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(x, i);
_x[i] = PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_get_ele(x, i);
}

PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_set_zero(y, size_batch);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_set_zero(y, size_batch);
for (unsigned int i = 0; i < dim; i++) {
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_set_zero(tmp, size_batch);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_set_zero(tmp, size_batch);
for (unsigned int j = i; j < dim; j++) {
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_madd(tmp, trimat, _x[j], size_batch);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_madd(tmp, trimat, _x[j], size_batch);
trimat += size_batch;
}
PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_madd(y, tmp, _x[i], size_batch);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_madd(y, tmp, _x[i], size_batch);
}
}

crypto_sign/rainbowIIIc-classic/clean/parallel_matrix_op.h → crypto_sign/rainbowI-compressed/clean/parallel_matrix_op.h 查看文件

@@ -15,7 +15,7 @@
/// @param[in] dim - the dimension of the upper-triangle matrix, i.e., an dim x dim matrix.
/// @return the corresponding index in an array storage.
///
unsigned int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_idx_of_trimat(unsigned int i_row, unsigned int j_col, unsigned int dim);
unsigned int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_idx_of_trimat(unsigned int i_row, unsigned int j_col, unsigned int dim);

///
/// @brief Upper trianglize a rectangle matrix to the corresponding upper-trangle matrix.
@@ -25,7 +25,7 @@ unsigned int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_idx_of_trimat(unsigned int i_row,
/// @param[in] bwidth - the width of the batched matrix A, i.e., A is a Awidth x Awidth matrix.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned int Awidth, unsigned int size_batch);
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned int Awidth, unsigned int size_batch);

//////////////////// Section: matrix multiplications ///////////////////////////////

@@ -40,7 +40,7 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_UpperTrianglize(unsigned char *btriC, cons
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA,
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);

///
@@ -54,7 +54,7 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_trimat_madd_gf16(unsigned char *bC,
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA,
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);

///
@@ -68,7 +68,7 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_trimat_madd_gf256(unsigned char *bC,
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, const unsigned char *btriA,
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, const unsigned char *btriA,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);

///
@@ -82,7 +82,7 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_trimatTr_madd_gf256(unsigned char *bC, const unsigned char *btriA,
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_trimatTr_madd_gf256(unsigned char *bC, const unsigned char *btriA,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);

///
@@ -96,7 +96,7 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_trimatTr_madd_gf256(unsigned char *b
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA,
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);

///
@@ -110,7 +110,7 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC,
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA,
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);

///
@@ -125,7 +125,7 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_matTr_madd_gf16(unsigned char *bC,
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_matTr_madd_gf16(unsigned char *bC,
const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth,
const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch);

@@ -141,7 +141,7 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_matTr_madd_gf16(unsigned char *bC,
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_matTr_madd_gf256(unsigned char *bC,
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_matTr_madd_gf256(unsigned char *bC,
const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth,
const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch);

@@ -157,7 +157,7 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_matTr_madd_gf256(unsigned char *bC,
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr,
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);

///
@@ -172,7 +172,7 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC,
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr,
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);

///
@@ -187,7 +187,7 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC,
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned int Aheight,
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned int Aheight,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);

///
@@ -202,7 +202,7 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, con
/// @param[in] Bwidth - the width of B.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned int Aheight,
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned int Aheight,
const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);

//////////////////// Section: "quadratric" matrix evaluation ///////////////////////////////
@@ -216,7 +216,7 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, co
/// @param[in] dim - the dimension of matrix trimat (and x).
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch);
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch);

///
/// @brief y = x^Tr * trimat * x , in GF(256)
@@ -227,7 +227,7 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_quad_trimat_eval_gf16(unsigned char
/// @param[in] dim - the dimension of matrix trimat (and x).
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch);
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch);

///
/// @brief z = y^Tr * mat * x , in GF(16)
@@ -240,7 +240,7 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char
/// @param[in] dim_x - the length of x.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned int dim_y,
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned int dim_y,
const unsigned char *mat, const unsigned char *x, unsigned int dim_x, unsigned int size_batch);

///
@@ -254,7 +254,7 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char
/// @param[in] dim_x - the length of x.
/// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
///
void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned int dim_y,
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned int dim_y,
const unsigned char *mat, const unsigned char *x, unsigned int dim_x, unsigned int size_batch);

#endif // _P_MATRIX_OP_H_

crypto_sign/rainbowIIIc-classic/clean/rainbow.c → crypto_sign/rainbowI-compressed/clean/rainbow.c 查看文件

@@ -16,7 +16,7 @@

#define MAX_ATTEMPT_FRMAT 128

int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t *sk, const uint8_t *_digest) {
int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_rainbow_sign(uint8_t *signature, const sk_t *sk, const uint8_t *_digest) {
uint8_t mat_l1[_O1 * _O1_BYTE];
uint8_t mat_l2[_O2 * _O2_BYTE];
uint8_t mat_buffer[2 * _MAX_O * _MAX_O_BYTE];
@@ -27,8 +27,8 @@ int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t
memcpy(prng_preseed, sk->sk_seed, LEN_SKSEED);
memcpy(prng_preseed + LEN_SKSEED, _digest, _HASH_LEN); // prng_preseed = sk_seed || digest
uint8_t prng_seed[_HASH_LEN];
PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_hash_msg(prng_seed, _HASH_LEN, prng_preseed, _HASH_LEN + LEN_SKSEED);
PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_prng_set(&prng_sign, prng_seed, _HASH_LEN); // seed = H( sk_seed || digest )
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_hash_msg(prng_seed, _HASH_LEN, prng_preseed, _HASH_LEN + LEN_SKSEED);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_prng_set(&prng_sign, prng_seed, _HASH_LEN); // seed = H( sk_seed || digest )
for (unsigned int i = 0; i < LEN_SKSEED + _HASH_LEN; i++) {
prng_preseed[i] ^= prng_preseed[i]; // clean
}
@@ -44,7 +44,7 @@ int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t
if (MAX_ATTEMPT_FRMAT <= n_attempt) {
break;
}
PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_prng_gen(&prng_sign, vinegar, _V1_BYTE); // generating vinegars
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_prng_gen(&prng_sign, vinegar, _V1_BYTE); // generating vinegars
gfmat_prod(mat_l1, sk->l1_F2, _O1 * _O1_BYTE, _V1, vinegar); // generating the linear equations for layer 1
l1_succ = gfmat_inv(mat_l1, mat_l1, _O1, mat_buffer); // check if the linear equation solvable
n_attempt++;
@@ -65,7 +65,7 @@ int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t
uint8_t y[_PUB_M_BYTE];
uint8_t *x_v1 = vinegar;
uint8_t x_o1[_O1_BYTE];
uint8_t x_o2[_O1_BYTE];
uint8_t x_o2[_O2_BYTE];

uint8_t digest_salt[_HASH_LEN + _SALT_BYTE];
memcpy(digest_salt, _digest, _HASH_LEN);
@@ -79,31 +79,31 @@ int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t
}
// The computation: H(digest||salt) --> z --S--> y --C-map--> x --T--> w

PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_prng_gen(&prng_sign, salt, _SALT_BYTE); // roll the salt
PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_hash_msg(_z, _PUB_M_BYTE, digest_salt, _HASH_LEN + _SALT_BYTE); // H(digest||salt)
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_prng_gen(&prng_sign, salt, _SALT_BYTE); // roll the salt
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_hash_msg(_z, _PUB_M_BYTE, digest_salt, _HASH_LEN + _SALT_BYTE); // H(digest||salt)

// y = S^-1 * z
memcpy(y, _z, _PUB_M_BYTE); // identity part of S
gfmat_prod(temp_o, sk->s1, _O1_BYTE, _O2, _z + _O1_BYTE);
PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_add(y, temp_o, _O1_BYTE);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_add(y, temp_o, _O1_BYTE);

// Central Map:
// layer 1: calculate x_o1
memcpy(temp_o, r_l1_F1, _O1_BYTE);
PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_add(temp_o, y, _O1_BYTE);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_add(temp_o, y, _O1_BYTE);
gfmat_prod(x_o1, mat_l1, _O1_BYTE, _O1, temp_o);

// layer 2: calculate x_o2
PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_set_zero(temp_o, _O2_BYTE);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_set_zero(temp_o, _O2_BYTE);
gfmat_prod(temp_o, mat_l2_F2, _O2_BYTE, _O1, x_o1); // F2
batch_quad_trimat_eval(mat_l2, sk->l2_F5, x_o1, _O1, _O2_BYTE); // F5
PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_add(temp_o, mat_l2, _O2_BYTE);
PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_add(temp_o, r_l2_F1, _O2_BYTE); // F1
PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_add(temp_o, y + _O1_BYTE, _O2_BYTE);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_add(temp_o, mat_l2, _O2_BYTE);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_add(temp_o, r_l2_F1, _O2_BYTE); // F1
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_add(temp_o, y + _O1_BYTE, _O2_BYTE);

// generate the linear equations of the 2nd layer
gfmat_prod(mat_l2, sk->l2_F6, _O2 * _O2_BYTE, _O1, x_o1); // F6
PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_add(mat_l2, mat_l2_F3, _O2 * _O2_BYTE); // F3
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_add(mat_l2, mat_l2_F3, _O2 * _O2_BYTE); // F3
succ = gfmat_inv(mat_l2, mat_l2, _O2, mat_buffer);
gfmat_prod(x_o2, mat_l2, _O2_BYTE, _O2, temp_o); // solve l2 eqs

@@ -117,13 +117,13 @@ int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t
memcpy(w + _V2_BYTE, x_o2, _O2_BYTE);
// Computing the t1 part.
gfmat_prod(y, sk->t1, _V1_BYTE, _O1, x_o1);
PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_add(w, y, _V1_BYTE);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_add(w, y, _V1_BYTE);
// Computing the t4 part.
gfmat_prod(y, sk->t4, _V1_BYTE, _O2, x_o2);
PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_add(w, y, _V1_BYTE);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_add(w, y, _V1_BYTE);
// Computing the t3 part.
gfmat_prod(y, sk->t3, _O1_BYTE, _O2, x_o2);
PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_add(w + _V1_BYTE, y, _O1_BYTE);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_add(w + _V1_BYTE, y, _O1_BYTE);

memset(signature, 0, _SIGNATURE_BYTE); // set the output 0
// clean
@@ -141,12 +141,12 @@ int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t
if (MAX_ATTEMPT_FRMAT <= n_attempt) {
return -1;
}
PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_add(signature, w, _PUB_N_BYTE);
PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_add(signature + _PUB_N_BYTE, salt, _SALT_BYTE);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_add(signature, w, _PUB_N_BYTE);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_add(signature + _PUB_N_BYTE, salt, _SALT_BYTE);
return 0;
}

int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_rainbow_verify(const uint8_t *digest, const uint8_t *signature, const pk_t *pk) {
int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_rainbow_verify(const uint8_t *digest, const uint8_t *signature, const pk_t *pk) {
unsigned char digest_ck[_PUB_M_BYTE];
// public_map( digest_ck , pk , signature ); Evaluating the quadratic public polynomials.
batch_quad_trimat_eval(digest_ck, pk->pk, signature, _PUB_N, _PUB_M_BYTE);
@@ -155,7 +155,7 @@ int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_rainbow_verify(const uint8_t *digest, const
unsigned char digest_salt[_HASH_LEN + _SALT_BYTE];
memcpy(digest_salt, digest, _HASH_LEN);
memcpy(digest_salt + _HASH_LEN, signature + _PUB_N_BYTE, _SALT_BYTE);
PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_hash_msg(correct, _PUB_M_BYTE, digest_salt, _HASH_LEN + _SALT_BYTE); // H( digest || salt )
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_hash_msg(correct, _PUB_M_BYTE, digest_salt, _HASH_LEN + _SALT_BYTE); // H( digest || salt )

// check consistancy.
unsigned char cc = 0;
@@ -165,4 +165,15 @@ int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_rainbow_verify(const uint8_t *digest, const
return (0 == cc) ? 0 : -1;
}

/////////////// cyclic version ///////////////////////////
int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_rainbow_sign_cyclic(uint8_t *signature, const csk_t *csk, const uint8_t *digest) {
unsigned char sk[sizeof(sk_t) + 32];
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_generate_secretkey_cyclic((sk_t *)sk, csk->pk_seed, csk->sk_seed); // generating classic secret key.
return PQCLEAN_RAINBOWICOMPRESSED_CLEAN_rainbow_sign(signature, (sk_t *)sk, digest);
}

int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_rainbow_verify_cyclic(const uint8_t *digest, const uint8_t *signature, const cpk_t *_pk) {
unsigned char pk[sizeof(pk_t) + 32];
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_cpk_to_pk((pk_t *)pk, _pk); // generating classic public key.
return PQCLEAN_RAINBOWICOMPRESSED_CLEAN_rainbow_verify(digest, signature, (pk_t *)pk);
}

crypto_sign/rainbowIa-cyclic-compressed/clean/rainbow.h → crypto_sign/rainbowI-compressed/clean/rainbow.h 查看文件

@@ -16,7 +16,7 @@
/// @param[in] sk - the secret key.
/// @param[in] digest - the digest.
///
int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_rainbow_sign(uint8_t *signature, const sk_t *sk, const uint8_t *digest);
int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_rainbow_sign(uint8_t *signature, const sk_t *sk, const uint8_t *digest);

///
/// @brief Verifying function.
@@ -26,7 +26,7 @@ int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_rainbow_sign(uint8_t *signature, con
/// @param[in] pk - the public key.
/// @return 0 for successful verified. -1 for failed verification.
///
int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_rainbow_verify(const uint8_t *digest, const uint8_t *signature, const pk_t *pk);
int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_rainbow_verify(const uint8_t *digest, const uint8_t *signature, const pk_t *pk);

///
/// @brief Signing function for compressed secret key of the cyclic rainbow.
@@ -35,7 +35,7 @@ int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_rainbow_verify(const uint8_t *digest
/// @param[in] sk - the compressed secret key.
/// @param[in] digest - the digest.
///
int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_rainbow_sign_cyclic(uint8_t *signature, const csk_t *sk, const uint8_t *digest);
int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_rainbow_sign_cyclic(uint8_t *signature, const csk_t *sk, const uint8_t *digest);

///
/// @brief Verifying function for cyclic public keys.
@@ -45,6 +45,6 @@ int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_rainbow_sign_cyclic(uint8_t *signatu
/// @param[in] pk - the public key of cyclic rainbow.
/// @return 0 for successful verified. -1 for failed verification.
///
int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_rainbow_verify_cyclic(const uint8_t *digest, const uint8_t *signature, const cpk_t *pk);
int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_rainbow_verify_cyclic(const uint8_t *digest, const uint8_t *signature, const cpk_t *pk);

#endif // _RAINBOW_H_

+ 32
- 0
crypto_sign/rainbowI-compressed/clean/rainbow_blas.h 查看文件

@@ -0,0 +1,32 @@
#ifndef _RAINBOW_BLAS_H_
#define _RAINBOW_BLAS_H_
/// @file rainbow_blas.h
/// @brief Defining the functions used in rainbow.c acconding to the definitions in rainbow_config.h
///
/// Defining the functions used in rainbow.c acconding to the definitions in rainbow_config.h

#include "blas.h"
#include "blas_comm.h"
#include "parallel_matrix_op.h"
#include "rainbow_config.h"


#define gfv_get_ele PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_get_ele
#define gfv_mul_scalar PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_mul_scalar
#define gfv_madd PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16v_madd

#define gfmat_prod PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16mat_prod
#define gfmat_inv PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf16mat_inv

#define batch_trimat_madd PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_trimat_madd_gf16
#define batch_trimatTr_madd PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_trimatTr_madd_gf16
#define batch_2trimat_madd PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_2trimat_madd_gf16
#define batch_matTr_madd PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_matTr_madd_gf16
#define batch_bmatTr_madd PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_bmatTr_madd_gf16
#define batch_mat_madd PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_mat_madd_gf16

#define batch_quad_trimat_eval PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_quad_trimat_eval_gf16
#define batch_quad_recmat_eval PQCLEAN_RAINBOWICOMPRESSED_CLEAN_batch_quad_recmat_eval_gf16


#endif // _RAINBOW_BLAS_H_

crypto_sign/rainbowIa-classic/clean/rainbow_config.h → crypto_sign/rainbowI-compressed/clean/rainbow_config.h 查看文件

@@ -7,7 +7,7 @@

#define _USE_GF16
#define _GFSIZE 16
#define _V1 32
#define _V1 36
#define _O1 32
#define _O2 32
#define _MAX_O 32

crypto_sign/rainbowIa-cyclic-compressed/clean/rainbow_keypair.c → crypto_sign/rainbowI-compressed/clean/rainbow_keypair.c 查看文件

@@ -12,52 +12,81 @@
#include <stdlib.h>
#include <string.h>

static void generate_S_T(unsigned char *s_and_t, prng_t *prng0) {
PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_prng_gen(prng0, s_and_t, _O1_BYTE * _O2); // S1
s_and_t += _O1_BYTE * _O2;
PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_prng_gen(prng0, s_and_t, _V1_BYTE * _O1); // T1
s_and_t += _V1_BYTE * _O1;
PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_prng_gen(prng0, s_and_t, _V1_BYTE * _O2); // T2
s_and_t += _V1_BYTE * _O2;
PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_prng_gen(prng0, s_and_t, _O1_BYTE * _O2); // T3
static
void generate_S_T( unsigned char *s_and_t, prng_t *prng0 ) {
sk_t *_sk;
unsigned size;

size = sizeof(_sk->s1);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_prng_gen( prng0, s_and_t, size );
s_and_t += size;

size = sizeof(_sk->t1);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_prng_gen( prng0, s_and_t, size );
s_and_t += size;

size = sizeof(_sk->t4);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_prng_gen( prng0, s_and_t, size );
s_and_t += size;

size = sizeof(_sk->t3);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_prng_gen( prng0, s_and_t, size );
}

static unsigned int generate_l1_F12(unsigned char *sk, prng_t *prng0) {
unsigned int n_byte_generated = 0;
PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_prng_gen(prng0, sk, _O1_BYTE * N_TRIANGLE_TERMS(_V1)); // l1_F1
sk += _O1_BYTE * N_TRIANGLE_TERMS(_V1);
n_byte_generated += _O1_BYTE * N_TRIANGLE_TERMS(_V1);

PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_prng_gen(prng0, sk, _O1_BYTE * _V1 * _O1); // l1_F2
n_byte_generated += _O1_BYTE * _V1 * _O1;
static
unsigned generate_l1_F12( unsigned char *sk, prng_t *prng0 ) {
unsigned n_byte_generated = 0;
sk_t *_sk;
unsigned size;

size = sizeof(_sk->l1_F1);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_prng_gen( prng0, sk, size );
sk += size;
n_byte_generated += size;

size = sizeof(_sk->l1_F2);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_prng_gen( prng0, sk, size );
n_byte_generated += size;

return n_byte_generated;
}

static unsigned int generate_l2_F12356(unsigned char *sk, prng_t *prng0) {
unsigned int n_byte_generated = 0;

PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_prng_gen(prng0, sk, _O2_BYTE * N_TRIANGLE_TERMS(_V1)); // l2_F1
sk += _O2_BYTE * N_TRIANGLE_TERMS(_V1);
n_byte_generated += _O2_BYTE * N_TRIANGLE_TERMS(_V1);
static
unsigned generate_l2_F12356( unsigned char *sk, prng_t *prng0 ) {
unsigned n_byte_generated = 0;
sk_t *_sk;
unsigned size;

PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_prng_gen(prng0, sk, _O2_BYTE * _V1 * _O1); // l2_F2
sk += _O2_BYTE * _V1 * _O1;
n_byte_generated += _O2_BYTE * _V1 * _O1;
size = sizeof(_sk->l2_F1);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_prng_gen( prng0, sk, size );
sk += size;
n_byte_generated += size;

PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_prng_gen(prng0, sk, _O2_BYTE * _V1 * _O2); // l2_F3
sk += _O2_BYTE * _V1 * _O1;
n_byte_generated += _O2_BYTE * _V1 * _O1;
size = sizeof(_sk->l2_F2);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_prng_gen( prng0, sk, size );
sk += size;
n_byte_generated += size;

PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_prng_gen(prng0, sk, _O2_BYTE * N_TRIANGLE_TERMS(_O1)); // l2_F5
sk += _O2_BYTE * N_TRIANGLE_TERMS(_O1);
n_byte_generated += _O2_BYTE * N_TRIANGLE_TERMS(_O1);
size = sizeof(_sk->l2_F3);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_prng_gen( prng0, sk, size );
sk += size;
n_byte_generated += size;

PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_prng_gen(prng0, sk, _O2_BYTE * _O1 * _O2); // l2_F6
n_byte_generated += _O2_BYTE * _O1 * _O2;
size = sizeof(_sk->l2_F5);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_prng_gen( prng0, sk, size );
sk += size;
n_byte_generated += size;

size = sizeof(_sk->l2_F6);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_prng_gen( prng0, sk, size );
n_byte_generated += size;

return n_byte_generated;
}


static void generate_B1_B2(unsigned char *sk, prng_t *prng0) {
sk += generate_l1_F12(sk, prng0);
generate_l2_F12356(sk, prng0);
@@ -69,7 +98,7 @@ static void calculate_t4(unsigned char *t2_to_t4, const unsigned char *t1, const
unsigned char *t4 = t2_to_t4;
for (unsigned int i = 0; i < _O2; i++) { /// t3 width
gfmat_prod(temp, t1, _V1_BYTE, _O1, t3);
PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_add(t4, temp, _V1_BYTE);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_add(t4, temp, _V1_BYTE);
t4 += _V1_BYTE;
t3 += _O1_BYTE;
}
@@ -79,7 +108,7 @@ static void obsfucate_l1_polys(unsigned char *l1_polys, const unsigned char *l2_
unsigned char temp[_O1_BYTE + 32];
while (n_terms--) {
gfmat_prod(temp, s1, _O1_BYTE, _O2, l2_polys);
PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_add(l1_polys, temp, _O1_BYTE);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_gf256v_add(l1_polys, temp, _O1_BYTE);
l1_polys += _O1_BYTE;
l2_polys += _O2_BYTE;
}
@@ -89,14 +118,14 @@ static void obsfucate_l1_polys(unsigned char *l1_polys, const unsigned char *l2_


///////////////////// Cyclic //////////////////////////////////
void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_generate_keypair_cyclic(cpk_t *pk, sk_t *sk, const unsigned char *pk_seed, const unsigned char *sk_seed) {
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_generate_keypair_cyclic(cpk_t *pk, sk_t *sk, const unsigned char *pk_seed, const unsigned char *sk_seed) {
memcpy(pk->pk_seed, pk_seed, LEN_PKSEED);
memcpy(sk->sk_seed, sk_seed, LEN_SKSEED);

// prng for sk
prng_t prng;
prng_t *prng0 = &prng;
PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_prng_set(prng0, sk_seed, LEN_SKSEED);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_prng_set(prng0, sk_seed, LEN_SKSEED);
generate_S_T(sk->s1, prng0); // S,T: only a part of sk

unsigned char t2[sizeof(sk->t4)];
@@ -107,18 +136,18 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_generate_keypair_cyclic(cpk_t *pk,
sk_t inst_Qs;
sk_t *Qs = &inst_Qs;
prng_t *prng1 = &prng;
PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_prng_set(prng1, pk_seed, LEN_PKSEED);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_prng_set(prng1, pk_seed, LEN_PKSEED);
generate_B1_B2(Qs->l1_F1, prng1); // generating l1_Q1, l1_Q2, l2_Q1, l2_Q2, l2_Q3, l2_Q5, l2_Q6
obsfucate_l1_polys(Qs->l1_F1, Qs->l2_F1, N_TRIANGLE_TERMS(_V1), sk->s1);
obsfucate_l1_polys(Qs->l1_F2, Qs->l2_F2, _V1 * _O1, sk->s1);
// so far, the Qs contains l1_F1, l1_F2, l2_F1, l2_F2, l2_F3, l2_F5, l2_F6.

PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_calculate_F_from_Q(sk, Qs, sk); // calcuate the rest parts of secret key from Qs and S,T
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_calculate_F_from_Q(sk, Qs, sk); // calcuate the rest parts of secret key from Qs and S,T

unsigned char t4[sizeof(sk->t4)];
memcpy(t4, sk->t4, _V1_BYTE * _O2); // temporarily store t4
memcpy(sk->t4, t2, _V1_BYTE * _O2); // restore t2
PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_calculate_Q_from_F_cyclic(pk, sk, sk); // calculate the rest parts of public key: l1_Q3, l1_Q5, l1_Q6, l1_Q9, l2_Q9
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_calculate_Q_from_F_cyclic(pk, sk, sk); // calculate the rest parts of public key: l1_Q3, l1_Q5, l1_Q6, l1_Q9, l2_Q9
memcpy(sk->t4, t4, _V1_BYTE * _O2); // restore t4

obsfucate_l1_polys(pk->l1_Q3, Qs->l2_F3, _V1 * _O2, sk->s1);
@@ -131,19 +160,19 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_generate_keypair_cyclic(cpk_t *pk,
}


void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_generate_compact_keypair_cyclic(cpk_t *pk, csk_t *rsk, const unsigned char *pk_seed, const unsigned char *sk_seed) {
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_generate_compact_keypair_cyclic(cpk_t *pk, csk_t *rsk, const unsigned char *pk_seed, const unsigned char *sk_seed) {
memcpy(rsk->pk_seed, pk_seed, LEN_PKSEED);
memcpy(rsk->sk_seed, sk_seed, LEN_SKSEED);
sk_t sk;
PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_generate_keypair_cyclic(pk, &sk, pk_seed, sk_seed);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_generate_keypair_cyclic(pk, &sk, pk_seed, sk_seed);
}

void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_generate_secretkey_cyclic(sk_t *sk, const unsigned char *pk_seed, const unsigned char *sk_seed) {
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_generate_secretkey_cyclic(sk_t *sk, const unsigned char *pk_seed, const unsigned char *sk_seed) {
memcpy(sk->sk_seed, sk_seed, LEN_SKSEED);

// prng for sk
prng_t prng0;
PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_prng_set(&prng0, sk_seed, LEN_SKSEED);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_prng_set(&prng0, sk_seed, LEN_SKSEED);
generate_S_T(sk->s1, &prng0);
calculate_t4(sk->t4, sk->t1, sk->t3);

@@ -151,19 +180,19 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_generate_secretkey_cyclic(sk_t *sk,
sk_t inst_Qs;
sk_t *Qs = &inst_Qs;
prng_t prng1;
PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_prng_set(&prng1, pk_seed, LEN_PKSEED);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_prng_set(&prng1, pk_seed, LEN_PKSEED);
generate_B1_B2(Qs->l1_F1, &prng1);

obsfucate_l1_polys(Qs->l1_F1, Qs->l2_F1, N_TRIANGLE_TERMS(_V1), sk->s1);
obsfucate_l1_polys(Qs->l1_F2, Qs->l2_F2, _V1 * _O1, sk->s1);

// calcuate the parts of sk according to pk.
PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_calculate_F_from_Q(sk, Qs, sk);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_calculate_F_from_Q(sk, Qs, sk);

// clean prng for sk
memset(&prng0, 0, sizeof(prng_t));
}
void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_cpk_to_pk(pk_t *rpk, const cpk_t *cpk) {
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_cpk_to_pk(pk_t *rpk, const cpk_t *cpk) {
// procedure: cpk_t --> extcpk_t --> pk_t

// convert from cpk_t to extcpk_t
@@ -171,7 +200,7 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_cpk_to_pk(pk_t *rpk, const cpk_t *c

// setup prng
prng_t prng0;
PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_prng_set(&prng0, cpk->pk_seed, LEN_SKSEED);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_prng_set(&prng0, cpk->pk_seed, LEN_SKSEED);

// generating parts of key with prng
generate_l1_F12(pk.l1_Q1, &prng0);
@@ -184,5 +213,5 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_cpk_to_pk(pk_t *rpk, const cpk_t *c
memcpy(pk.l2_Q9, cpk->l2_Q9, _O2_BYTE * N_TRIANGLE_TERMS(_O2));

// convert from extcpk_t to pk_t
PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_extcpk_to_pk(rpk, &pk);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_extcpk_to_pk(rpk, &pk);
}

crypto_sign/rainbowIIIc-cyclic-compressed/clean/rainbow_keypair.h → crypto_sign/rainbowI-compressed/clean/rainbow_keypair.h 查看文件

@@ -77,7 +77,7 @@ typedef struct rainbow_secretkey_cyclic {
/// @param[in] pk_seed - seed for generating parts of public key.
/// @param[in] sk_seed - seed for generating secret key.
///
void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_generate_keypair_cyclic(cpk_t *pk, sk_t *sk, const unsigned char *pk_seed, const unsigned char *sk_seed);
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_generate_keypair_cyclic(cpk_t *pk, sk_t *sk, const unsigned char *pk_seed, const unsigned char *sk_seed);

///
/// @brief Generate compressed key pairs for cyclic rainbow.
@@ -87,7 +87,7 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_generate_keypair_cyclic(cpk_t *pk
/// @param[in] pk_seed - seed for generating parts of the public key.
/// @param[in] sk_seed - seed for generating the secret key.
///
void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_generate_compact_keypair_cyclic(cpk_t *pk, csk_t *sk, const unsigned char *pk_seed, const unsigned char *sk_seed);
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_generate_compact_keypair_cyclic(cpk_t *pk, csk_t *sk, const unsigned char *pk_seed, const unsigned char *sk_seed);

///
/// @brief Generate secret key for cyclic rainbow.
@@ -96,7 +96,7 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_generate_compact_keypair_cyclic(c
/// @param[in] pk_seed - seed for generating parts of the pbulic key.
/// @param[in] sk_seed - seed for generating the secret key.
///
void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_generate_secretkey_cyclic(sk_t *sk, const unsigned char *pk_seed, const unsigned char *sk_seed);
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_generate_secretkey_cyclic(sk_t *sk, const unsigned char *pk_seed, const unsigned char *sk_seed);

////////////////////////////////////

@@ -106,6 +106,6 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_generate_secretkey_cyclic(sk_t *s
/// @param[out] pk - the classic public key.
/// @param[in] cpk - the cyclic public key.
///
void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_cpk_to_pk(pk_t *pk, const cpk_t *cpk);
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_cpk_to_pk(pk_t *pk, const cpk_t *cpk);

#endif // _RAINBOW_KEYPAIR_H_

crypto_sign/rainbowIIIc-cyclic/clean/rainbow_keypair_computation.c → crypto_sign/rainbowI-compressed/clean/rainbow_keypair_computation.c 查看文件

@@ -11,12 +11,12 @@
#include <stdlib.h>
#include <string.h>

void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) {
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) {
const unsigned char *idx_l1 = cpk->l1_Q1;
const unsigned char *idx_l2 = cpk->l2_Q1;
for (unsigned int i = 0; i < _V1; i++) {
for (unsigned int j = i; j < _V1; j++) {
unsigned int pub_idx = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N);
unsigned int pub_idx = PQCLEAN_RAINBOWICOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N);
memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE);
memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE);
idx_l1 += _O1_BYTE;
@@ -27,7 +27,7 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk
idx_l2 = cpk->l2_Q2;
for (unsigned int i = 0; i < _V1; i++) {
for (unsigned int j = _V1; j < _V1 + _O1; j++) {
unsigned int pub_idx = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N);
unsigned int pub_idx = PQCLEAN_RAINBOWICOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N);
memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE);
memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE);
idx_l1 += _O1_BYTE;
@@ -38,7 +38,7 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk
idx_l2 = cpk->l2_Q3;
for (unsigned int i = 0; i < _V1; i++) {
for (unsigned int j = _V1 + _O1; j < _PUB_N; j++) {
unsigned int pub_idx = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N);
unsigned int pub_idx = PQCLEAN_RAINBOWICOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N);
memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE);
memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE);
idx_l1 += _O1_BYTE;
@@ -49,7 +49,7 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk
idx_l2 = cpk->l2_Q5;
for (unsigned int i = _V1; i < _V1 + _O1; i++) {
for (unsigned int j = i; j < _V1 + _O1; j++) {
unsigned int pub_idx = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N);
unsigned int pub_idx = PQCLEAN_RAINBOWICOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N);
memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE);
memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE);
idx_l1 += _O1_BYTE;
@@ -60,7 +60,7 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk
idx_l2 = cpk->l2_Q6;
for (unsigned int i = _V1; i < _V1 + _O1; i++) {
for (unsigned int j = _V1 + _O1; j < _PUB_N; j++) {
unsigned int pub_idx = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N);
unsigned int pub_idx = PQCLEAN_RAINBOWICOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N);
memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE);
memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE);
idx_l1 += _O1_BYTE;
@@ -71,7 +71,7 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk
idx_l2 = cpk->l2_Q9;
for (unsigned int i = _V1 + _O1; i < _PUB_N; i++) {
for (unsigned int j = i; j < _PUB_N; j++) {
unsigned int pub_idx = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N);
unsigned int pub_idx = PQCLEAN_RAINBOWICOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N);
memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE);
memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE);
idx_l1 += _O1_BYTE;
@@ -119,7 +119,7 @@ static void calculate_F_from_Q_ref(sk_t *Fs, const sk_t *Qs, sk_t *Ts) {
memset(tempQ, 0, _O1 * _O1 * _O2_BYTE);
batch_matTr_madd(tempQ, Ts->t1, _V1, _V1_BYTE, _O1, Fs->l2_F2, _O1, _O2_BYTE); // t1_tr*(Q1_T1+Q2)
memcpy(Fs->l2_F5, Qs->l2_F5, _O2_BYTE * N_TRIANGLE_TERMS(_O1)); // F5
PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_UpperTrianglize(Fs->l2_F5, tempQ, _O1, _O2_BYTE); // UT( ... )
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_UpperTrianglize(Fs->l2_F5, tempQ, _O1, _O2_BYTE); // UT( ... )

batch_trimatTr_madd(Fs->l2_F2, Qs->l2_F1, Ts->t1, _V1, _V1_BYTE, _O1, _O2_BYTE); // F2 = Q1_T1 + Q2 + Q1^tr*t1

@@ -151,7 +151,7 @@ static void calculate_Q_from_F_cyclic_ref(cpk_t *Qs, const sk_t *Fs, const sk_t
memset(tempQ.l2_F2, 0, sizeof(tempQ.l2_F2));
batch_matTr_madd(tempQ.l2_F1, Ts->t1, _V1, _V1_BYTE, _O1, tempQ.l1_F2, _O1, _O1_BYTE); // T1tr*(F1*T1 + F2)
memset(Qs->l1_Q5, 0, _O1_BYTE * N_TRIANGLE_TERMS(_O1));
PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_UpperTrianglize(Qs->l1_Q5, tempQ.l2_F1, _O1, _O1_BYTE); // UT( ... ) // Q5
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_UpperTrianglize(Qs->l1_Q5, tempQ.l2_F1, _O1, _O1_BYTE); // UT( ... ) // Q5

/*
F1_T2 = F1 * t2
@@ -170,7 +170,7 @@ static void calculate_Q_from_F_cyclic_ref(cpk_t *Qs, const sk_t *Fs, const sk_t

memset(tempQ.l1_F2, 0, _O1_BYTE * _V1 * _O2); // should be F3. assuming: _O1 >= _O2
batch_matTr_madd(tempQ.l1_F2, t2, _V1, _V1_BYTE, _O2, Qs->l1_Q3, _O2, _O1_BYTE); // T2tr * ( F1_T2 + F2_T3 )
PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_UpperTrianglize(Qs->l1_Q9, tempQ.l1_F2, _O2, _O1_BYTE); // Q9
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_UpperTrianglize(Qs->l1_Q9, tempQ.l1_F2, _O2, _O1_BYTE); // Q9

batch_trimatTr_madd(Qs->l1_Q3, Fs->l1_F1, t2, _V1, _V1_BYTE, _O2, _O1_BYTE); // F1_F1T_T2 + F2_T3 // Q3

@@ -197,17 +197,17 @@ static void calculate_Q_from_F_cyclic_ref(cpk_t *Qs, const sk_t *Fs, const sk_t

batch_matTr_madd(tempQ.l2_F3, Ts->t3, _O1, _O1_BYTE, _O2, tempQ.l2_F6, _O2, _O2_BYTE); // T2tr*( ..... ) + T3tr*( ..... )
memset(Qs->l2_Q9, 0, _O2_BYTE * N_TRIANGLE_TERMS(_O2));
PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_UpperTrianglize(Qs->l2_Q9, tempQ.l2_F3, _O2, _O2_BYTE); // Q9
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_UpperTrianglize(Qs->l2_Q9, tempQ.l2_F3, _O2, _O2_BYTE); // Q9
}

// Choosing implementations depends on the macros: _BLAS_SSE_ and _BLAS_AVX2_
#define calculate_F_from_Q_impl calculate_F_from_Q_ref
#define calculate_Q_from_F_cyclic_impl calculate_Q_from_F_cyclic_ref

void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_calculate_F_from_Q(sk_t *Fs, const sk_t *Qs, sk_t *Ts) {
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_calculate_F_from_Q(sk_t *Fs, const sk_t *Qs, sk_t *Ts) {
calculate_F_from_Q_impl(Fs, Qs, Ts);
}

void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_calculate_Q_from_F_cyclic(cpk_t *Qs, const sk_t *Fs, const sk_t *Ts) {
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_calculate_Q_from_F_cyclic(cpk_t *Qs, const sk_t *Fs, const sk_t *Ts) {
calculate_Q_from_F_cyclic_impl(Qs, Fs, Ts);
}

crypto_sign/rainbowVc-cyclic/clean/rainbow_keypair_computation.h → crypto_sign/rainbowI-compressed/clean/rainbow_keypair_computation.h 查看文件

@@ -37,7 +37,7 @@ typedef struct rainbow_extend_publickey {
/// @param[out] pk - the classic public key.
/// @param[in] cpk - the internel public key.
///
void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk);
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk);
/////////////////////////////////////////////////

///
@@ -47,7 +47,7 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk);
/// @param[in] Fs - parts of the secret key: l1_F1, l1_F2, l2_F1, l2_F2, l2_F3, l2_F5, l2_F6
/// @param[in] Ts - parts of the secret key: T1, T4, T3
///
void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_calculate_Q_from_F(ext_cpk_t *Qs, const sk_t *Fs, const sk_t *Ts);
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_calculate_Q_from_F(ext_cpk_t *Qs, const sk_t *Fs, const sk_t *Ts);


///
@@ -57,7 +57,7 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_calculate_Q_from_F(ext_cpk_t *Qs, const sk_t
/// @param[in] Qs - parts of the pk: l1_Q1, l1_Q2, l2_Q1, l2_Q2, l2_Q3, l2_Q5, l2_Q6
/// @param[in] Ts - parts of the sk: T1, T4, T3
///
void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_calculate_F_from_Q(sk_t *Fs, const sk_t *Qs, sk_t *Ts);
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_calculate_F_from_Q(sk_t *Fs, const sk_t *Qs, sk_t *Ts);

///
/// @brief Computing parts of the pk from the secret key
@@ -66,6 +66,6 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_calculate_F_from_Q(sk_t *Fs, const sk_t *Qs,
/// @param[in] Fs - parts of the sk: l1_F1, l1_F2, l2_F1, l2_F2, l2_F3, l2_F5, l2_F6
/// @param[in] Ts - parts of the sk: T1, T4, T3
///
void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_calculate_Q_from_F_cyclic(cpk_t *Qs, const sk_t *Fs, const sk_t *Ts);
void PQCLEAN_RAINBOWICOMPRESSED_CLEAN_calculate_Q_from_F_cyclic(cpk_t *Qs, const sk_t *Fs, const sk_t *Ts);

#endif // _RAINBOW_KEYPAIR_COMP_H_

crypto_sign/rainbowIIIc-classic/clean/sign.c → crypto_sign/rainbowI-compressed/clean/sign.c 查看文件

@@ -12,26 +12,28 @@
#include <stdlib.h>
#include <string.h>

int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_crypto_sign_keypair(unsigned char *pk, unsigned char *sk) {
int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_crypto_sign_keypair(unsigned char *pk, unsigned char *sk) {
unsigned char sk_seed[LEN_SKSEED] = {0};
randombytes(sk_seed, LEN_SKSEED);

PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_generate_keypair((pk_t *)pk, (sk_t *)sk, sk_seed);
unsigned char pk_seed[LEN_PKSEED] = {0};
randombytes(pk_seed, LEN_PKSEED);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_generate_compact_keypair_cyclic((cpk_t *)pk, (csk_t *)sk, pk_seed, sk_seed);
return 0;
}

int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_crypto_sign(unsigned char *sm, size_t *smlen, const unsigned char *m, size_t mlen, const unsigned char *sk) {
int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_crypto_sign(unsigned char *sm, size_t *smlen, const unsigned char *m, size_t mlen, const unsigned char *sk) {
unsigned char digest[_HASH_LEN];

PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_hash_msg(digest, _HASH_LEN, m, mlen);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_hash_msg(digest, _HASH_LEN, m, mlen);

memcpy(sm, m, mlen);
smlen[0] = mlen + _SIGNATURE_BYTE;

return PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_rainbow_sign(sm + mlen, (const sk_t *)sk, digest);
return PQCLEAN_RAINBOWICOMPRESSED_CLEAN_rainbow_sign_cyclic(sm + mlen, (const csk_t *)sk, digest);
}

int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_crypto_sign_open(unsigned char *m, size_t *mlen, const unsigned char *sm, size_t smlen, const unsigned char *pk) {
int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_crypto_sign_open(unsigned char *m, size_t *mlen, const unsigned char *sm, size_t smlen, const unsigned char *pk) {
int rc;
if (_SIGNATURE_BYTE > smlen) {
rc = -1;
@@ -39,9 +41,9 @@ int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_crypto_sign_open(unsigned char *m, size_t *
*mlen = smlen - _SIGNATURE_BYTE;

unsigned char digest[_HASH_LEN];
PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_hash_msg(digest, _HASH_LEN, sm, *mlen);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_hash_msg(digest, _HASH_LEN, sm, *mlen);

rc = PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_rainbow_verify(digest, sm + mlen[0], (const pk_t *)pk);
rc = PQCLEAN_RAINBOWICOMPRESSED_CLEAN_rainbow_verify_cyclic(digest, sm + mlen[0], (const cpk_t *)pk);
}
if (!rc) {
memmove(m, sm, smlen - _SIGNATURE_BYTE);
@@ -52,23 +54,23 @@ int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_crypto_sign_open(unsigned char *m, size_t *
return rc;
}

int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_crypto_sign_signature(
int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_crypto_sign_signature(
uint8_t *sig, size_t *siglen,
const uint8_t *m, size_t mlen, const uint8_t *sk) {
unsigned char digest[_HASH_LEN];

PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_hash_msg(digest, _HASH_LEN, m, mlen);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_hash_msg(digest, _HASH_LEN, m, mlen);
*siglen = _SIGNATURE_BYTE;
return PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_rainbow_sign(sig, (const sk_t *)sk, digest);
return PQCLEAN_RAINBOWICOMPRESSED_CLEAN_rainbow_sign_cyclic(sig, (const csk_t *)sk, digest);
}

int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_crypto_sign_verify(
int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_crypto_sign_verify(
const uint8_t *sig, size_t siglen,
const uint8_t *m, size_t mlen, const uint8_t *pk) {
if (siglen != _SIGNATURE_BYTE) {
return -1;
}
unsigned char digest[_HASH_LEN];
PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_hash_msg(digest, _HASH_LEN, m, mlen);
return PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_rainbow_verify(digest, sig, (const pk_t *)pk);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_hash_msg(digest, _HASH_LEN, m, mlen);
return PQCLEAN_RAINBOWICOMPRESSED_CLEAN_rainbow_verify_cyclic(digest, sig, (const cpk_t *)pk);
}

crypto_sign/rainbowIa-cyclic-compressed/clean/utils_hash.c → crypto_sign/rainbowI-compressed/clean/utils_hash.c 查看文件

@@ -7,7 +7,7 @@
#include "rainbow_config.h"
#include "sha2.h"

static inline int _hash(unsigned char *digest, const unsigned char *m, size_t mlen) {
static inline int h(unsigned char *digest, const unsigned char *m, size_t mlen) {
sha256(digest, m, mlen);
return 0;
}
@@ -25,14 +25,14 @@ static inline int expand_hash(unsigned char *digest, size_t n_digest, const unsi
n_digest -= _HASH_LEN;

while (_HASH_LEN <= n_digest) {
_hash(digest + _HASH_LEN, digest, _HASH_LEN);
h(digest + _HASH_LEN, digest, _HASH_LEN);

n_digest -= _HASH_LEN;
digest += _HASH_LEN;
}
unsigned char temp[_HASH_LEN];
if (n_digest) {
_hash(temp, digest, _HASH_LEN);
h(temp, digest, _HASH_LEN);
for (size_t i = 0; i < n_digest; i++) {
digest[_HASH_LEN + i] = temp[i];
}
@@ -40,11 +40,11 @@ static inline int expand_hash(unsigned char *digest, size_t n_digest, const unsi
return 0;
}

int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_hash_msg(unsigned char *digest,
int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_hash_msg(unsigned char *digest,
size_t len_digest,
const unsigned char *m,
size_t mlen) {
unsigned char buf[_HASH_LEN];
_hash(buf, m, mlen);
h(buf, m, mlen);
return expand_hash(digest, len_digest, buf);
}

crypto_sign/rainbowIIIc-classic/clean/utils_hash.h → crypto_sign/rainbowI-compressed/clean/utils_hash.h 查看文件

@@ -6,6 +6,6 @@

#include <stddef.h>

int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_hash_msg(unsigned char *digest, size_t len_digest, const unsigned char *m, size_t mlen);
int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_hash_msg(unsigned char *digest, size_t len_digest, const unsigned char *m, size_t mlen);

#endif // _UTILS_HASH_H_

crypto_sign/rainbowIIIc-classic/clean/utils_prng.c → crypto_sign/rainbowI-compressed/clean/utils_prng.c 查看文件

@@ -78,13 +78,13 @@ static int randombytes_with_state(prng_t *state,
return 0;
}

int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_prng_set(prng_t *ctx, const void *prng_seed, unsigned long prng_seedlen) {
int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_prng_set(prng_t *ctx, const void *prng_seed, unsigned long prng_seedlen) {
unsigned char seed[48];
if (prng_seedlen >= 48) {
memcpy(seed, prng_seed, 48);
} else {
memcpy(seed, prng_seed, prng_seedlen);
PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_hash_msg(seed + prng_seedlen, 48 - (unsigned)prng_seedlen, (const unsigned char *)prng_seed, prng_seedlen);
PQCLEAN_RAINBOWICOMPRESSED_CLEAN_hash_msg(seed + prng_seedlen, 48 - (unsigned)prng_seedlen, (const unsigned char *)prng_seed, prng_seedlen);
}

randombytes_init_with_state(ctx, seed);
@@ -92,6 +92,6 @@ int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_prng_set(prng_t *ctx, const void *prng_seed
return 0;
}

int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_prng_gen(prng_t *ctx, unsigned char *out, unsigned long outlen) {
int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_prng_gen(prng_t *ctx, unsigned char *out, unsigned long outlen) {
return randombytes_with_state(ctx, out, outlen);
}

crypto_sign/rainbowIIIc-classic/clean/utils_prng.h → crypto_sign/rainbowI-compressed/clean/utils_prng.h 查看文件

@@ -12,7 +12,7 @@ typedef struct {
unsigned char V[16];
} prng_t;

int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_prng_set(prng_t *ctx, const void *prng_seed, unsigned long prng_seedlen);
int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_prng_gen(prng_t *ctx, unsigned char *out, unsigned long outlen);
int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_prng_set(prng_t *ctx, const void *prng_seed, unsigned long prng_seedlen);
int PQCLEAN_RAINBOWICOMPRESSED_CLEAN_prng_gen(prng_t *ctx, unsigned char *out, unsigned long outlen);

#endif // _UTILS_PRNG_H_

+ 20
- 0
crypto_sign/rainbowIII-circumzenithal/META.yml 查看文件

@@ -0,0 +1,20 @@
name: "RAINBOW(256,68,32,48) - circumzenithal"
type: signature
claimed-nist-level: 3
length-public-key: 264608
length-secret-key: 626048
length-signature: 164
nistkat-sha256: 1b5cbbdef12492ba8176309a44461d3d64a05b049f78edb85af1d166f4b64f32
testvectors-sha256: de0cb0aabde2f779bffde09af2bde4b0b125cbbe9491551869e39051b94a2183
principal-submitters:
- Jintai Ding
auxiliary-submitters:
- Ming-Shing Chen
- Matthias Kannwischer
- Jacques Patarin
- Albrecht Petzoldt
- Dieter Schmidt
- Bo-Yin Yang
implementations:
- name: clean
version: https://github.com/fast-crypto-lab/rainbow-submission-round2/commit/173ada0e077e1b9dbd8e4a78994f87acc0c92263

crypto_sign/rainbowIa-classic/clean/LICENSE → crypto_sign/rainbowIII-circumzenithal/clean/LICENSE 查看文件


+ 21
- 0
crypto_sign/rainbowIII-circumzenithal/clean/Makefile 查看文件

@@ -0,0 +1,21 @@
# This Makefile can be used with GNU Make or BSD Make

LIB=librainbowIII-circumzenithal_clean.a

HEADERS = api.h blas_comm.h blas.h gf.h parallel_matrix_op.h rainbow_blas.h rainbow_config.h rainbow.h rainbow_keypair_computation.h rainbow_keypair.h utils_hash.h utils_prng.h
OBJECTS = blas_comm.o parallel_matrix_op.o rainbow.o rainbow_keypair.o rainbow_keypair_computation.o sign.o utils_hash.o utils_prng.o blas.o gf.o


CFLAGS=-O3 -Wall -Wconversion -Wextra -Wpedantic -Wvla -Werror -Wmissing-prototypes -Wredundant-decls -std=c99 -I../../../common $(EXTRAFLAGS)

all: $(LIB)

%.o: %.c $(HEADERS)
$(CC) $(CFLAGS) -c -o $@ $<

$(LIB): $(OBJECTS)
$(AR) -r $@ $(OBJECTS)

clean:
$(RM) $(OBJECTS)
$(RM) $(LIB)

+ 19
- 0
crypto_sign/rainbowIII-circumzenithal/clean/Makefile.Microsoft_nmake 查看文件

@@ -0,0 +1,19 @@
# This Makefile can be used with Microsoft Visual Studio's nmake using the command:
# nmake /f Makefile.Microsoft_nmake

LIBRARY=librainbowIII-circumzenithal_clean.lib
OBJECTS = blas_comm.obj parallel_matrix_op.obj rainbow.obj rainbow_keypair.obj rainbow_keypair_computation.obj sign.obj utils_hash.obj utils_prng.obj blas.obj gf.obj

CFLAGS=/nologo /O2 /I ..\..\..\common /W4 /WX

all: $(LIBRARY)

# Make sure objects are recompiled if headers change.
$(OBJECTS): *.h

$(LIBRARY): $(OBJECTS)
LIB.EXE /NOLOGO /WX /OUT:$@ $**

clean:
-DEL $(OBJECTS)
-DEL $(LIBRARY)

+ 32
- 0
crypto_sign/rainbowIII-circumzenithal/clean/api.h 查看文件

@@ -0,0 +1,32 @@
#ifndef PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_API_H
#define PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_API_H

#include <stddef.h>
#include <stdint.h>

#define PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_CRYPTO_SECRETKEYBYTES 626048
#define PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_CRYPTO_PUBLICKEYBYTES 264608
#define PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_CRYPTO_BYTES 164
#define PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_CRYPTO_ALGNAME "RAINBOW(256,68,32,48) - circumzenithal"

int PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_crypto_sign_keypair(uint8_t *pk, uint8_t *sk);


int PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_crypto_sign_signature(
uint8_t *sig, size_t *siglen,
const uint8_t *m, size_t mlen, const uint8_t *sk);

int PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_crypto_sign_verify(
const uint8_t *sig, size_t siglen,
const uint8_t *m, size_t mlen, const uint8_t *pk);

int PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_crypto_sign(uint8_t *sm, size_t *smlen,
const uint8_t *m, size_t mlen,
const uint8_t *sk);

int PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_crypto_sign_open(uint8_t *m, size_t *mlen,
const uint8_t *sm, size_t smlen,
const uint8_t *pk);


#endif

+ 31
- 0
crypto_sign/rainbowIII-circumzenithal/clean/blas.c 查看文件

@@ -0,0 +1,31 @@
#include "blas.h"
#include "gf.h"

#include <stddef.h>

void PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256v_predicated_add(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, size_t _num_byte) {
uint8_t pr_u8 = (uint8_t) ((uint8_t) 0 - predicate);
for (size_t i = 0; i < _num_byte; i++) {
accu_b[i] ^= (a[i] & pr_u8);
}
}

void PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256v_add(uint8_t *accu_b, const uint8_t *a, size_t _num_byte) {
for (size_t i = 0; i < _num_byte; i++) {
accu_b[i] ^= a[i];
}
}


void PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256v_mul_scalar(uint8_t *a, uint8_t b, size_t _num_byte) {
for (size_t i = 0; i < _num_byte; i++) {
a[i] = PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256_mul(a[i], b);
}
}

void PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256v_madd(uint8_t *accu_c, const uint8_t *a, uint8_t gf256_b, size_t _num_byte) {
for (size_t i = 0; i < _num_byte; i++) {
accu_c[i] ^= PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256_mul(a[i], gf256_b);
}
}


+ 19
- 0
crypto_sign/rainbowIII-circumzenithal/clean/blas.h 查看文件

@@ -0,0 +1,19 @@
#ifndef _BLAS_H_
#define _BLAS_H_
/// @file blas.h
/// @brief Functions for implementing basic linear algebra functions.
///

#include "rainbow_config.h"
#include <stddef.h>
#include <stdint.h>

void PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256v_predicated_add(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, size_t _num_byte);
void PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256v_add(uint8_t *accu_b, const uint8_t *a, size_t _num_byte);


void PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256v_mul_scalar(uint8_t *a, uint8_t b, size_t _num_byte);
void PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256v_madd(uint8_t *accu_c, const uint8_t *a, uint8_t gf256_b, size_t _num_byte);


#endif // _BLAS_H_

+ 144
- 0
crypto_sign/rainbowIII-circumzenithal/clean/blas_comm.c 查看文件

@@ -0,0 +1,144 @@
/// @file blas_comm.c
/// @brief The standard implementations for blas_comm.h
///

#include "blas_comm.h"
#include "blas.h"
#include "gf.h"
#include "rainbow_config.h"

#include <stdint.h>
#include <string.h>

void PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte) {
for (size_t i = 0; i < _num_byte; i++) {
b[i] = 0;
}
}
/// @brief get an element from GF(256) vector .
///
/// @param[in] a - the input vector a.
/// @param[in] i - the index in the vector a.
/// @return the value of the element.
///
uint8_t PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256v_get_ele(const uint8_t *a, unsigned int i) {
return a[i];
}

unsigned int PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256v_is_zero(const uint8_t *a, unsigned int _num_byte) {
uint8_t r = 0;
while (_num_byte--) {
r |= a[0];
a++;
}
return (0 == r);
}

/// polynomial multplication
/// School boook
void PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256v_polymul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int _num) {
PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256v_set_zero(c, _num * 2 - 1);
for (unsigned int i = 0; i < _num; i++) {
PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256v_madd(c + i, a, b[i], _num);
}
}

static void gf256mat_prod_ref(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b) {
PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256v_set_zero(c, n_A_vec_byte);
for (unsigned int i = 0; i < n_A_width; i++) {
PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256v_madd(c, matA, b[i], n_A_vec_byte);
matA += n_A_vec_byte;
}
}

void PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec) {
unsigned int n_vec_byte = len_vec;
for (unsigned int k = 0; k < len_vec; k++) {
PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256v_set_zero(c, n_vec_byte);
const uint8_t *bk = b + n_vec_byte * k;
for (unsigned int i = 0; i < len_vec; i++) {
PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256v_madd(c, a + n_vec_byte * i, bk[i], n_vec_byte);
}
c += n_vec_byte;
}
}

static unsigned int gf256mat_gauss_elim_ref(uint8_t *mat, unsigned int h, unsigned int w) {
unsigned int r8 = 1;

for (unsigned int i = 0; i < h; i++) {
uint8_t *ai = mat + w * i;
unsigned int skip_len_align4 = i & ((unsigned int)~0x3);

for (unsigned int j = i + 1; j < h; j++) {
uint8_t *aj = mat + w * j;
PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256v_predicated_add(ai + skip_len_align4, 1 ^ PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256_is_nonzero(ai[i]), aj + skip_len_align4, w - skip_len_align4);
}
r8 &= PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256_is_nonzero(ai[i]);
uint8_t pivot = ai[i];
pivot = PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256_inv(pivot);
PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256v_mul_scalar(ai + skip_len_align4, pivot, w - skip_len_align4);
for (unsigned int j = 0; j < h; j++) {
if (i == j) {
continue;
}
uint8_t *aj = mat + w * j;
PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256v_madd(aj + skip_len_align4, ai + skip_len_align4, aj[i], w - skip_len_align4);
}
}

return r8;
}

static unsigned int gf256mat_solve_linear_eq_ref(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n) {
uint8_t mat[64 * 64];
for (unsigned int i = 0; i < n; i++) {
memcpy(mat + i * (n + 1), inp_mat + i * n, n);
mat[i * (n + 1) + n] = c_terms[i];
}
unsigned int r8 = PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256mat_gauss_elim(mat, n, n + 1);
for (unsigned int i = 0; i < n; i++) {
sol[i] = mat[i * (n + 1) + n];
}
return r8;
}

static inline void gf256mat_submat(uint8_t *mat2, unsigned int w2, unsigned int st, const uint8_t *mat, unsigned int w, unsigned int h) {
for (unsigned int i = 0; i < h; i++) {
for (unsigned int j = 0; j < w2; j++) {
mat2[i * w2 + j] = mat[i * w + st + j];
}
}
}

unsigned int PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer) {
uint8_t *aa = buffer;
for (unsigned int i = 0; i < H; i++) {
uint8_t *ai = aa + i * 2 * H;
PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256v_set_zero(ai, 2 * H);
PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256v_add(ai, a + i * H, H);
ai[H + i] = 1;
}
unsigned int r8 = PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256mat_gauss_elim(aa, H, 2 * H);
gf256mat_submat(inv_a, H, H, aa, 2 * H, H);
return r8;
}


// choosing the implementations depends on the macros _BLAS_AVX2_ and _BLAS_SSE

#define gf256mat_prod_impl gf256mat_prod_ref
#define gf256mat_gauss_elim_impl gf256mat_gauss_elim_ref
#define gf256mat_solve_linear_eq_impl gf256mat_solve_linear_eq_ref
void PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b) {
gf256mat_prod_impl(c, matA, n_A_vec_byte, n_A_width, b);
}

unsigned int PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w) {
return gf256mat_gauss_elim_impl(mat, h, w);
}

unsigned int PQCLEAN_RAINBOWIIICIRCUMZENITHAL_CLEAN_gf256mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n) {
return gf256mat_solve_linear_eq_impl(sol, inp_mat, c_terms, n);
}


部分文件因文件數量過多而無法顯示

Loading…
取消
儲存