<div dir="ltr">This clamping question also impacts how Tor's Next Generation Onion services will blind keys from the Onion Services Directory authorities.</div><br><div class="gmail_quote"><div dir="ltr">On Mon, Mar 6, 2017 at 2:36 PM Tony Arcieri <<a href="mailto:bascule@gmail.com">bascule@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg">Ed25519 performs the following operations on private scalars immediately prior to use:<div class="gmail_msg"><br class="gmail_msg"></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px" class="gmail_msg"><div class="gmail_msg"><font face="monospace, monospace" class="gmail_msg">scalar[0] &= 248;</font></div><div class="gmail_msg"><font face="monospace, monospace" class="gmail_msg">scalar[31] &= 63;</font></div><div class="gmail_msg"><font face="monospace, monospace" class="gmail_msg">scalar[31] |= 64;</font></div></blockquote><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">I've heard this referred to as "clamping" although that may not be the best term.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">These operations are not applied to the canonical scalar, i.e. the one which is serialized and persisted as part of the keypair. Instead Ed25519 implementations generally flip these bits immediately prior to use, either for signing or deriving the public key.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">From what I've read, this bitflipping is intended to accomplish the following:</div><div class="gmail_msg"><ul class="gmail_msg"><li class="gmail_msg">Prevent small subgroup attacks: flipping these bits makes the scalar a multiple of the cofactor, which I understand is supposed to help prevent small subgroup attacks. However, reading about these attacks, they don't seem to help the attacker very much.</li><li class="gmail_msg">Defense against deficient implementations: I'm not sure I really understand the rationale here, but my understanding is there are certain classes of implementation defects this helps guard against.</li></ul></div><div class="gmail_msg">So far, it's been pretty troublesome finding a really good explanation of what this bitflipping is actually for or anyone who feels particularly strongly as to its importance. The general reaction I've gotten asking about them is akin to "djb flipped these bits... he must have his reasons".</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Flipping these bits is particularly troublesome for implementing hierarchical key derivation schemes (e.g. semiprivate keys, BIP-32) which rely on commutative groups to allow holders of master public keys to derive child public keys by multiplying by scalar values which can be derived by both the public and private key holders (a.k.a. "hardened" vs "non-hardened" derivation in BIP-32 schemes).</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">In these schemes, it's not possible to "clamp" the derived scalar immediately prior to signing ("post-clamping" I guess?), as this would result in a different public key (i.e. the math simply does not work out as the groups are no longer commutative). Instead, if any clamping is to be performed it must happen immediately to the parent scalar, and/or to any scalars derived by both the public and private key holders in such a scheme.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">My intuition is that "clamping" more than once is detrimental in that the clamping operation weakens the key. Not really being sure about the purpose though, I'm not sure if "pre-clamping" is sufficient to guard against these attacks. </div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">I'm very curious if "clamping" can simply be omitted, as it seems to largely be a defense-in-depth measure which guards against a handful of low-severity theoretical attacks. It complicates HKD schemes and, done incorrectly in the context of such a scheme, I'm worried it might actually harm security.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">-- <br class="gmail_msg"><div class="m_-6974441511896531391gmail_signature gmail_msg">Tony Arcieri<br class="gmail_msg"></div>
</div></div>
_______________________________________________<br class="gmail_msg">
Curves mailing list<br class="gmail_msg">
<a href="mailto:Curves@moderncrypto.org" class="gmail_msg" target="_blank">Curves@moderncrypto.org</a><br class="gmail_msg">
<a href="https://moderncrypto.org/mailman/listinfo/curves" rel="noreferrer" class="gmail_msg" target="_blank">https://moderncrypto.org/mailman/listinfo/curves</a><br class="gmail_msg">
</blockquote></div>