0x4a52466c696e74 2 gadi atpakaļ
vecāks
revīzija
c23c980164
7 mainītis faili ar 54 papildinājumiem un 10 dzēšanām
  1. 4 0
      curve.go
  2. 7 0
      dhellman/dhellman.go
  3. 9 0
      dhellman/key_pair.go
  4. 12 0
      dhellman/key_private.go
  5. 7 0
      dhellman/key_public.go
  6. 1 0
      dhellman/z_test.go
  7. 14 10
      tools/curve.go

+ 4 - 0
curve.go

@@ -0,0 +1,4 @@
+package curve
+
+type Curve interface {
+}

+ 7 - 0
dhellman/dhellman.go

@@ -0,0 +1,7 @@
+package dhellman
+
+import "git.ali33.ru/fcg-xvii/curve/v2"
+
+func constructor(curve curve.Curve) (curve.KeyPair, error) {
+	return nil, nil
+}

+ 9 - 0
dhellman/key_pair.go

@@ -0,0 +1,9 @@
+package dhellman
+
+import "git.ali33.ru/fcg-xvii/curve/v2/tools"
+
+type keyPair struct {
+	private *keyPrivate
+	public  *keyPublic
+	curve   *tools.Curve
+}

+ 12 - 0
dhellman/key_private.go

@@ -0,0 +1,12 @@
+package dhellman
+
+import (
+	"math/big"
+
+	"git.ali33.ru/fcg-xvii/curve/v2/tools"
+)
+
+type keyPrivate struct {
+	curve *tools.Curve
+	x     *big.Int
+}

+ 7 - 0
dhellman/key_public.go

@@ -0,0 +1,7 @@
+package dhellman
+
+import "git.ali33.ru/fcg-xvii/curve/v2/tools"
+
+type keyPublic struct {
+	p *tools.Point
+}

+ 1 - 0
dhellman/z_test.go

@@ -0,0 +1 @@
+package dhellman

+ 14 - 10
tools/curve.go

@@ -112,16 +112,6 @@ func (s *Curve) SetP(p *big.Int) (err error) {
 		return
 	}
 	s.p = p
-	/*if !IsPrime(Div(Sub(p, 1), 2)) {
-
-	}*/
-	/*
-		if p.Cmp(MinP) < 0 {
-			err = fmt.Errorf("слишком маленький размер конечного поля [ %s ]", p)
-			return
-		}
-	*/
-	//s.p = new(big.Int).Set(p)
 	// сброс подгруппы
 	s.n = nil
 	s.h = nil
@@ -166,6 +156,13 @@ func (s *Curve) InverseMod(k, p *big.Int) (res *big.Int, err error) {
 	return
 }
 
+func (s *Curve) Points(dx *big.Int) (p1, p2 *Point, err error) {
+	if err = s.IsValidN(); err != nil {
+		return
+	}
+	return s.points(x)
+}
+
 // Определение координат пары зеркальных точек по x
 func (s *Curve) points(dx *big.Int) (p1, p2 *Point, err error) {
 	dxx := intCopy(dx)
@@ -204,6 +201,13 @@ func (s *Curve) points(dx *big.Int) (p1, p2 *Point, err error) {
 	return
 }
 
+func (s *Curve) SearchClosePoints(x *big.Int) (p1, p2 *Point, err error) {
+	if err = s.IsValidN(); err != nil {
+		return
+	}
+	return s.searhClosePoints(x)
+}
+
 func (s *Curve) searhClosePoints(x *big.Int) (p1, p2 *Point, err error) {
 	cx := intCopy(x)
 	if x.Cmp(s.p) >= 0 {