Support Falcon PADDED signature format#530
Conversation
|
This should just overwrite the current Falcon implementations, as those are attempting to implement the padded format already |
|
Sorry for stealth-editing the description, @thomwiggers; I wanted to see the PR CI results yesterday but didn't have time to write things up properly. Didn't expect anyone to look at it so soon.
The current code already implements the compressed version modulo the value of the |
|
I'm mainly not sure exactly how well variable-length signature formats are supported by PQClean's tests... Even though the API includes |
|
Pinging @dstebila to see how we want to approach this from the liboqs side: proceed with only fixed-length for now and perhaps include variable-length later? Revamp the PQClean tests if necessary? |
This PR adds Falcon*-padded, and also makes some changes to Falcon*, the latter of which is the compressed version, right? So is that compressed version variable length in this PR or not? If it is variable length, then can't we already tell from the CI tests whether PQClean tests have a problem with this? |
| @@ -4,7 +4,7 @@ type: signature | |||
| claimed-nist-level: 1 | |||
| length-public-key: 897 | |||
| length-secret-key: 1281 | |||
| length-signature: 666 | |||
| length-signature: 752 | |||
There was a problem hiding this comment.
It seems strange to me that the (even if just maximum) signature length of Falcon-compressed is larger than the padded format.
There was a problem hiding this comment.
With the padded format, signature generation retries until the signature size is below some fixed constant and then padded to this constant length. The constant is fixed such that the probability of a retry is fairly low. With the compressed format, there are no retries; you get what you get on the first iteration. Hence, a "compressed" signature can be longer than a padded signature but on average is shorter.
The "compressed" name is a bit of misnomer imo, since both padded and compressed version use the same format for representing data. Every padded signature is just a compressed signature with some extra 0s tacked on.
The thing is that accessing the bytes in the signature buffer beyond the length of the signature should probably be categorized as undefined behaviour. The thing with undefined behaviour is that there's a very non-zero chance that these bytes are actually the same each time so if we do something like |
Yeah, that looks like it is the case. I currently get a different length (always slightly less than I have two dumb questions, though:
Does that mean that these signatures are interoperable? Should a compliant
I assume this means (a) the CT format is not compatible with the others, and it would need its own entirely separate |
The Falcon reference implementation verifies signatures of both formats using the same code. The caller can provide the format, or if none is provided the verification code infers it.
The CT format can be handled by the same verify function. In particular, CT-format signatures have a different header byte which allows for easy differentiation. See the I don't think there's any active development going on in liboqs or PQClean to support the CT format, but it's probably in the "nice to have" category. |
|
Sorry that this PR has been collecting dust for a month or so over the holidays. Now that some relevant downstream work in liboqs is ready to go, I'd like to revive it.
How about this proposal for extending the tests to cover variable-length signatures:
If we want to make sure that there are no reads beyond the valid signature length, then we could perhaps mark the signature buffer as initially "uninitialized" and use Would adding one or both of these tests help to alleviate your concerns about supporting variable-length Falcon signatures @thomwiggers? |
This sounds like a good test.
I also like this a lot, though there is of course a bit of overhead when we run Valgrind --- we currently run the |
Valgrind provides a |
7866b9d to
403e279
Compare
293e8cb to
e5f7281
Compare
b707f9f to
6940370
Compare
|
Am I interpreting this PR correctly?:
|
Yes indeed, that's an accurate interpretation. |
|
This is now passing all CI. Notes to make code review easier:
|
|
Since I skipped a number of hanging CI tests, I thought it best to pre-integrate the new code into liboqs to take advantage of its CI (which includes running on an actual ARM machine). https://github.com/open-quantum-safe/liboqs/commits/sw-falcon-padded/ |
d3f5a6f to
016dd2c
Compare
|
Yeah, I think the skipping of tests is unfortunate but probably required. PQClean could use a restructuring of its CI, and we would ideally figure out how to get proper ARM-based tests going (on actual hardware, with accelerators). |
TODO: add a test for interoperability between the two formats (for
crypto_signandcrypto_verifyonly).Will mark as ready for review once CI is green and this test is added.
This PR adds support for the PADDED Falcon signature format.
For a quick refresher on the different formats, here's what the Falcon reference says:
It is possible to implement
crypto_sign_verifyto accept both COMPRESSED and PADDED formats, which is what I've attempted to do. (The reference code does this if thesig_typeparameter is set to 0.) However, this doesn't work as well for non-detached signing/verification. The Falcon spec has a separate format forsmobjects to be used in NIST KATs, but this is only defined for non-padded signatures. Rather than modify the COMPRESSED version'scrypto_sign_openalgorithm to accept PADDED signatures within this format (thereby going outside the spec), I decided to use a simplesignature || messageformat for the PADDED version, since signatures were fixed length and we would be going outside the spec anyway.KAT vectors were generated for the PADDED format by carefully modifying the reference code's KAT generation script. See https://github.com/SWilson4/falcon-padded-KATs for details.
Manually checked properties
.github/workflows/generate_workflows.py) (new schemes)for (size_t i=...)stdint.htypes (includinguint8_tinstead ofunsigned char)size_t