// TestProveDamgardFujisakiCommitmentSquare demonstrates how to prove that the commitment
// hides the square. Given c, prove that c = g^(x^2) * h^r (mod n).
TestProveDamgardFujisakiCommitmentSquare demonstrates how to prove that the commitment
hides the square. Given c, prove that c = g^(x^2) * h^r (mod n).
// TestProveDamgardFujisakiCommitmentSquare demonstrates how to prove that the commitment // hides the square . Given c prove that c = g^ ( x^2 ) * h^r ( mod n ) .
func TestProveDamgardFujisakiCommitmentSquare(t *testing.T) {
	receiver, err := commitments.NewDamgardFujisakiReceiver(1024, 80)
	if err != nil {
		t.Errorf("Error in NewDamgardFujisakiReceiver: %v", err)
	}
	T := new(big.Int).Mul(receiver.QRSpecialRSA.N, receiver.QRSpecialRSA.N)
	committer := commitments.NewDamgardFujisakiCommitter(receiver.QRSpecialRSA.N,
		receiver.H, receiver.G, T, receiver.K)
	x := common.GetRandomInt(committer.QRSpecialRSA.N)
	x2 := new(big.Int).Mul(x, x)
	c, err := committer.GetCommitMsg(x2)
	if err != nil {
		t.Errorf("Error in computing commit msg: %v", err)
	}
	receiver.SetCommitment(c)
	challengeSpaceSize := 80
	prover, err := NewDFCommitmentSquareProver(committer, x, challengeSpaceSize)
	if err != nil {
		t.Errorf("Error in instantiating DFCommitmentSquareProver: %v", err)
	}
	verifier, err := NewDFCommitmentSquareVerifier(receiver, prover.SmallCommitment, challengeSpaceSize)
	if err != nil {
		t.Errorf("Error in instantiating DFCommitmentSquareVerifier: %v", err)
	}
	proofRandomData1, proofRandomData2 := prover.GetProofRandomData()
	verifier.SetProofRandomData(proofRandomData1, proofRandomData2)
	challenge := verifier.GetChallenge()
	s1, s21, s22 := prover.GetProofData(challenge)
	proved := verifier.Verify(s1, s21, s22)
	assert.Equal(t, true, proved, "DamgardFujisaki square proof failed.")
}
func TestProveDamgardFujisakiCommitmentSquare ( t * testing . T ) { receiver , err := commitments . NewDamgardFujisakiReceiver ( 1024 , 80 ) if err != nil { t . Errorf ( " " , err ) } T := new ( big . Int ) . Mul ( receiver . QRSpecialRSA . N , receiver . QRSpecialRSA . N ) committer := commitments . NewDamgardFujisakiCommitter ( receiver . QRSpecialRSA . N , receiver . H , receiver . G , T , receiver . K ) x := common . GetRandomInt ( committer . QRSpecialRSA . N ) x2 := new ( big . Int ) . Mul ( x , x ) c , err := committer . GetCommitMsg ( x2 ) if err != nil { t . Errorf ( " " , err ) } receiver . SetCommitment ( c ) challengeSpaceSize := 80 prover , err := NewDFCommitmentSquareProver ( committer , x , challengeSpaceSize ) if err != nil { t . Errorf ( " " , err ) } verifier , err := NewDFCommitmentSquareVerifier ( receiver , prover . SmallCommitment , challengeSpaceSize ) if err != nil { t . Errorf ( " " , err ) } proofRandomData1 , proofRandomData2 := prover . GetProofRandomData ( ) verifier . SetProofRandomData ( proofRandomData1 , proofRandomData2 ) challenge := verifier . GetChallenge ( ) s1 , s21 , s22 := prover . GetProofData ( challenge ) proved := verifier . Verify ( s1 , s21 , s22 ) assert . Equal ( t , true , proved , " " ) }
TestProveDamgardFujisakiCommitmentSquare demonstrates how to prove that the commitment
hides the square.
TestProveDamgardFujisakiCommitmentSquare demonstrates how to prove that the commitment hides the square .
// n^2 is used for T - but any other value can be used as well