mmcloughlin / addchain

Cryptographic Addition Chain Generation in Go
BSD 3-Clause "New" or "Revised" License
184 stars 14 forks source link

internal/gen: generated code doesn't allow aliasing #129

Closed FiloSottile closed 3 years ago

FiloSottile commented 3 years ago

For example, the first two operations of a P-521 chain are

    z.Square(x)
    z.Mul(x, z)

which will break if z = x.

mmcloughlin commented 3 years ago

Aside: reminds me of this https://github.com/mmcloughlin/ec3/issues/83. The EFD contains lots of examples of formulas that don't work under aliasing. The logic to fix up those formulas was pretty gnarly.

https://github.com/mmcloughlin/ec3/blob/3948e750fa5e745b6f160c22d5b8fab3dc6436e7/efd/op3/alias.go

Thankfully in this case it should be much easier.

mmcloughlin commented 3 years ago

Update: #134 landed which should have fixed this. I'm trying to add an extra integration test that runs allocation and execution on every case in the results list (see #136), but running into allocation failures because of dead code (see #133).

mmcloughlin commented 3 years ago

Okay, #127 fixed the missing allocations thing, so I landed #136 which is an integration test over all target exponents in the results list. Calling this done for now. Let me know if you have any issues.