Skip to content

Commit

Permalink
style: clean comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yelhousni committed Sep 21, 2024
1 parent 6f69c7e commit 9b31869
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ecc/eisenstein.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ func (z *ComplexNumber) Set(x *ComplexNumber) *ComplexNumber {
return z
}

// Set sets z to 0, and returns z.
// SetZero sets z to 0, and returns z.
func (z *ComplexNumber) SetZero() *ComplexNumber {
z.A0 = *big.NewInt(0)
z.A1 = *big.NewInt(0)
return z
}

// Set sets z to 1, and returns z.
// SetOne sets z to 1, and returns z.
func (z *ComplexNumber) SetOne() *ComplexNumber {
z.A0 = *big.NewInt(1)
z.A1 = *big.NewInt(0)
Expand Down Expand Up @@ -121,8 +121,8 @@ func (z *ComplexNumber) Quo(x, y *ComplexNumber) *ComplexNumber {
return z
}

// HalfGCD returns the rational reconstruction of l mod r.
// This outputs u, v s.t. l = u/v mod r
// HalfGCD returns the rational reconstruction of a, b.
// This outputs w, v, u s.t. w = a*u + b*v.
func HalfGCD(a, b *ComplexNumber) [3]*ComplexNumber {

var aRun, bRun, u, v, u_, v_, quotient, remainder, t, t1, t2 ComplexNumber
Expand Down
15 changes: 15 additions & 0 deletions ecc/eisenstein_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,18 @@ func GenComplexNumber() gopter.Gen {
return &ComplexNumber{A0: values[0].(big.Int), A1: values[1].(big.Int)}
})
}

// bench
func BenchmarkHalfGCD(b *testing.B) {
var prime, _ = new(big.Int).SetString("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed", 16) // 2^255 - 19
a0, _ := rand.Int(rand.Reader, prime)
a1, _ := rand.Int(rand.Reader, prime)
c0, _ := rand.Int(rand.Reader, prime)
c1, _ := rand.Int(rand.Reader, prime)
a := ComplexNumber{A0: *a0, A1: *a1}
c := ComplexNumber{A0: *c0, A1: *c1}
b.ResetTimer()
for i := 0; i < b.N; i++ {
HalfGCD(&a, &c)
}
}

0 comments on commit 9b31869

Please sign in to comment.