Debian Codegraph @

edwards25519/constants_test.go

raw symbols SCIP
1 package edwards25519
2
3 import (
4 "testing"
5 )
6
7 func TestFeConstants(t *testing.T) {
8 var dP1, dP1InvDM1 FieldElement
9 dP1.add(&feD, &feOne)
10 dP1InvDM1.sub(&feD, &feOne)
11 dP1InvDM1.Inverse(&dP1InvDM1)
12 dP1InvDM1.Mul(&dP1InvDM1, &dP1)
13 if dP1InvDM1.EqualsI(&feDp1OverDm1) != 1 {
14 t.Fatalf("feDp1OverDm1: %v != %v", &feDp1OverDm1, &dP1InvDM1)
15 }
16
17 var sqrtID FieldElement
18 sqrtID.Mul(&feI, &feD)
19 sqrtID.Sqrt(&sqrtID)
20 if sqrtID.EqualsI(&feSqrtID) != 1 {
21 t.Fatalf("sqrtID: %v != %v", &feSqrtID, &sqrtID)
22 }
23
24 var doubleInvSqrtMinusDMinusOne FieldElement
25 doubleInvSqrtMinusDMinusOne.Add(&feInvSqrtMinusDMinusOne, &feInvSqrtMinusDMinusOne)
26 if doubleInvSqrtMinusDMinusOne.EqualsI(&feDoubleInvSqrtMinusDMinusOne) != 1 {
27 t.Fatalf("doubleInvSqrtMinusDMinusOne: %v != %v",
28 feDoubleInvSqrtMinusDMinusOne, doubleInvSqrtMinusDMinusOne)
29 }
30
31 var doubleIInvSqrtMinusDMinusOne FieldElement
32 doubleIInvSqrtMinusDMinusOne.Mul(&feDoubleInvSqrtMinusDMinusOne, &feI)
33 if doubleIInvSqrtMinusDMinusOne.EqualsI(&feDoubleIInvSqrtMinusDMinusOne) != 1 {
34 t.Fatalf("doubleIInvSqrtMinusDMinusOne: %v != %v",
35 feDoubleIInvSqrtMinusDMinusOne, doubleIInvSqrtMinusDMinusOne)
36 }
37
38 var invSqrt1pD FieldElement
39 invSqrt1pD.add(&feD, &feOne)
40 invSqrt1pD.InvSqrt(&invSqrt1pD)
41 if invSqrt1pD.EqualsI(&feInvSqrt1pD) != 1 {
42 t.Fatalf("invSqrt1pD: %v != %v", feInvSqrt1pD, invSqrt1pD)
43 }
44 }