Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove A as A=-1 for all twistedEdwards #88

Merged
merged 1 commit into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ecc/bls12-377/twistededwards/point.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions ecc/bls12-377/twistededwards/twistededwards.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"github.com/consensys/gnark-crypto/ecc/bls12-377/fr"
)

// CurveParams curve parameters: ax^2 + y^2 = 1 + d*x^2*y^2
// CurveParams curve parameters: -x^2 + y^2 = 1 + d*x^2*y^2
type CurveParams struct {
A, D fr.Element // in Montgomery form
D fr.Element // in Montgomery form
Cofactor fr.Element // not in Montgomery form
Order big.Int
Base PointAffine
Expand All @@ -22,7 +22,6 @@ func GetEdwardsCurve() CurveParams {
// copy to keep Order private
var res CurveParams

res.A.Set(&edwards.A)
res.D.Set(&edwards.D)
res.Cofactor.Set(&edwards.Cofactor)
res.Order.Set(&edwards.Order)
Expand All @@ -33,7 +32,6 @@ func GetEdwardsCurve() CurveParams {

func init() {

edwards.A.SetOne().Neg(&edwards.A)
edwards.D.SetUint64(3021)
edwards.Cofactor.SetUint64(4).FromMont()
edwards.Order.SetString("2111115437357092606062206234695386632838870926408408195193685246394721360383", 10)
Expand Down
2 changes: 1 addition & 1 deletion ecc/bls12-381/twistededwards/point.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions ecc/bls12-381/twistededwards/twistededwards.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import (
"github.com/consensys/gnark-crypto/ecc/bls12-381/fr"
)

// CurveParams curve parameters: ax^2 + y^2 = 1 + d*x^2*y^2
// CurveParams curve parameters: -x^2 + y^2 = 1 + d*x^2*y^2
type CurveParams struct {
A, D fr.Element // in Montgomery form
D fr.Element // in Montgomery form
Cofactor fr.Element // not in Montgomery form
Order big.Int
Base PointAffine
Expand All @@ -38,7 +38,6 @@ func GetEdwardsCurve() CurveParams {
// copy to keep Order private
var res CurveParams

res.A.Set(&edwards.A)
res.D.Set(&edwards.D)
res.Cofactor.Set(&edwards.Cofactor)
res.Order.Set(&edwards.Order)
Expand All @@ -49,7 +48,6 @@ func GetEdwardsCurve() CurveParams {

func init() {

edwards.A.SetOne().Neg(&edwards.A)
edwards.D.SetString("19257038036680949359750312669786877991949435402254120286184196891950884077233") // -(10240/10241)
edwards.Cofactor.SetUint64(8).FromMont()
edwards.Order.SetString("6554484396890773809930967563523245729705921265872317281365359162392183254199", 10)
Expand Down
2 changes: 1 addition & 1 deletion ecc/bls24-315/twistededwards/point.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions ecc/bls24-315/twistededwards/twistededwards.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"github.com/consensys/gnark-crypto/ecc/bls24-315/fr"
)

// CurveParams curve parameters: ax^2 + y^2 = 1 + d*x^2*y^2
// CurveParams curve parameters: -x^2 + y^2 = 1 + d*x^2*y^2
type CurveParams struct {
A, D fr.Element // in Montgomery form
D fr.Element // in Montgomery form
Cofactor fr.Element // not in Montgomery form
Order big.Int
Base PointAffine
Expand All @@ -22,7 +22,6 @@ func GetEdwardsCurve() CurveParams {
// copy to keep Order private
var res CurveParams

res.A.Set(&edwards.A)
res.D.Set(&edwards.D)
res.Cofactor.Set(&edwards.Cofactor)
res.Order.Set(&edwards.Order)
Expand All @@ -33,7 +32,6 @@ func GetEdwardsCurve() CurveParams {

func init() {

edwards.A.SetOne().Neg(&edwards.A)
edwards.D.SetString("8771873785799030510227956919069912715983412030268481769609515223557738569779")
edwards.Cofactor.SetUint64(8).FromMont()
edwards.Order.SetString("1437753473921907580703509300571927811987591765799164617677716990775193563777", 10)
Expand Down
2 changes: 1 addition & 1 deletion ecc/bn254/twistededwards/point.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions ecc/bn254/twistededwards/twistededwards.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"github.com/consensys/gnark-crypto/ecc/bn254/fr"
)

// CurveParams curve parameters: ax^2 + y^2 = 1 + d*x^2*y^2
// CurveParams curve parameters: -x^2 + y^2 = 1 + d*x^2*y^2
type CurveParams struct {
A, D fr.Element // in Montgomery form
D fr.Element // in Montgomery form
Cofactor fr.Element // not in Montgomery form
Order big.Int
Base PointAffine
Expand All @@ -21,7 +21,6 @@ func GetEdwardsCurve() CurveParams {
// copy to keep Order private
var res CurveParams

res.A.Set(&edwards.A)
res.D.Set(&edwards.D)
res.Cofactor.Set(&edwards.Cofactor)
res.Order.Set(&edwards.Order)
Expand All @@ -32,7 +31,6 @@ func GetEdwardsCurve() CurveParams {

func init() {

edwards.A.SetOne().Neg(&edwards.A)
edwards.D.SetString("12181644023421730124874158521699555681764249180949974110617291017600649128846")
edwards.Cofactor.SetUint64(8).FromMont()
edwards.Order.SetString("2736030358979909402780800718157159386076813972158567259200215660948447373041", 10)
Expand Down
2 changes: 1 addition & 1 deletion ecc/bw6-633/twistededwards/point.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions ecc/bw6-633/twistededwards/twistededwards.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"github.com/consensys/gnark-crypto/ecc/bw6-633/fr"
)

// CurveParams curve parameters: ax^2 + y^2 = 1 + d*x^2*y^2
// CurveParams curve parameters: -x^2 + y^2 = 1 + d*x^2*y^2
type CurveParams struct {
A, D fr.Element // in Montgomery form
D fr.Element // in Montgomery form
Cofactor fr.Element // not in Montgomery form
Order big.Int
Base PointAffine
Expand All @@ -21,7 +21,6 @@ func GetEdwardsCurve() CurveParams {
// copy to keep Order private
var res CurveParams

res.A.Set(&edwards.A)
res.D.Set(&edwards.D)
res.Cofactor.Set(&edwards.Cofactor)
res.Order.Set(&edwards.Order)
Expand All @@ -32,7 +31,6 @@ func GetEdwardsCurve() CurveParams {

func init() {

edwards.A.SetOne().Neg(&edwards.A)
edwards.D.SetString("37248940285811842784899494310834635440994424264352085037441815381151934266434102922992043546621")
edwards.Cofactor.SetUint64(8).FromMont()
edwards.Order.SetString("4963142838689179791878211236301121218116687802119716497817028544854034649070444389864454748079", 10)
Expand Down
2 changes: 1 addition & 1 deletion ecc/bw6-761/twistededwards/point.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions ecc/bw6-761/twistededwards/twistededwards.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"github.com/consensys/gnark-crypto/ecc/bw6-761/fr"
)

// CurveParams curve parameters: ax^2 + y^2 = 1 + d*x^2*y^2
// CurveParams curve parameters: -x^2 + y^2 = 1 + d*x^2*y^2
type CurveParams struct {
A, D fr.Element // in Montgomery form
D fr.Element // in Montgomery form
Cofactor fr.Element // not in Montgomery form
Order big.Int
Base PointAffine
Expand All @@ -21,7 +21,6 @@ func GetEdwardsCurve() CurveParams {
// copy to keep Order private
var res CurveParams

res.A.Set(&edwards.A)
res.D.Set(&edwards.D)
res.Cofactor.Set(&edwards.Cofactor)
res.Order.Set(&edwards.Order)
Expand All @@ -32,7 +31,6 @@ func GetEdwardsCurve() CurveParams {

func init() {

edwards.A.SetOne().Neg(&edwards.A)
edwards.D.SetUint64(79743)
edwards.Cofactor.SetUint64(8).FromMont()
edwards.Order.SetString("32333053251621136751331591711861691692049189094364332567435817881934511297123972799646723302813083835942624121493", 10)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func computeX(y *fr.Element) (x fr.Element) {
num.Square(y)
den.Mul(&num, &edwards.D)
num.Sub(&one, &num)
den.Sub(&edwards.A, &den)
den.Add(&one, &den).Neg(&den)
x.Div(&num, &den)
x.Sqrt(&x)
return
Expand Down