Skip to content

secp256k1: Not constant time #7051

Closed
@tac0turtle

Description

Issue from tendermint in regards to secp256k1. this key is being added directly into the SDK

ValarDragon on Jul 29, 2018 •

Our current secp256k1 implementation isn't constant time. I haven't looked at the actual math parts yet, but the following two very minor things aren't constant time:

Our signature encoding is vartime in the parity of the signature. This is easy to fix. (This is present due to it being vartime in the previous DER encoding as well) This isn't really a problem, since the normal security of ECDSA assumes you get this extra bit of distinguishing s's parity, but we may as well fix it since we're only allowing one parity per #2091.

RFC6979 (Deterministic nonce generation): This is basically impossible to exploit, but I thought I may as well list it here. Every 2**224 signatures on average, RFC6979 will leak some timing information on how the nonce was created. Nothing needs to be changed here imo, since this is very much not a concern.
ValarDragon on Aug 28, 2018

I don't know how I missed this on my first read through this codebase, but there are two more cases of non-constant time ness, but these actually matter.

In the signRFC6979 function (called as part of Sign), the following two lines are present

inv := new(big.Int).ModInverse(k, N)
s := new(big.Int).Mul(privkey.D, r)

From the godocs " Modular exponentation of inputs of a particular size is not a cryptographically constant-time operation. ", thus this isn't constant time.

From conversation with @zmanian, this isn't a prelaunch concern.
ebuchman on Jan 23, 2019

@ValarDragon do you want to open this on the upstream btcd repo?

We will mitigate using #3163 and make clear in documentation that this lib isn't constant time until then.

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions