"bufio"
"bytes"
"compress/gzip"
- "crypto"
"crypto/rand"
"encoding/hex"
"os"
"strings"
"testing"
- "bytom/crypto/ed25519/internal/edwards25519"
+ "github.com/bytom/bytom/crypto/ed25519/internal/edwards25519"
)
type zeroReader struct{}
}
}
-func TestCryptoSigner(t *testing.T) {
- var zero zeroReader
- public, private, _ := GenerateKey(zero)
-
- signer := crypto.Signer(private)
-
- publicInterface := signer.Public()
- public2, ok := publicInterface.(PublicKey)
- if !ok {
- t.Fatalf("expected PublicKey from Public() but got %T", publicInterface)
- }
-
- if !bytes.Equal(public, public2) {
- t.Errorf("public keys do not match: original:%x vs Public():%x", public, public2)
- }
-
- message := []byte("message")
- var noHash crypto.Hash
- signature, err := signer.Sign(zero, message, noHash)
- if err != nil {
- t.Fatalf("error from Sign(): %s", err)
- }
-
- if !Verify(public, message, signature) {
- t.Errorf("Verify failed on signature from Sign()")
- }
-}
-
func TestGolden(t *testing.T) {
// sign.input.gz is a selection of test cases from
// http://ed25519.cr.yp.to/python/sign.input