<commit_before>// Copyright 2019 <NAME>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package edwards25519

import (
	"testing"

	"github.com/gtank/ristretto255/internal/radix51"
)

var (
	// The Ed25519 basepoint.
	B = ProjP3{
		X: radix51.FieldElement([5]uint64{1738742601995546, 1146398526822698, 2070867633025821, 562264141797630, 587772402128613}),
		Y: radix51.FieldElement([5]uint64{1801439850948184, 1351079888211148, 450359962737049, 900719925474099, 1801439850948198}),
		Z: radix51.FieldElement([5]uint64{1, 0, 0, 0, 0}),
		T: radix51.FieldElement([5]uint64{1841354044333475, 16398895984059, 755974180946558, 900171276175154, 1821297809914039}),
	}
)

func TestAddSubNegOnBasePoint(t *testing.T) {
	var B, Bneg ProjP3
	var tmpP2 ProjP2
	var tmpP1xP1 ProjP1xP1
	var tmpCached ProjCached

	Bneg.Neg(&B)

	var checkLhs, checkRhs, zero ProjP3
	zero.Zero()

	tmpCached.FromP3(&B)
	tmpP1xP1.Add(&B, &tmpCached)
	checkLhs.FromP1xP1(&tmpP1xP1)
	tmpP2.FromP3(&B)
	tmpP1xP1.Double(&tmpP2)
	checkRhs.FromP1xP1(&tmpP1xP1)
	if checkLhs.Equal(&checkRhs) != 1 {
		t.Error("B + B != [2]B")
	}

	tmpCached.FromP3(&B)
	tmpP1xP1.Sub(&B, &tmpCached)
	checkLhs.FromP1xP1(&tmpP1xP1)<commit_msg>internal/edwards25519: fix shadowing of B in TestAddSubNegOnBasePoint<commit_after>// Copyright 2019 <NAME>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package edwards25519

import (
	"testing"

	"github.com/gtank/ristretto255/internal/radix51"
)

var (
	// The Ed25519 basepoint.
	B = ProjP3{
		X: radix51.FieldElement([5]uint64{1738742601995546, 1146398526822698, 2070867633025821, 562264141797630, 587772402128613}),
		Y: radix51.FieldElement([5]uint64{1801439850948184, 1351079888211148, 450359962737049, 900719925474099, 1801439850948198}),
		Z: radix51.FieldElement([5]uint64{1, 0, 0, 0, 0}),
		T: radix51.FieldElement([5]uint64{1841354044333475, 16398895984059, 755974180946558, 900171276175154, 1821297809914039}),
	}
)

func TestAddSubNegOnBasePoint(t *testing.T) {
	var Bneg ProjP3
	var tmpP2 ProjP2
	var tmpP1xP1 ProjP1xP1
	var tmpCached ProjCached

	Bneg.Neg(&B)

	var checkLhs, checkRhs, zero ProjP3
	zero.Zero()

	tmpCached.FromP3(&B)
	tmpP1xP1.Add(&B, &tmpCached)
	checkLhs.FromP1xP1(&tmpP1xP1)
	tmpP2.FromP3(&B)
	tmpP1xP1.Double(&tmpP2)
	checkRhs.FromP1xP1(&tmpP1xP1)
	if checkLhs.Equal(&checkRhs) != 1 {
		t.Error("B + B != [2]B")
	}

	tmpCached.FromP3(&B)
	tmpP1xP1.Sub(&B, &tmpCached)
	checkLhs.FromP1xP1(&tmpP1xP1)
{'fraction_non_alphanumeric': 0.12359550561797752, 'fraction_numerical': 0.2421542037969779, 'mean_word_length': 5.569974554707379, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2261560', 'n_tokens_mistral': 1535, 'n_tokens_neox': 1172, 'n_words': 206}