~moody/libdp9ik

libdp9ik/spake2ee_test.go -rw-r--r-- 1.5 KiB
4efa26b9 — Jacob Moody Progress made towards authpak_new and authpak_finish 9 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package libdp9ik_test

import (
	"fmt"
	"math/big"
	"testing"

	auth "git.sr.ht/~moody/libdp9ik"
)

func TestSpake2ee_h2P(t *testing.T) {
	p := big.NewInt(0)
	a := big.NewInt(0)
	d := big.NewInt(0)
	h := big.NewInt(0)

	PX := big.NewInt(0)
	PY := big.NewInt(0)
	PZ := big.NewInt(0)
	PT := big.NewInt(0)

	p.SetString("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 16)
	a.SetString("1", 16)
	d.SetInt64(-39081)
	h.SetString("9FFAA7A0174BF9330A7397D878457FB83BA403AD2E0F86C968EFE5B96513783B1A848B416509DA6C9777AACF83C433044FD27766E7376AF4", 16)
	auth.Spake2ee_h2P(p, a, d, h, PX, PY, PZ, PT)
	px := fmt.Sprintf("%X", PX)
	py := fmt.Sprintf("%X", PY)
	pz := fmt.Sprintf("%X", PZ)
	pt := fmt.Sprintf("%X", PT)

	const (
		cpx = "9E14182914BFB6AE5D4DCB15684B519366CC11238EED52CA493B3B3093C5CEBFA42607F3840F421AA8B5D8C53F8E3800057FB32AFCEC9AC2"
		cpy = "FDA9A16F10FE74BF3FA716F148382BB4E262C38E894A9872E7F0329AE34EAFB60CBD356D498319F7B70FA1A128C094C22D7F6265639FBC18"
		cpz = "6A726A835765C8435827C3427BD8A727454E3D721A70FA68363C07CD124A3D48CB53A1B0D3E40EE8575A6E6E0AABCDB9CF2E69C5F2B12777"
		cpt = "16C4FC221A0A6254A6FF98DFECEAAAE22AF75C0F6F706C9C43D1FB66D7C377809733EAD5097060266DC03B37D180D15C3FC51BEBA3B6B380"
	)

	if px != cpx {
		t.Fatalf("Px: Expected %s\nGot %s", cpx, px)
	}

	if py != cpy {
		t.Fatalf("Py: Expected %s\nGot %s", cpy, py)
	}

	if pz != cpz {
		t.Fatalf("Pz: Expected %s\nGot %s", cpz, pz)
	}

	if pt != cpt {
		t.Fatalf("Pt: Expected %s\nGot %s", cpt, pt)
	}
}