mldsa_gh 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +88 -0
- data/ext/mldsa_gh_native/extconf.rb +14 -0
- data/ext/mldsa_gh_native/mldsa_gh_native.c +222 -0
- data/ext/mldsa_gh_native/mldsa_gh_native_all.c +24 -0
- data/ext/mldsa_gh_native/mldsa_gh_native_all.h +26 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/BUILDING.md +108 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/LICENSE +305 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/README.md +247 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/README.md +23 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/mldsa_native.c +803 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/mldsa_native.h +956 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/mldsa_native_asm.S +830 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/mldsa_native_config.h +855 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/cbmc.h +233 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/common.h +301 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/context.h +152 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/ct.c +21 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/ct.h +373 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/debug.c +75 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/debug.h +125 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/fips202.c +270 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/fips202.h +224 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/fips202x4.c +187 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/fips202x4.h +125 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.c +510 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.h +110 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/auto.h +85 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/fips202_native_aarch64.h +69 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_aarch64_asm.S +378 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S +207 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S +262 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S +1080 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S +990 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccakf1600_round_constants.c +47 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_scalar.h +27 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_v84a.h +36 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x2_v84a.h +40 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_scalar.h +32 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +37 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/api.h +129 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/README.md +10 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/mve.h +67 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/fips202_native_armv81m.h +37 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +717 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.c +42 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_state_extract_bytes_mve.S +334 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_state_xor_bytes_mve.S +355 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccakf1600_round_constants.c +53 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/auto.h +35 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/keccak_f1600_x4_avx2.h +34 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/fips202_native_x86_64.h +45 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2_asm.S +488 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccakf1600_constants.c +52 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/meta.h +314 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/aarch64_zetas.c +248 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/arith_native_aarch64.h +367 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_intt_aarch64_asm.S +786 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_ntt_aarch64_asm.S +686 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_pointwise_montgomery_aarch64_asm.S +106 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_caddq_aarch64_asm.S +69 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_chknorm_aarch64_asm.S +76 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_decompose_32_aarch64_asm.S +108 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_decompose_88_aarch64_asm.S +108 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_use_hint_32_aarch64_asm.S +125 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_use_hint_88_aarch64_asm.S +133 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyvecl_pointwise_acc_montgomery_l4_aarch64_asm.S +157 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm.S +173 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm.S +205 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyz_unpack_17_aarch64_asm.S +103 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyz_unpack_19_aarch64_asm.S +100 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_rej_uniform_aarch64_asm.S +222 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_rej_uniform_eta2_aarch64_asm.S +170 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_rej_uniform_eta4_aarch64_asm.S +163 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_table.c +52 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta_table.c +547 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_table.c +63 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/api.h +617 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/meta.h +24 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/meta.h +323 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/arith_native_x86_64.h +330 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/consts.c +157 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/consts.h +27 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_intt_avx2_asm.S +2333 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_ntt_avx2_asm.S +2405 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_nttunpack_avx2_asm.S +254 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_acc_l4_avx2_asm.S +173 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_acc_l5_avx2_asm.S +189 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_acc_l7_avx2_asm.S +221 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_avx2_asm.S +158 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_caddq_avx2_asm.S +199 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_chknorm_avx2_asm.S +176 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_decompose_32_avx2_asm.S +490 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_decompose_88_avx2_asm.S +489 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_use_hint_32_avx2_asm.S +123 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_use_hint_88_avx2_asm.S +125 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_polyz_unpack_17_avx2_asm.S +355 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_polyz_unpack_19_avx2_asm.S +355 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_avx2_asm.S +132 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_eta2_avx2_asm.S +205 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_eta4_avx2_asm.S +176 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_table.c +161 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/packing.c +213 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/packing.h +277 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/params.h +153 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/poly.c +1066 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/poly.h +464 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/poly_kl.c +910 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/poly_kl.h +367 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/polyvec.c +509 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/polyvec.h +435 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/polyvec_lazy.c +311 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/polyvec_lazy.h +652 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/randombytes.h +26 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/reduce.h +144 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/rounding.h +265 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/sign.c +1720 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/sign.h +850 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/symmetric.h +68 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/sys.h +327 -0
- data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/zetas.inc +55 -0
- data/lib/mldsa/parameter_set.rb +82 -0
- data/lib/mldsa/signing_key.rb +147 -0
- data/lib/mldsa/verify_key.rb +72 -0
- data/lib/mldsa/version.rb +7 -0
- data/lib/mldsa_gh.rb +93 -0
- metadata +225 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: aed3bb631447f2cdb28c472cf08605aafb240a19a8833e0a4e5f66a1b39946d6
|
|
4
|
+
data.tar.gz: 1cb8657a920600ba10ac0baa7ca92ceeb3ce9db6adeefca3de3ddadef5aa968c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 0152a68f82bf5446a7b67d828f01f971dce522b512858cc5dc46e4d3e78be75c818dce581a118ce5e0f3b8279f0cd8658f8253a6452953ade62a48f7d041493e
|
|
7
|
+
data.tar.gz: c4aefcae2c3bb5055b0f7348c30eec5f96613f668db704ed2eaabf5c062205e6192e1db8b1211279c5644cceffd2fa376edf4dcc85cbdc448f1615799c6198ae
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 vcsjones
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# ML-DSA GitHub
|
|
2
|
+
|
|
3
|
+
Ruby bindings for ML-DSA using the vendored `mldsa-native`.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```ruby
|
|
8
|
+
require "mldsa_gh"
|
|
9
|
+
|
|
10
|
+
signing_key = MLDSA::SigningKey.generate(MLDSA::ML_DSA_65)
|
|
11
|
+
signature = signing_key.sign("message", context: "example")
|
|
12
|
+
|
|
13
|
+
verify_key = signing_key.verify_key
|
|
14
|
+
verify_key.verify(signature, "message", context: "example")
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Import a private seed, private key, or public key:
|
|
18
|
+
|
|
19
|
+
```ruby
|
|
20
|
+
signing_key = MLDSA::SigningKey.new(seed, MLDSA::ML_DSA_44)
|
|
21
|
+
signing_key = MLDSA::SigningKey.from_private_key(private_key, MLDSA::ML_DSA_44)
|
|
22
|
+
verify_key = MLDSA::VerifyKey.new(public_key, MLDSA::ML_DSA_44)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Parameter sets are objects describing an ML-DSA parameter set and sizes:
|
|
26
|
+
|
|
27
|
+
```ruby
|
|
28
|
+
MLDSA::ML_DSA_44.public_key_size # => 1312
|
|
29
|
+
MLDSA::ML_DSA_44.private_key_size # => 2560
|
|
30
|
+
MLDSA::ML_DSA_44.signature_size # => 2420
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## External Mu
|
|
34
|
+
|
|
35
|
+
ML-DSA signs in "pure" mode by default. That means callers provide the message bytes directly, rather than providing
|
|
36
|
+
a pre-hash or externally computed message representative. mldsa-native still computes ML-DSA's internal message
|
|
37
|
+
representative while signing. Pure mode is useful to avoid pre-hashing misuse, but it means the signer must have the
|
|
38
|
+
entire message available to pass into the signing operation. This can make signing large inputs, such as files, difficult
|
|
39
|
+
when buffering the full input in memory is not feasible.
|
|
40
|
+
|
|
41
|
+
ML-DSA has an "external mu" mode where the message representative is computed externally and then passed to signing.
|
|
42
|
+
This is similar to signing a digest in that the signing API receives a fixed-size value, but `mu` is not simply
|
|
43
|
+
`SHAKE256(message)`, and external mu is not the same as HashML-DSA.
|
|
44
|
+
|
|
45
|
+
External mu requires using the SHAKE-256 sponge function. It is defined as
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
SHAKE256(SHAKE256(public_key_bytes, 64) || 0x00 || context_size_byte || context || message, 64)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
One way to compute `mu` is with the `sha3` gem. This example shows computing the mu for "helloworld", however
|
|
52
|
+
broken up in to two operations.
|
|
53
|
+
|
|
54
|
+
```ruby
|
|
55
|
+
require "sha3"
|
|
56
|
+
|
|
57
|
+
context = "example"
|
|
58
|
+
message1 = "hello"
|
|
59
|
+
message2 = "world"
|
|
60
|
+
verify_key = signing_key.verify_key
|
|
61
|
+
|
|
62
|
+
tr_hasher = SHA3::Digest::SHAKE_256.new
|
|
63
|
+
tr_hasher << verify_key.to_bytes
|
|
64
|
+
tr = tr_hasher.squeeze(64)
|
|
65
|
+
|
|
66
|
+
mu_hasher = SHA3::Digest::SHAKE_256.new
|
|
67
|
+
mu_hasher << tr
|
|
68
|
+
mu_hasher << "\x00"
|
|
69
|
+
mu_hasher << context.bytesize.chr # ML-DSA does not permit a context larger than 255 bytes.
|
|
70
|
+
mu_hasher << context
|
|
71
|
+
mu_hasher << message1
|
|
72
|
+
mu_hasher << message2
|
|
73
|
+
mu = mu_hasher.squeeze(signing_key.parameter_set.mu_size)
|
|
74
|
+
|
|
75
|
+
# Sign 'helloworld' based on creating it from external mu.
|
|
76
|
+
signature = signing_key.sign_mu(mu)
|
|
77
|
+
|
|
78
|
+
# Verify it against 'helloworld' with our context to show that mu verifies against pure ML-DSA.
|
|
79
|
+
verify_key.verify(signature, message1 + message2, context: context)
|
|
80
|
+
|
|
81
|
+
# Or verify it against the externally computed mu
|
|
82
|
+
verify_key.verify_mu(signature, mu)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Comparison with `ruby/openssl`
|
|
86
|
+
|
|
87
|
+
Ruby's `openssl` gem can also offer ML-DSA from OpenSSL. However, this requires OpenSSL 3.5 or later, which is fairly new
|
|
88
|
+
and only starting to appear in very recent Linux distributions.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "mkmf"
|
|
4
|
+
|
|
5
|
+
$warnflags = ""
|
|
6
|
+
$CFLAGS << " -O3 -std=c99"
|
|
7
|
+
|
|
8
|
+
extension_dir = File.expand_path(__dir__)
|
|
9
|
+
vendor_mldsa_dir = File.join(extension_dir, "vendor", "mldsa-native", "mldsa")
|
|
10
|
+
|
|
11
|
+
$INCFLAGS << " -I#{vendor_mldsa_dir} -I#{extension_dir}"
|
|
12
|
+
$srcs = ["mldsa_gh_native.c", "mldsa_gh_native_all.c"]
|
|
13
|
+
|
|
14
|
+
create_makefile "mldsa_gh_native"
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
#if defined(__clang__)
|
|
2
|
+
#pragma clang diagnostic push
|
|
3
|
+
#pragma clang diagnostic ignored "-Wdefault-const-init-field-unsafe"
|
|
4
|
+
#endif
|
|
5
|
+
#include "ruby.h"
|
|
6
|
+
#if defined(__clang__)
|
|
7
|
+
#pragma clang diagnostic pop
|
|
8
|
+
#endif
|
|
9
|
+
|
|
10
|
+
#include <stdint.h>
|
|
11
|
+
#include <string.h>
|
|
12
|
+
|
|
13
|
+
#include "mldsa_gh_native_all.h"
|
|
14
|
+
|
|
15
|
+
typedef int (*mldsa_keypair_from_seed_func)(uint8_t *, uint8_t *, const uint8_t *);
|
|
16
|
+
typedef int (*mldsa_public_key_from_private_key_func)(uint8_t *, const uint8_t *);
|
|
17
|
+
typedef int (*mldsa_sign_internal_func)(uint8_t *, const uint8_t *, size_t, const uint8_t *, size_t, const uint8_t *,
|
|
18
|
+
const uint8_t *, int);
|
|
19
|
+
typedef int (*mldsa_verify_func)(const uint8_t *, const uint8_t *, size_t, const uint8_t *, size_t, const uint8_t *);
|
|
20
|
+
typedef int (*mldsa_verify_mu_func)(const uint8_t *, const uint8_t *, const uint8_t *);
|
|
21
|
+
typedef size_t (*mldsa_prepare_domain_separation_prefix_func)(uint8_t *, const uint8_t *, size_t, const uint8_t *, size_t, int);
|
|
22
|
+
|
|
23
|
+
typedef struct {
|
|
24
|
+
int parameter_set;
|
|
25
|
+
size_t private_key_size;
|
|
26
|
+
size_t public_key_size;
|
|
27
|
+
size_t signature_size;
|
|
28
|
+
mldsa_keypair_from_seed_func keypair_from_seed;
|
|
29
|
+
mldsa_public_key_from_private_key_func public_key_from_private_key;
|
|
30
|
+
mldsa_sign_internal_func sign_internal;
|
|
31
|
+
mldsa_verify_func verify;
|
|
32
|
+
mldsa_verify_mu_func verify_mu;
|
|
33
|
+
mldsa_prepare_domain_separation_prefix_func prepare_domain_separation_prefix;
|
|
34
|
+
} mldsa_parameter_set;
|
|
35
|
+
|
|
36
|
+
static VALUE mMLDSA = Qnil;
|
|
37
|
+
static VALUE mMLDSA_Native = Qnil;
|
|
38
|
+
static const mldsa_parameter_set parameter_sets[] = {
|
|
39
|
+
{44, MLDSA44_SECRETKEYBYTES, MLDSA44_PUBLICKEYBYTES, MLDSA44_BYTES,
|
|
40
|
+
mldsa_gh44_keypair_internal, mldsa_gh44_pk_from_sk, mldsa_gh44_signature_internal,
|
|
41
|
+
mldsa_gh44_verify, mldsa_gh44_verify_extmu, mldsa_gh44_prepare_domain_separation_prefix},
|
|
42
|
+
{65, MLDSA65_SECRETKEYBYTES, MLDSA65_PUBLICKEYBYTES, MLDSA65_BYTES,
|
|
43
|
+
mldsa_gh65_keypair_internal, mldsa_gh65_pk_from_sk, mldsa_gh65_signature_internal,
|
|
44
|
+
mldsa_gh65_verify, mldsa_gh65_verify_extmu, mldsa_gh65_prepare_domain_separation_prefix},
|
|
45
|
+
{87, MLDSA87_SECRETKEYBYTES, MLDSA87_PUBLICKEYBYTES, MLDSA87_BYTES,
|
|
46
|
+
mldsa_gh87_keypair_internal, mldsa_gh87_pk_from_sk, mldsa_gh87_signature_internal,
|
|
47
|
+
mldsa_gh87_verify, mldsa_gh87_verify_extmu, mldsa_gh87_prepare_domain_separation_prefix}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
static const mldsa_parameter_set *get_parameter_set(VALUE parameter_set)
|
|
51
|
+
{
|
|
52
|
+
int requested = NUM2INT(parameter_set);
|
|
53
|
+
size_t i;
|
|
54
|
+
|
|
55
|
+
for (i = 0; i < sizeof(parameter_sets) / sizeof(parameter_sets[0]); i++) {
|
|
56
|
+
if (parameter_sets[i].parameter_set == requested) {
|
|
57
|
+
return ¶meter_sets[i];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
rb_raise(rb_eArgError, "expected parameter set 44, 65, or 87, got %d", requested);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static VALUE ensure_string_size(VALUE value, size_t expected_size, const char *name)
|
|
65
|
+
{
|
|
66
|
+
StringValue(value);
|
|
67
|
+
|
|
68
|
+
if ((size_t)RSTRING_LEN(value) != expected_size) {
|
|
69
|
+
rb_raise(rb_eArgError, "expected %zu-byte %s, got %ld", expected_size, name, RSTRING_LEN(value));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return value;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
static VALUE mMLDSA_Native_keypair_from_seed(VALUE self, VALUE parameter_set, VALUE seed)
|
|
76
|
+
{
|
|
77
|
+
const mldsa_parameter_set *params = get_parameter_set(parameter_set);
|
|
78
|
+
VALUE private_key;
|
|
79
|
+
VALUE public_key;
|
|
80
|
+
|
|
81
|
+
(void)self;
|
|
82
|
+
seed = ensure_string_size(seed, MLDSA_SEEDBYTES, "private seed");
|
|
83
|
+
|
|
84
|
+
private_key = rb_str_new(NULL, (long)params->private_key_size);
|
|
85
|
+
public_key = rb_str_new(NULL, (long)params->public_key_size);
|
|
86
|
+
|
|
87
|
+
if (params->keypair_from_seed((uint8_t *)RSTRING_PTR(public_key), (uint8_t *)RSTRING_PTR(private_key),
|
|
88
|
+
(const uint8_t *)RSTRING_PTR(seed)) != 0) {
|
|
89
|
+
rb_raise(rb_eRuntimeError, "ML-DSA key generation failed");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return rb_ary_new_from_args(2, private_key, public_key);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
static VALUE mMLDSA_Native_public_key_from_private_key(VALUE self, VALUE parameter_set, VALUE private_key)
|
|
96
|
+
{
|
|
97
|
+
const mldsa_parameter_set *params = get_parameter_set(parameter_set);
|
|
98
|
+
VALUE public_key;
|
|
99
|
+
|
|
100
|
+
(void)self;
|
|
101
|
+
private_key = ensure_string_size(private_key, params->private_key_size, "private key");
|
|
102
|
+
|
|
103
|
+
public_key = rb_str_new(NULL, (long)params->public_key_size);
|
|
104
|
+
|
|
105
|
+
if (params->public_key_from_private_key((uint8_t *)RSTRING_PTR(public_key),
|
|
106
|
+
(const uint8_t *)RSTRING_PTR(private_key)) != 0) {
|
|
107
|
+
rb_raise(rb_eArgError, "invalid private key");
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return public_key;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
static VALUE mMLDSA_Native_sign(VALUE self, VALUE parameter_set, VALUE private_key, VALUE message, VALUE context,
|
|
114
|
+
VALUE randomness)
|
|
115
|
+
{
|
|
116
|
+
const mldsa_parameter_set *params = get_parameter_set(parameter_set);
|
|
117
|
+
uint8_t pre[MLD_DOMAIN_SEPARATION_MAX_BYTES];
|
|
118
|
+
size_t prelen;
|
|
119
|
+
size_t context_length;
|
|
120
|
+
VALUE signature;
|
|
121
|
+
|
|
122
|
+
(void)self;
|
|
123
|
+
private_key = ensure_string_size(private_key, params->private_key_size, "private key");
|
|
124
|
+
randomness = ensure_string_size(randomness, MLDSA_RNDBYTES, "randomness");
|
|
125
|
+
StringValue(message);
|
|
126
|
+
StringValue(context);
|
|
127
|
+
context_length = (size_t)RSTRING_LEN(context);
|
|
128
|
+
|
|
129
|
+
/* mldsa-native's public randomized signing API obtains hedging randomness
|
|
130
|
+
* by calling mld_randombytes(). We generate that randomness in Ruby before
|
|
131
|
+
* entering native code instead, so native signing never calls back into Ruby
|
|
132
|
+
* while holding RSTRING_PTR values. signature_internal lets us provide that
|
|
133
|
+
* randomness explicitly, but it also requires us to provide mldsa-native's
|
|
134
|
+
* pure ML-DSA domain-separation prefix. */
|
|
135
|
+
prelen = params->prepare_domain_separation_prefix(
|
|
136
|
+
pre, NULL, 0, (const uint8_t *)RSTRING_PTR(context), context_length, MLD_PREHASH_NONE);
|
|
137
|
+
if (prelen == 0) {
|
|
138
|
+
rb_raise(rb_eArgError, "expected context to be at most 255 bytes, got %ld", RSTRING_LEN(context));
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
signature = rb_str_new(NULL, (long)params->signature_size);
|
|
142
|
+
|
|
143
|
+
if (params->sign_internal((uint8_t *)RSTRING_PTR(signature), (const uint8_t *)RSTRING_PTR(message),
|
|
144
|
+
(size_t)RSTRING_LEN(message), pre, prelen, (const uint8_t *)RSTRING_PTR(randomness),
|
|
145
|
+
(const uint8_t *)RSTRING_PTR(private_key), 0) != 0) {
|
|
146
|
+
rb_raise(rb_eRuntimeError, "ML-DSA signing failed");
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return signature;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
static VALUE mMLDSA_Native_verify(VALUE self, VALUE parameter_set, VALUE public_key, VALUE signature,
|
|
153
|
+
VALUE message, VALUE context)
|
|
154
|
+
{
|
|
155
|
+
const mldsa_parameter_set *params = get_parameter_set(parameter_set);
|
|
156
|
+
int result;
|
|
157
|
+
|
|
158
|
+
(void)self;
|
|
159
|
+
public_key = ensure_string_size(public_key, params->public_key_size, "public key");
|
|
160
|
+
signature = ensure_string_size(signature, params->signature_size, "signature");
|
|
161
|
+
StringValue(message);
|
|
162
|
+
StringValue(context);
|
|
163
|
+
|
|
164
|
+
result = params->verify((const uint8_t *)RSTRING_PTR(signature), (const uint8_t *)RSTRING_PTR(message),
|
|
165
|
+
(size_t)RSTRING_LEN(message),
|
|
166
|
+
(const uint8_t *)RSTRING_PTR(context), (size_t)RSTRING_LEN(context),
|
|
167
|
+
(const uint8_t *)RSTRING_PTR(public_key));
|
|
168
|
+
|
|
169
|
+
return result == 0 ? Qtrue : Qfalse;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
static VALUE mMLDSA_Native_sign_mu(VALUE self, VALUE parameter_set, VALUE private_key, VALUE mu, VALUE randomness)
|
|
173
|
+
{
|
|
174
|
+
const mldsa_parameter_set *params = get_parameter_set(parameter_set);
|
|
175
|
+
VALUE signature;
|
|
176
|
+
|
|
177
|
+
(void)self;
|
|
178
|
+
private_key = ensure_string_size(private_key, params->private_key_size, "private key");
|
|
179
|
+
mu = ensure_string_size(mu, MLDSA_CRHBYTES, "mu");
|
|
180
|
+
randomness = ensure_string_size(randomness, MLDSA_RNDBYTES, "randomness");
|
|
181
|
+
|
|
182
|
+
signature = rb_str_new(NULL, (long)params->signature_size);
|
|
183
|
+
|
|
184
|
+
if (params->sign_internal((uint8_t *)RSTRING_PTR(signature), (const uint8_t *)RSTRING_PTR(mu),
|
|
185
|
+
(size_t)RSTRING_LEN(mu), NULL, 0, (const uint8_t *)RSTRING_PTR(randomness),
|
|
186
|
+
(const uint8_t *)RSTRING_PTR(private_key), 1) != 0) {
|
|
187
|
+
rb_raise(rb_eRuntimeError, "ML-DSA external-mu signing failed");
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return signature;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
static VALUE mMLDSA_Native_verify_mu(VALUE self, VALUE parameter_set, VALUE public_key, VALUE signature, VALUE mu)
|
|
194
|
+
{
|
|
195
|
+
const mldsa_parameter_set *params = get_parameter_set(parameter_set);
|
|
196
|
+
int result;
|
|
197
|
+
|
|
198
|
+
(void)self;
|
|
199
|
+
public_key = ensure_string_size(public_key, params->public_key_size, "public key");
|
|
200
|
+
signature = ensure_string_size(signature, params->signature_size, "signature");
|
|
201
|
+
mu = ensure_string_size(mu, MLDSA_CRHBYTES, "mu");
|
|
202
|
+
|
|
203
|
+
result = params->verify_mu((const uint8_t *)RSTRING_PTR(signature), (const uint8_t *)RSTRING_PTR(mu),
|
|
204
|
+
(const uint8_t *)RSTRING_PTR(public_key));
|
|
205
|
+
|
|
206
|
+
return result == 0 ? Qtrue : Qfalse;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
void Init_mldsa_gh_native(void)
|
|
210
|
+
{
|
|
211
|
+
mMLDSA = rb_define_module("MLDSA");
|
|
212
|
+
mMLDSA_Native = rb_define_module_under(mMLDSA, "Native");
|
|
213
|
+
rb_define_singleton_method(mMLDSA_Native, "keypair_from_seed",
|
|
214
|
+
mMLDSA_Native_keypair_from_seed, 2);
|
|
215
|
+
rb_define_singleton_method(mMLDSA_Native, "public_key_from_private_key",
|
|
216
|
+
mMLDSA_Native_public_key_from_private_key, 2);
|
|
217
|
+
rb_define_singleton_method(mMLDSA_Native, "sign", mMLDSA_Native_sign, 5);
|
|
218
|
+
rb_define_singleton_method(mMLDSA_Native, "verify", mMLDSA_Native_verify, 5);
|
|
219
|
+
rb_define_singleton_method(mMLDSA_Native, "sign_mu", mMLDSA_Native_sign_mu, 4);
|
|
220
|
+
rb_define_singleton_method(mMLDSA_Native, "verify_mu", mMLDSA_Native_verify_mu, 4);
|
|
221
|
+
|
|
222
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#define MLD_CONFIG_NAMESPACE_PREFIX mldsa_gh
|
|
2
|
+
#define MLD_CONFIG_MULTILEVEL_BUILD
|
|
3
|
+
#define MLD_CONFIG_NO_RANDOMIZED_API
|
|
4
|
+
|
|
5
|
+
#define MLD_CONFIG_MULTILEVEL_WITH_SHARED
|
|
6
|
+
#define MLD_CONFIG_MONOBUILD_KEEP_SHARED_HEADERS
|
|
7
|
+
#define MLD_CONFIG_PARAMETER_SET 44
|
|
8
|
+
#include "vendor/mldsa-native/mldsa/mldsa_native.c"
|
|
9
|
+
#undef MLD_CONFIG_PARAMETER_SET
|
|
10
|
+
#undef MLD_CONFIG_MULTILEVEL_WITH_SHARED
|
|
11
|
+
|
|
12
|
+
#define MLD_CONFIG_MULTILEVEL_NO_SHARED
|
|
13
|
+
#define MLD_CONFIG_PARAMETER_SET 65
|
|
14
|
+
#include "vendor/mldsa-native/mldsa/mldsa_native.c"
|
|
15
|
+
#undef MLD_CONFIG_PARAMETER_SET
|
|
16
|
+
#undef MLD_CONFIG_MONOBUILD_KEEP_SHARED_HEADERS
|
|
17
|
+
|
|
18
|
+
#define MLD_CONFIG_PARAMETER_SET 87
|
|
19
|
+
#include "vendor/mldsa-native/mldsa/mldsa_native.c"
|
|
20
|
+
#undef MLD_CONFIG_PARAMETER_SET
|
|
21
|
+
#undef MLD_CONFIG_MULTILEVEL_NO_SHARED
|
|
22
|
+
#undef MLD_CONFIG_NO_RANDOMIZED_API
|
|
23
|
+
#undef MLD_CONFIG_MULTILEVEL_BUILD
|
|
24
|
+
#undef MLD_CONFIG_NAMESPACE_PREFIX
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#ifndef RUBY_MLDSA_GH_NATIVE_ALL_H
|
|
2
|
+
#define RUBY_MLDSA_GH_NATIVE_ALL_H
|
|
3
|
+
|
|
4
|
+
#define MLD_CONFIG_NAMESPACE_PREFIX mldsa_gh
|
|
5
|
+
#define MLD_CONFIG_MULTILEVEL_BUILD
|
|
6
|
+
#define MLD_CONFIG_NO_RANDOMIZED_API
|
|
7
|
+
|
|
8
|
+
#define MLD_CONFIG_PARAMETER_SET 44
|
|
9
|
+
#include "mldsa_native.h"
|
|
10
|
+
#undef MLD_CONFIG_PARAMETER_SET
|
|
11
|
+
#undef MLD_H
|
|
12
|
+
|
|
13
|
+
#define MLD_CONFIG_PARAMETER_SET 65
|
|
14
|
+
#include "mldsa_native.h"
|
|
15
|
+
#undef MLD_CONFIG_PARAMETER_SET
|
|
16
|
+
#undef MLD_H
|
|
17
|
+
|
|
18
|
+
#define MLD_CONFIG_PARAMETER_SET 87
|
|
19
|
+
#include "mldsa_native.h"
|
|
20
|
+
#undef MLD_CONFIG_PARAMETER_SET
|
|
21
|
+
#undef MLD_CONFIG_NO_RANDOMIZED_API
|
|
22
|
+
#undef MLD_CONFIG_MULTILEVEL_BUILD
|
|
23
|
+
#undef MLD_CONFIG_NAMESPACE_PREFIX
|
|
24
|
+
#undef MLD_H
|
|
25
|
+
|
|
26
|
+
#endif
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
[//]: # (SPDX-License-Identifier: CC-BY-4.0)
|
|
2
|
+
|
|
3
|
+
# Building mldsa-native
|
|
4
|
+
|
|
5
|
+
### Prerequisites
|
|
6
|
+
|
|
7
|
+
To build **mldsa-native**, you need `make` and a C90 compiler. To use the test scripts, you need Python3 (>= 3.7).
|
|
8
|
+
|
|
9
|
+
### By hand
|
|
10
|
+
|
|
11
|
+
See [mldsa](mldsa).
|
|
12
|
+
|
|
13
|
+
### Using `make`
|
|
14
|
+
|
|
15
|
+
You can build and test **mldsa-native** as follows:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
make test # With native code backend (if available)
|
|
19
|
+
make OPT=0 test # With C backend
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
To merely build test components, use the following `make` targets:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
make func
|
|
26
|
+
make kat
|
|
27
|
+
make acvp
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
To run them, add `run_`:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
make run_func
|
|
34
|
+
make run_kat
|
|
35
|
+
make run_acvp
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The resulting binaries can be found in `test/build` (their full path is printed by `make`).
|
|
39
|
+
|
|
40
|
+
For benchmarking, specify the cycle counting method. Currently, **mldsa-native** is supporting NO, PERF, PMU, and MAC:
|
|
41
|
+
* `NO` means that no cycle counting will be used; this can be used to confirm that benchmarks compile fine.
|
|
42
|
+
* `PERF` uses the `perf` kernel module for cycle counting. Does not work on Apple platforms.
|
|
43
|
+
* `PMU` uses direct PMU access if available. On AArch64, this may require you to load a kernel module first, see [here](https://github.com/mupq/pqax?tab=readme-ov-file#enable-access-to-performance-counters). Does not work on Apple platforms.
|
|
44
|
+
* `MAC` is `perf`-based and works on some Apple platforms, at least Apple M1.
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
# CYCLES has to be one of PERF, PMU, MAC, NO
|
|
48
|
+
sudo make run_bench CYCLES=PERF
|
|
49
|
+
sudo make run_bench_components CYCLES=PERF
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Using `tests` script
|
|
53
|
+
|
|
54
|
+
For convenience, you can also use the [`./scripts/tests`](scripts/tests) script as a wrapper around `make`. For
|
|
55
|
+
example,
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
./scripts/tests func
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
will compile and run functionality tests. Similarly,
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
./scripts/tests bench -c PERF -r
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
will compile and run benchmarks, using PERF for cycle counting (`-c PERF`) and running as root (`-r`).
|
|
68
|
+
|
|
69
|
+
For detailed information on how to use the script, please refer to
|
|
70
|
+
`./scripts/tests --help`.
|
|
71
|
+
|
|
72
|
+
### Windows
|
|
73
|
+
|
|
74
|
+
You can also build **mldsa-native** on Windows using `nmake` and an MSVC compiler.
|
|
75
|
+
|
|
76
|
+
To build and run the tests, use the following `nmake` target:
|
|
77
|
+
```powershell
|
|
78
|
+
nmake /f .\Makefile.Microsoft_nmake quickcheck
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
This runs the functional, RNG-failure, allocation, ACVP, KAT and Wycheproof tests. The assembly backends are not yet
|
|
82
|
+
supported on Windows, so the tests are built for the C backend only.
|
|
83
|
+
|
|
84
|
+
# Checking the proofs
|
|
85
|
+
|
|
86
|
+
## CBMC
|
|
87
|
+
|
|
88
|
+
### Prerequisites
|
|
89
|
+
|
|
90
|
+
To run the CBMC proofs, you need specific versions of CBMC and the underlying solvers, e.g. as specified in our `nix` environment; see [nix/cbmc](nix/cbmc/).
|
|
91
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for instructions on how to setup and use `nix`.
|
|
92
|
+
|
|
93
|
+
### Running the CBMC proofs
|
|
94
|
+
|
|
95
|
+
Once you are in the `nix` shell or have all tools setup by hand, use `./scripts/tests cbmc` (or just `tests cbmc` in the `nix` shell) to re-check the CBMC proofs.
|
|
96
|
+
See `tests cbmc --help` for details on the command line options, and [proofs/cbmc](proofs/cbmc) for more details on the CBMC proofs in general.
|
|
97
|
+
|
|
98
|
+
## HOL-Light
|
|
99
|
+
|
|
100
|
+
### Prerequisites
|
|
101
|
+
|
|
102
|
+
To run the HOL-Light proofs, you need recent versions of HOL-Light and s2n-bignum, e.g. as specified in our `nix` environment; see [nix/s2n_bignum](nix/s2n_bignum) and [nix/hol_light](nix/hol_light).
|
|
103
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for instructions on how to setup and use `nix`.
|
|
104
|
+
|
|
105
|
+
### Running the HOL-Light proofs
|
|
106
|
+
|
|
107
|
+
Once you are in the `nix` shell or have all tools setup by hand, use `./scripts/tests hol_light` (or just `tests hol_light` in the `nix` shell) to re-check the HOL-Light proofs. Note that depending on the function, they will take a long time. See `tests hol_light --help` for details on the command line options, and [proofs/hol_light](proofs/hol_light) for more details on the HOL-Light proofs in general.
|
|
108
|
+
|