The twisted Edwards curve takes the form of \(a x^2 + y^2 = 1 + d x^2 y^2\). For Ed25519 it has a finite field defined by \(p=2^{255}-19\), \(d=370957059346694393431380835087545651895421138798432190163887855330 85940283555\) and the base point is at \(x=5866666666666666666666666666666666666666666666666666666666666666\). In this case we will provide the points at \(G, 2G, 3G\) and using scalar methods and point addition [article]:
Barebones Ed25519: Adding and Scalar Multiply on the Edwards curveTheoryThe twisted Edwards curve takes the form of: \(a x^2 + y^2 = 1 + d x^2 y^2\) For Ed25519 it has a finite field defined by \(p=2^{255}-19\), \(a=-1\), \(d=370957059346694393431380835087545651895421138798432190163887855330 85940283555\) and the base point is at \(x=5866666666666666666666666666666666666666666666666666666666666666\). The simplest operations we have is to take a base point (\(G\)) and then perform point addition and where \(2G\) is equal to \(G+G\) and where we get a new point on the elliptic curve. For \(3G\) we can have \(G+2G\), and so on. We can also perform a scalar multiplication, such as taking a scalar of \(3\) and finding \(3G\). In the following code we have three scalar values of 1, 2 and 3, and then use point addition and scalar multiplication to find \(2G\) and \(3G\), and where we should get the same values as \(G+G\) and \(G+2G\), respectively. Note, in Curve 25519, we normally just define the x co-ordinate of a point on the curve. suite := suites.MustFind("Ed25519") one := suite.Scalar().SetInt64(1) two := suite.Scalar().SetInt64(2) three := suite.Scalar().SetInt64(3) G:=suite.Point().Base() G_1 := suite.Point().Mul(one,G) G_2 := suite.Point().Mul(two,G) G_3 := suite.Point().Mul(three,G) G_T1 := suite.Point().Add(G_1,G_1) G_T2 := suite.Point().Add(G_1,G_2) A sample run shows that \(2G\) is equal to \(G+G\), and \(3G\) is equal to \(G+2G\): Curve: Ed25519 Point G 5866666666666666666666666666666666666666666666666666666666666666 Point 1G 5866666666666666666666666666666666666666666666666666666666666666 Point 2G c9a3f86aae465f0e56513864510f3997561fa2c9e85ea21dc2292309f3cd6022 Point 3G d4b4f5784868c3020403246717ec169ff79e26608ea126a1ab69ee77d1b16712 Point G+G c9a3f86aae465f0e56513864510f3997561fa2c9e85ea21dc2292309f3cd6022 Point G+2G d4b4f5784868c3020403246717ec169ff79e26608ea126a1ab69ee77d1b16712 Basically the addition becomes: \((x_{1},y_{1})+(x_{2},y_{2})=\left({\frac {x_{1}y_{2}+y_{1}x_{2}}{1+dx_{1}x_{2}y_{1}y_{2}}},{\frac {y_{1}y_{2}-ax_{1}x_{2}}{1-dx_{1}x_{2}y_{1}y_{2}}}\right)\) CodeAn outline of the code is: package main import ( "fmt" "go.dedis.ch/kyber/v3/suites" "os" "strconv" ) func main() { val:=3 argCount := len(os.Args[1:]) if (argCount>0) { val,_= strconv.Atoi(os.Args[1]) } suite := suites.MustFind("Ed25519") one := suite.Scalar().SetInt64(1) two := suite.Scalar().SetInt64(2) three := suite.Scalar().SetInt64(3) value := suite.Scalar().SetInt64(int64(val)) G:=suite.Point().Base() n := suite.Scalar().Pick(suite.RandomStream()) G_1 := suite.Point().Mul(one,G) G_2 := suite.Point().Mul(two,G) G_3 := suite.Point().Mul(three,G) G_val := suite.Point().Mul(value,G) G_n := suite.Point().Mul(n,G) G_T1 := suite.Point().Add(G_1,G_1) G_T2 := suite.Point().Add(G_1,G_2) G_T3 := suite.Point().Sub(G_T2,G_2) fmt.Printf("Curve: %s\n",suite.String()) fmt.Printf("Point G %s\n",G.String()) fmt.Printf("Point 1G %s\n",G_1.String()) fmt.Printf("Point 2G %s\n",G_2.String()) fmt.Printf("Point 3G %s\n",G_3.String()) fmt.Printf("\nPoint G+G %s\n",G_T1.String()) fmt.Printf("Point G+2G %s\n",G_T2.String()) fmt.Printf("Point 2G-G %s\n",G_T3.String()) fmt.Printf("\nValue %s\n",value.String()) fmt.Printf("Point vG %s\n",G_val.String()) fmt.Printf("\nRandom scale (n) %s\n",n.String()) fmt.Printf("Point nG %s\n",G_n.String()) } A sample run gives for a user entered value of 4 is: Curve: Ed25519 Point G 5866666666666666666666666666666666666666666666666666666666666666 Point 1G 5866666666666666666666666666666666666666666666666666666666666666 Point 2G c9a3f86aae465f0e56513864510f3997561fa2c9e85ea21dc2292309f3cd6022 Point 3G d4b4f5784868c3020403246717ec169ff79e26608ea126a1ab69ee77d1b16712 Point G+G c9a3f86aae465f0e56513864510f3997561fa2c9e85ea21dc2292309f3cd6022 Point G+2G d4b4f5784868c3020403246717ec169ff79e26608ea126a1ab69ee77d1b16712 Point 2G-G 5866666666666666666666666666666666666666666666666666666666666666 Value 0300000000000000000000000000000000000000000000000000000000000000 Point vG d4b4f5784868c3020403246717ec169ff79e26608ea126a1ab69ee77d1b16712 Random scale (n) 771db1b66acfdfc2ed6a8df59ec59b885457433b50199d087640858df9bb5206 Point nG 0477a521d7336c6fff5cd9de1d8b7f176bc0573a2353abb2398c5b1631240213 |