Skip to content
This repository has been archived by the owner on May 22, 2023. It is now read-only.

Commit

Permalink
Remove obsolete test code
Browse files Browse the repository at this point in the history
  • Loading branch information
fasmat committed Mar 30, 2023
1 parent 9f15b71 commit bb2e612
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 37 deletions.
1 change: 0 additions & 1 deletion ed25519.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"bytes"
"crypto/ed25519"
"crypto/sha512"
"encoding/binary"
"errors"
"io"
"strconv"
Expand Down
25 changes: 0 additions & 25 deletions ed25519_fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,28 +60,3 @@ func Fuzz_Sign(f *testing.F) {
require.EqualValues(t, key.Public(), pub)
})
}

func Fuzz_Derive(f *testing.F) {
py, err := pure25519.New()
if err != nil {
f.Skip("failed to initialize python bindings")
}

f.Add(int64(0), []byte("Spacemesh rocks"), uint64(5))
f.Fuzz(func(t *testing.T, rndSeed int64, salt []byte, index uint64) {
src := rand.New(rand.NewSource(rndSeed))
seed := make([]byte, 32)

// generate random seed
_, err := src.Read(seed)
require.NoError(t, err, "failed to read random seed")

// derive key from seed
goKey := NewDerivedKeyFromSeed(seed, index, salt)
pyKey, err := py.Derive(seed, salt, index)
require.NoError(t, err)

// compare keys
require.EqualValues(t, pyKey, goKey.Seed())
})
}
11 changes: 0 additions & 11 deletions ed25519_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package ed25519

import (
"encoding/hex"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -56,13 +55,3 @@ func Test_SignVerify(t *testing.T) {
wrongMessage := []byte("wrong message")
require.False(t, Verify(public, wrongMessage, sig), "signature of different message accepted")
}

func Test_Derive(t *testing.T) {
const expectedEncodedKey = "b6e1caa7ed8fb8b517dbbd5a49f7c9e76f33f0dd74100396207b640479d6fade2b0f080a354fd3c981630efe75bcbc5f4134895b749364f25badeae5a687950c"
const s = "8d03a58456bb1b45f696032444b09d476fa5406f998ed0a50e694ee8a40cfb09"
seed, err := hex.DecodeString(s)
require.NoError(t, err)

privateKey1 := NewDerivedKeyFromSeed(seed, 5, []byte("Spacemesh rocks"))
require.Equal(t, expectedEncodedKey, hex.EncodeToString(privateKey1), "Unexpected key")
}

0 comments on commit bb2e612

Please sign in to comment.