Conversation
|
@jschneider-bensch, would this interface work libcrux? And in particular: Could libcrux implement this in a way that even when using libcrux as a full SHA2 implementation, it could still provide the "bare SHA" (only full blocks, no padding) and "wrapper around bare" parts separately, and still let the proofs run through? I'm not yet sure how critical that is, but I'd rather check now and adjust if needed. If nothing else, splitting also the libcrux version along this boarder will make it easier to opt in to hardware acceleration where it is supported with less configuration effort. |
|
In Regarding proofs: When we take an implementation exported from HACL (or HACL-rs), as in the case of SHA-2, we don't have a prover in the loop, so to say. The idea here is instead that HACL* is a verified implementation in F*, which can be exported to C, or Rust preserving the verification results established on the F* side, if the pre-conditions for calling any of the functions established there are maintained. So in libcrux, we leave the exported code untouched and give wrappers that ensure the pre-conditions are met and which implement the high-level API. If the low-level functions are called directly, it has to be ensured that all preconditions are met. I have a basic question here, though: Reading through #9, I understood that the motivation for adding a block-only version is too get rid of the padding and spooling code in the provider, right? Would this then be done generically, independent of the backend? |
|
Thanks. Yeah, I think we can just pass around the preconditions. And ad padding, yes, this would be done generically. This PR even contains1 a very simple stupid but correct-for-the-test-cases implementation of that generic mechanism, and I hope that that Extender struct would rather sooner than later be replaced by formally verified/-fiable. code. Footnotes
|
|
I did some quick tests here: Maybe I am missing something, but I still didn't understand the reason of this more constrained API. Is the |
As Jonas said, this is certainly possible, but I don't think it's something we want or should do. This would require adding new, less safe APIs. If we want to have confidence in the implementation here later, we should use libcrux APIs as they are and rather see if we can (want to) add hardware acceleration to that implementation. Doing it the other way around (as proposed here) is not the right approach. |
|
This PR is exactly about using the verified implementation for the block bits around the hardware accelerated inner ones. Libcrux APIs need to take in the hardware primitives, that requires having a version where it only does those outer layers and we plug in the inner ones from hardware. When we assume that the hardware is correct, AIU we'll have to annotate the hardware accelerator with the assertions that it is correct, and then the proof can run through. We can sure do with not exposing the inner half of the algorithm, but it'd give less confidence in the whole system compared to when we expose the inner part along with its proof annotations, because we'd be running different paths between when we use hardware acceleration or not. |
This is adjusted from the one suggested in [16]. [16]: #16
This is adjusted from the one suggested in [16]. [16]: #16
Closes: #12
There's some way to go to provide the top layer, but for a first check, @WilliamTakeshi: If you'd only provide the limited version introduced here for #9, you could just drop all the buffers, and wouldn't need to deal with padding at finalization, right?