<commit_before>package doubleratchet

import (
	"github.com/stretchr/testify/require"
	"testing"
)

func TestDhPair(t *testing.T) {
	// Arrange.
	p := dhPair{
		privateKey: [32]byte{5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
		publicKey:  [32]byte{6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6},
	}

	// Act.
	var (
		privKey = p.PrivateKey()
		pubKey  = p.PublicKey()
	)

	// Assert.
	require.Equal(t, p.privateKey, privKey)
	require.Equal(t, p.publicKey, pubKey)
}

func TestDefaultCrypto_GenerateDH_Basic(t *testing.T) {
	// Arrange.
	c := DefaultCrypto{}

	// Act.
	pair, err := c.GenerateDH()

	// Assert.
	require.Nil(t, err)

	require.EqualValues(t, 0, pair.PrivateKey()[0]&7)
	require.EqualValues(t, 0, pair.PrivateKey()[31]&128)
	require.EqualValues(t, 64, pair.PrivateKey()[31]&64)

	require.NotEqual(t, [32]byte{}, pair.PrivateKey())
	require.NotEqual(t, [32]byte{}, pair.PublicKey())
	require.Len(t, pair.PrivateKey(), 32)
	require.Len(t, pair.PublicKey(), 32)
	require.NotEqual(t, pair.PublicKey(), pair.PrivateKey())
}<commit_msg>dhPair.String() test<commit_after>package doubleratchet

import (
	"fmt"
	"github.com/stretchr/testify/require"
	"testing"
)

func TestDhPair(t *testing.T) {
	// Arrange.
	p := dhPair{
		privateKey: [32]byte{5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
		publicKey:  [32]byte{6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6},
	}

	// Act.
	var (
		privKey = p.PrivateKey()
		pubKey  = p.PublicKey()
	)

	// Assert.
	require.Equal(t, p.privateKey, privKey)
	require.Equal(t, p.publicKey, pubKey)
	require.Equal(t, fmt.Sprintf(`{privateKey: %s publicKey: %s}`, p.PrivateKey(), p.PublicKey()), p.String())
}

func TestDefaultCrypto_GenerateDH_Basic(t *testing.T) {
	// Arrange.
	c := DefaultCrypto{}

	// Act.
	pair, err := c.GenerateDH()

	// Assert.
	require.Nil(t, err)

	require.EqualValues(t, 0, pair.PrivateKey()[0]&7)
	require.EqualValues(t, 0, pair.PrivateKey()[31]&128)
	require.EqualValues(t, 64, pair.PrivateKey()[31]&64)

	require.NotEqual(t, [32]byte{}, pair.PrivateKey())
	require.NotEqual(t, [32]byte{}, pair.PublicKey())
	require.Len(t, pair.PrivateKey(), 32)
	require.Len(t, pair.PublicKey(), 32)
	require.NotEqual(t, pair.PublicKey(), pair.PrivateKey())
}
{'fraction_non_alphanumeric': 0.21274834437086093, 'fraction_numerical': 0.07533112582781457, 'mean_word_length': 3.86317907444668, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2329522', 'n_tokens_mistral': 1250, 'n_tokens_neox': 1066, 'n_words': 264}