Exemplo n.º 1
0
// Try to verify a proof that has a single flipped bit
func TestInvalidatedUserProof(T *testing.T) {
	data, users, _ := createSetup(5, 2)

	msg, err := users[0].GetCoverCipherText(data, 3, 1)
	if err != nil {
		T.Fatalf("Failed to create proof: %v", err)
	}
	crypto.FlipBit(msg.Proof)
	if err := msg.Verify(data); err == nil {
		T.Log("Forged proof was valid, should be invalid")
		T.Fail()
	}

	points := make([]abstract.Point, 3)
	for i := range points {
		points[i], _ = crypto.Suite.Point().Pick(nil, crypto.Suite.Cipher(nil))
	}
	msg, err = users[0].GetRealCipherText(data, points)
	if err != nil {
		T.Fatalf("Failed to create proof: %v", err)
	}
	crypto.FlipBit(msg.Proof)
	if err := msg.Verify(data); err == nil {
		T.Log("Forged proof was valid, should be invalid")
		T.Fail()
	}
}
Exemplo n.º 2
0
// Test what happens if we mess with the secret r_j = \sum_i r_{ij}
func TestInvalidatedNotaryProof(T *testing.T) {
	data, _, notaries := createSetup(5, 2)

	msg, err := notaries[0].GetCiphertext(data, 3)
	if err != nil {
		T.Fatalf("Failed to create proof: %v", err)
	}

	crypto.FlipBit(msg.Proof)
	if err := msg.Verify(data); err == nil {
		T.Fatal("Forged proof was valid, should be invalid")
	}
}