/ go Public

# x/crypto/bn256: wrong formulas in comments#48143

Open
opened this issue Sep 2, 2021 · 4 comments
Open

# x/crypto/bn256: wrong formulas in comments #48143

opened this issue Sep 2, 2021 · 4 comments
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Milestone

 bn256/gfp6.go : 251 in latest version of go ``````// On the other hand (xj²τ² + yjτ + z)(xjτ² + yj²τ + z) // = τ²(y²-ξxz) + τ(ξx²-yz) + (z²-ξxy) // // So that's why A = (z²-ξxy), B = (ξx²-yz), C = (y²-ξxz) `````` while the right one is : ``````// On the other hand (xj²τ² + yjτ + z)(xjτ² + yj²τ + z) // = τ²(y²-xz) + τ(ξx²-yz) + (z²-ξxy) // // So that's why A = (z²-ξxy), B = (ξx²-yz), C = (y²-xz) `````` in addition, http://arxiv.org/pdf/0904.0854v3.pdf which is referenced by optate.go : 9 also has wrong formulas : The text was updated successfully, but these errors were encountered:
changed the title golang.org/x/crypto/bn256: wrong formulas x/crypto/bn256: wrong formulas Sep 2, 2021
added this to the Unreleased milestone Sep 2, 2021

### cherrymui commented Sep 2, 2021

 It looks the code actually does `````` C := newGFp2(pool) C.Square(a.y, pool) t1.Mul(a.x, a.z, pool) C.Sub(C, t1) `````` i.e. `C = (y²-xz)` without ξ. @zhangzhanli do you suggest only the comment is wrong or the implementation as well? Thanks.

added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 2, 2021

### zhangzhanli commented Sep 22, 2021

 @cherrymui Yes, it seems the source code works as expected. As for full addition, since we use mixed addition instead , so there is no impact on miller's algorithm.

changed the title x/crypto/bn256: wrong formulas x/crypto/bn256: wrong formulas in comments Sep 22, 2021
added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Sep 22, 2021

### cherrymui commented Sep 22, 2021

 Thanks.

### gopherbot commented Nov 4, 2021

 Change https://golang.org/cl/361374 mentions this issue: `crypto: fix wrong formulas in comments`