-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
expand_message_xmd : a potential optimization #223
Comments
(cc @armfazh @chris-wood ) |
My take is that most un-optimized implementations won't see much increase in cost, whereas optimized implementations would enjoy significant savings for long One additional advantage is that changing the design as described above might discourage people from defining prehash modes, which is probably a good thing security-wise. |
Ah, thinking about this more, the suggestion doesn't quite work: if We might instead consider:
Now every b_i hash starts with a block comprising The advantage of this construction over the current one is that this lets us reuse work for computing Thoughts? |
@kwantam ACKing this issue! I'll implement the different variants and get some benchmarks. |
Thinking more about this, I think the proposal in my prior message ends up assuming a lot more about the security of the compression function than the current version of xmd does (and, in particular, seems to assume a property that isn't really standard). So I think we'd be better off with the current version, just for the sake of being conservative with security. Details: Recall that the current version of xmd ensures that the "inner" invocation of H (to compute (Of course, the invoking protocol is welcome to use The version I proposed in the prior message tries to ensure that the inner and outer invocations use different IVs by fixing the first block of the outer invocation (rather than the inner one). But for this to work, it has to be the case that the adversary can't craft an input to the inner invocation that causes the outer and inner IVs to match---and to rule this out, we need to rely on some property of the hash function that doesn't seem like a standard one. What property do we need? Well, contrary to what I initially posted above, it's certainly not enough for H to have preimage resistance, because this isn't quite a preimage attack:
(The attacker has strictly more power in the second case than in the first, so we should expect hash functions to be weaker against the second kind of attack than against a preimage attack.) It's also not any of the standard prefix-resistance properties, since those fix a prefix for the attacker to target. We might call what we're looking for prefix-fixpoint-resistance. But since this doesn't appear to be anything like a standard notion of security, it seems at best dubious to base the security of the construction on it. As more evidence that this isn't a great idea, we know that it's relatively easy to find a fixpoint for a Davies-Meyer--style compression function like the one used in SHA-2. I have no idea whether this can be extended to make the attack work, but it seems to be a crack in the armor... |
I consider that we must be act with caution, since it is easy to make wrong decisions that could lead to attacks. As a matter of sanity, we could take some time to revisit the simplest and secure approach, and from it, departing to make some improvements. |
Well, since it seems like there's no way to make this work-savings proposal happen unless we're willing to make some weird assumption about a hash function, how about we table this for now and revisit if any of us comes up with a better idea? Meanwhile, I think @armfazh is right that we want to write down a detailed analysis of the current expand_message_xmd function. Just for the sake of completeness, here's a variant of our current function that gets rid of the XOR operation, at the cost of one more compression function invocation. (The security analysis of this one is somewhat easier because it doesn't use XOR chaining.)
Here, unless The extra compression function invocation is to compute
which would require at least two compression function invocations for every |
Hi folks,
It occurs to me that there's one possible modification to expand_message_xmd that would make it slightly nicer for some users. It's not a clear and unqualified win, but it's worth at least discussing.
Right now, expand_message_xmd computes the following:
This is to ensure that
b_0
andb_i
(i >= 1) are hashed with different initialization vectors. The downside of this approach is that some protocols will already have computedH(msg || ...)
, and the above means that they have to pass overmsg
again to computeb_0
.We could instead consider doing this:
This also ensures that
b_0
andb_i
(i >= 1) are hashed starting from different initialization vectors, but now implementors can reuse the work computingH(msg || ...)
inb_0
.This looks like strictly more hashing work, since all the
b_i
need to be prefixed with a block of 0s. But as we know, most of the time implementations allow you to preload the state of the hash function, so in practice it's possible to optimize this away. On the other hand, anyone who doesn't want to implement this optimization will pay extra for hashing.So the question is, do we enable a potentially nice optimization at the cost of making un-optimized implementations slower?
(This assumes, of course, that we're willing to make any change at all. But now's the time for a change, since to my knowledge no one except me has actually implemented the new hash_to_field functions yet.)
The text was updated successfully, but these errors were encountered: