// TestProveDamgardFujisakiCommitmentPositive demonstrates how to prove that the commitment
// hides a positive number. Given c, prove that c = g^x * h^r (mod n) where x >= 0.
TestProveDamgardFujisakiCommitmentPositive demonstrates how to prove that the commitment
hides a positive number. Given c, prove that c = g^x * h^r (mod n) where x >= 0.
// TestProveDamgardFujisakiCommitmentPositive demonstrates how to prove that the commitment // hides a positive number . Given c prove that c = g^x * h^r ( mod n ) where x > = 0 .
func TestProveDamgardFujisakiCommitmentPositive(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)
	c, err := committer.GetCommitMsg(x)
	if err != nil {
		t.Errorf("error in computing commit msg: %v", err)
	}
	receiver.SetCommitment(c)
	_, r := committer.GetDecommitMsg()
	challengeSpaceSize := 80
	prover, err := NewDFCommitmentPositiveProver(committer, x, r,
		challengeSpaceSize)
	if err != nil {
		t.Errorf("error in instantiating DFCommitmentPositiveProver: %v", err)
	}
	smallCommitments, bigCommitments := prover.GetVerifierInitializationData()
	verifier, err := NewDFCommitmentPositiveVerifier(receiver, receiver.Commitment,
		smallCommitments, bigCommitments, challengeSpaceSize)
	if err != nil {
		t.Errorf("error in instantiating DFCommitmentPositiveVerifier: %v", err)
	}
	proofRandomData := prover.GetProofRandomData()
	challenges := verifier.GetChallenges()
	err = verifier.SetProofRandomData(proofRandomData)
	if err != nil {
		t.Errorf("error when calling SetProofRandomData: %v", err)
	}
	proofData := prover.GetProofData(challenges)
	proved := verifier.Verify(proofData)
	assert.Equal(t, true, proved, "DamgardFujisaki positive proof failed.")
}
func TestProveDamgardFujisakiCommitmentPositive ( 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 ) c , err := committer . GetCommitMsg ( x ) if err != nil { t . Errorf ( " " , err ) } receiver . SetCommitment ( c ) _ , r := committer . GetDecommitMsg ( ) challengeSpaceSize := 80 prover , err := NewDFCommitmentPositiveProver ( committer , x , r , challengeSpaceSize ) if err != nil { t . Errorf ( " " , err ) } smallCommitments , bigCommitments := prover . GetVerifierInitializationData ( ) verifier , err := NewDFCommitmentPositiveVerifier ( receiver , receiver . Commitment , smallCommitments , bigCommitments , challengeSpaceSize ) if err != nil { t . Errorf ( " " , err ) } proofRandomData := prover . GetProofRandomData ( ) challenges := verifier . GetChallenges ( ) err = verifier . SetProofRandomData ( proofRandomData ) if err != nil { t . Errorf ( " " , err ) } proofData := prover . GetProofData ( challenges ) proved := verifier . Verify ( proofData ) assert . Equal ( t , true , proved , " " ) }
TestProveDamgardFujisakiCommitmentPositive demonstrates how to prove that the commitment
hides a positive number.
TestProveDamgardFujisakiCommitmentPositive demonstrates how to prove that the commitment hides a positive number .
// n^2 is used for T - but any other value can be used as well