12

I'm looking at libsecp256k1's codebase, for learning reasons (doubt I can contribute with anything useful there). While looking at the field implementation, the implementation of secp256k1_fe_mul_inner in both 10x26 and 5x52 is a little strange to me. I know some multiplication algorithms, like Karatsuba and Toom's algorithms, but this one doesn't look like one of them, at least I couldn't relate.
Looking at the source and git history, I only see a reference to Peter Dettman, but I was unable to find any paper authored by him. Is this algorithm inspired by a public paper? Any reference would be helpful, as I'm unable to follow reason about the code itself. I understand what it is doing, but I don't know exactly how.

2

1 Answer 1

2

Is this algorithm inspired by a public paper? Any reference would be helpful, as I'm unable to follow reason about the code itself.

I am not sure about "papers", but more or less formal articles on modular multiplication in fact abound: indeed, the implementation in question "simply" leverages known properties of modular arithmetic.

As to the specifics, the following is the link to a post about an older and somewhat simpler version of secp256k1_fe_mul_inner than the current one, but it might be enough to support further exploration/reverse-engineering:

That article also contains a link to the relevant modular arithmetic, in a nice and compact series of slides, which I will repost here:

(There could be some added value in explaining the present implementation of secp256k1_fe_mul_inner, since it adds few more optimizations on top of the basic modular arithmetic. But I think that would require a level of detail and formality that is well beyond the scope of the present question.)

Not the answer you're looking for? Browse other questions tagged or ask your own question.