From 213b1c6d82560e6fa801e02011424d4746a4c9a8 Mon Sep 17 00:00:00 2001 From: Rongjian Lan Date: Fri, 15 Feb 2019 11:53:57 -0800 Subject: [PATCH] Remove the extra tests that havev heavy external dependency, we actually don't need them --- .gitmodules | 12 ---- crypto/vrf/p256/p256_test.go | 121 ----------------------------------- keytransparency | 1 - trillian | 1 - 4 files changed, 135 deletions(-) delete mode 160000 keytransparency delete mode 160000 trillian diff --git a/.gitmodules b/.gitmodules index e7d1bb3a0..ad2702ed2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -5,15 +5,3 @@ [submodule "vendor/github.com/libp2p/go-libp2p-kad-dht"] path = vendor/github.com/libp2p/go-libp2p-kad-dht url = https://github.com/libp2p/go-libp2p-kad-dht -[submodule "vendor/github.com/google/keytransparency"] - path = vendor/github.com/google/keytransparency - url = https://github.com/google/keytransparency -[submodule "vendor/github.com/google/trillian"] - path = vendor/github.com/google/trillian - url = https://github.com/google/trillian -[submodule "keytransparency"] - path = keytransparency - url = git@github.com:google/keytransparency.git -[submodule "trillian"] - path = trillian - url = git@github.com:google/trillian.git diff --git a/crypto/vrf/p256/p256_test.go b/crypto/vrf/p256/p256_test.go index 534701cc7..52619d2f1 100644 --- a/crypto/vrf/p256/p256_test.go +++ b/crypto/vrf/p256/p256_test.go @@ -16,24 +16,10 @@ package p256 import ( "bytes" - "context" "crypto/rand" "encoding/hex" - "encoding/json" - "io/ioutil" "math" - "os" "testing" - - "github.com/golang/protobuf/jsonpb" - "github.com/golang/protobuf/proto" - "github.com/google/keytransparency/core/testdata" - "github.com/google/trillian/crypto/keys" - "github.com/google/trillian/crypto/keys/der" - "github.com/google/trillian/crypto/keyspb" - - pb "github.com/google/keytransparency/core/api/v1/keytransparency_go_proto" - _ "github.com/google/trillian/crypto/keys/der/proto" ) const ( @@ -80,76 +66,6 @@ func TestH2(t *testing.T) { } } -func TestNewFromWrappedKey(t *testing.T) { - ctx := context.Background() - for _, tc := range []struct { - desc string - wantFromWrappedErr bool - spec *keyspb.Specification - keygen keys.ProtoGenerator - }{ - { - desc: "DER with ECDSA spec", - spec: &keyspb.Specification{ - Params: &keyspb.Specification_EcdsaParams{ - EcdsaParams: &keyspb.Specification_ECDSA{ - Curve: keyspb.Specification_ECDSA_P256, - }, - }, - }, - keygen: func(ctx context.Context, spec *keyspb.Specification) (proto.Message, error) { - return der.NewProtoFromSpec(spec) - }, - }, - { - desc: "DER with Non-ECDSA spec", - wantFromWrappedErr: true, - spec: &keyspb.Specification{ - Params: &keyspb.Specification_RsaParams{ - RsaParams: &keyspb.Specification_RSA{Bits: 2048}, - }, - }, - keygen: func(ctx context.Context, spec *keyspb.Specification) (proto.Message, error) { - return der.NewProtoFromSpec(spec) - }, - }, - } { - t.Run(tc.desc, func(t *testing.T) { - // Generate VRF key. - wrapped, err := tc.keygen(ctx, tc.spec) - if err != nil { - t.Fatalf("keygen failed: %v", err) - } - vrfPriv, err := NewFromWrappedKey(ctx, wrapped) - if got, want := err != nil, tc.wantFromWrappedErr; got != want { - t.Errorf("NewFromWrappedKey (): %v, want err: %v", err, want) - } - if err != nil { - return - } - - vrfPubDER, err := der.MarshalPublicKey(vrfPriv.Public()) - if err != nil { - t.Fatalf("MarshalPublicKey failed: %v", err) - } - vrfPub, err := NewVRFVerifierFromRawKey(vrfPubDER) - if err != nil { - t.Fatalf("NewVRFVerifierFromRawKey(): %v", err) - } - // Test that the public and private components match. - m := []byte("foobar") - indexA, proof := vrfPriv.Evaluate(m) - indexB, err := vrfPub.ProofToHash(m, proof) - if err != nil { - t.Fatalf("ProofToHash(): %v", err) - } - if got, want := indexB, indexA; got != want { - t.Errorf("ProofToHash(%s, %x): %x, want %x", m, proof, got, want) - } - }) - } -} - func TestVRF(t *testing.T) { k, pk := GenerateKey() @@ -184,43 +100,6 @@ func TestVRF(t *testing.T) { } } -// Test vectors in core/testdata are generated by running -// go generate ./core/testdata -func TestProofToHash(t *testing.T) { - directoryFile := "../../../test/testdata/directory.json" - f, err := os.Open(directoryFile) - if err != nil { - t.Fatalf("ReadFile(%v): %v", directoryFile, err) - } - defer f.Close() - var directory pb.Directory - if err := jsonpb.Unmarshal(f, &directory); err != nil { - t.Fatalf("jsonpb.Unmarshal(): %v", err) - } - pk, err := NewVRFVerifierFromRawKey(directory.GetVrf().GetDer()) - if err != nil { - t.Fatalf("NewVRFVerifier failure: %v", err) - } - - respFile := "../../../test/testdata/getentryresponse.json" - b, err := ioutil.ReadFile(respFile) - if err != nil { - t.Fatalf("ReadFile(%v): %v", respFile, err) - } - var getUserResponses []testdata.ResponseVector - if err := json.Unmarshal(b, &getUserResponses); err != nil { - t.Fatalf("Unmarshal(): %v", err) - } - for _, tc := range getUserResponses { - t.Run(tc.Desc, func(t *testing.T) { - _, err := pk.ProofToHash([]byte(tc.UserIDs[0]), tc.GetUserResp.GetLeaf().GetVrfProof()) - if err != nil { - t.Errorf("ProofToHash(%v): %v)", tc.Desc, err) - } - }) - } -} - func TestReadFromOpenSSL(t *testing.T) { for _, tc := range []struct { priv string diff --git a/keytransparency b/keytransparency deleted file mode 160000 index 3fda514f0..000000000 --- a/keytransparency +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3fda514f045e9cba8e238e75ac9efe84aa1d8783 diff --git a/trillian b/trillian deleted file mode 160000 index b6ba309d0..000000000 --- a/trillian +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b6ba309d0ed1934a3e68df816682beca7681f313