diff --git a/README b/README new file mode 100644 index 0000000..0a1103a --- /dev/null +++ b/README @@ -0,0 +1,11 @@ +This is foremost an implementation of the curve Ed25519 that satisfies Go's +elliptic.Curve interface. It targets amd64 systems, and is eventually intended +to be a legible general-purpose library along the lines of curve25519-dalek. + +It is also an implementation of GF(2^255-19) field operations in a 64-bit +representation, in both pure Go and plan9 assembly for amd64. This code is +currently package-internal. + +The library is a WORK IN PROGRESS. Everything will change dramatically as +development continues. There are no guarantees of stability, functionality, +correctness, or safety. We aren't open yet, come back later! diff --git a/ed25519.go b/ed25519.go index 0b06b4c..52bc9cc 100644 --- a/ed25519.go +++ b/ed25519.go @@ -94,7 +94,7 @@ func (curve ed25519Curve) Double(x1, y1 *big.Int) (x, y *big.Int) { // ScalarMult returns k*(Bx,By) where k is a number in big-endian form. func (curve ed25519Curve) ScalarMult(x1, y1 *big.Int, k []byte) (x, y *big.Int) { - // if either coordinate is nil, return the point at infinity + // if either coordinate is nil, return the identity point if x1 == nil || y1 == nil { x = new(big.Int).Set(bigZero) y = new(big.Int).Set(bigOne) @@ -144,13 +144,10 @@ func (curve ed25519Curve) scalarFromBytes(out *[32]byte, in []byte) { } } -// // ScalarBaseMult returns k*G, where G is the base point of the group and k is -// // an integer in big-endian form. -// func (curve ed25519Curve) ScalarBaseMult(k []byte) (x, y *big.Int) { -// var p edwards25519.ExtendedGroupElement -// var scBytes [32]byte - -// curve.scalarFromBytes(&scBytes, k) -// edwards25519.GeScalarMultBase(&p, &scBytes) -// return extendedToAffine(&p) -// } +// ScalarBaseMult returns k*G, where G is the base point of the curve and k is +// an integer in big-endian form. The difference between this and +// arbitrary-point ScalarMult is the availability of precomputed multiples of +// the base point. +func (curve ed25519Curve) ScalarBaseMult(k []byte) (x, y *big.Int) { + panic("not yet implemented") +} diff --git a/ed25519_test.go b/ed25519_test.go index 3808847..c8a28b3 100644 --- a/ed25519_test.go +++ b/ed25519_test.go @@ -369,24 +369,7 @@ func BenchmarkScalarMult(b *testing.B) { // } // } -// // BENCHMARKS - -// func BenchmarkScalarBaseMult(b *testing.B) { -// ed := Ed25519() - -// var k [32]byte -// _, err := io.ReadFull(rand.Reader, k[:]) -// if err != nil { -// b.Fatal(err) -// } -// k[0] &= 248 -// k[31] &= 127 -// k[31] |= 64 - -// for i := 0; i < b.N; i++ { -// _, _ = ed.ScalarBaseMult(k[:]) -// } -// } +// COMPARATIVE FIELD BENCHMARKS var radix51A = field.FieldElement{ 486662, 0, 0, 0, 0, @@ -418,7 +401,6 @@ func BenchmarkFeFromBig(b *testing.B) { var feOnes field.FieldElement = [5]uint64{1, 1, 1, 1, 1} -//func FeToBig(h *FieldElement) *big.Int { func BenchmarkFeToBig(b *testing.B) { for i := 0; i < b.N; i++ { _ = field.FeToBig(&feOnes) diff --git a/internal/radix51/const.go b/internal/radix51/const.go index 51b6190..b650ff8 100644 --- a/internal/radix51/const.go +++ b/internal/radix51/const.go @@ -1,4 +1,6 @@ -// Copyright 2017 George Tankersley. All rights reserved. +// Copyright (c) 2017 George Tankersley. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. // Constants used in the implementation of GF(2^255-19) field arithmetic. package radix51 diff --git a/internal/radix51/fe.go b/internal/radix51/fe.go index d78922f..66a7093 100644 --- a/internal/radix51/fe.go +++ b/internal/radix51/fe.go @@ -1,4 +1,6 @@ -// Copyright 2017 George Tankersley. All rights reserved. +// Copyright (c) 2017 George Tankersley. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. // Field arithmetic in radix 2^51 representation. This code is a port of the // public domain amd64-51-30k version of ed25519 from SUPERCOP. diff --git a/internal/radix51/fe_mul.go b/internal/radix51/fe_mul.go index 68b6849..edc7bd2 100644 --- a/internal/radix51/fe_mul.go +++ b/internal/radix51/fe_mul.go @@ -1,3 +1,7 @@ +// Copyright (c) 2017 George Tankersley. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + // +build !amd64 noasm package radix51 diff --git a/internal/radix51/fe_mul_amd64.go b/internal/radix51/fe_mul_amd64.go index c76b4db..b0d38be 100644 --- a/internal/radix51/fe_mul_amd64.go +++ b/internal/radix51/fe_mul_amd64.go @@ -1,3 +1,7 @@ +// Copyright (c) 2017 George Tankersley. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + // +build amd64,!noasm package radix51 diff --git a/internal/radix51/fe_mul_amd64.s b/internal/radix51/fe_mul_amd64.s index 07ebb0c..e246262 100644 --- a/internal/radix51/fe_mul_amd64.s +++ b/internal/radix51/fe_mul_amd64.s @@ -1,3 +1,7 @@ +// Copyright (c) 2017 George Tankersley. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + // Based on assembly generated by PeachPy. Equivalent to the Go in fe_mul.go, // which was originally based on the amd64-51-30k assembly in SUPERCOP. diff --git a/internal/radix51/fe_square.go b/internal/radix51/fe_square.go index fa738eb..ec5bd62 100644 --- a/internal/radix51/fe_square.go +++ b/internal/radix51/fe_square.go @@ -1,3 +1,7 @@ +// Copyright (c) 2017 George Tankersley. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + // +build !amd64 noasm package radix51 diff --git a/internal/radix51/fe_square_amd64.go b/internal/radix51/fe_square_amd64.go index c089146..8c38356 100644 --- a/internal/radix51/fe_square_amd64.go +++ b/internal/radix51/fe_square_amd64.go @@ -1,3 +1,7 @@ +// Copyright (c) 2017 George Tankersley. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + // +build amd64,!noasm package radix51 diff --git a/internal/radix51/fe_square_amd64.s b/internal/radix51/fe_square_amd64.s index f9af5c8..fa01331 100644 --- a/internal/radix51/fe_square_amd64.s +++ b/internal/radix51/fe_square_amd64.s @@ -1,3 +1,7 @@ +// Copyright (c) 2017 George Tankersley. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + // +build amd64,!noasm // func FeSquare(outp *uint64, xp *uint64) diff --git a/internal/radix51/fe_test.go b/internal/radix51/fe_test.go index 15a5a06..3450871 100644 --- a/internal/radix51/fe_test.go +++ b/internal/radix51/fe_test.go @@ -1,3 +1,7 @@ +// Copyright (c) 2017 George Tankersley. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package radix51 import ( diff --git a/internal/radix51/mul.go b/internal/radix51/mul.go index dbea36c..c196d9d 100644 --- a/internal/radix51/mul.go +++ b/internal/radix51/mul.go @@ -1,3 +1,7 @@ +// Copyright (c) 2017 George Tankersley. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package radix51 import "unsafe"