// ProveCommitmentMultiplication demonstrates how, given commitments A, B, C, prover can
// prove that C = A * B. Note that the proof should work also for other commitments that are based
// on q-one-way homomorphism, not only for RSABasedCommitter.
ProveCommitmentMultiplication demonstrates how, given commitments A, B, C, prover can
prove that C = A * B. Note that the proof should work also for other commitments that are based
on q-one-way homomorphism, not only for RSABasedCommitter.
// ProveCommitmentMultiplication demonstrates how given commitments A B C prover can // prove that C = A * B . Note that the proof should work also for other commitments that are based // on q - one - way homomorphism not only for RSABasedCommitter .
func ProveCommitmentMultiplication() (bool, error) {
	receiver, err := commitments.NewRSABasedCommitReceiver(1024)
	if err != nil {
		return false, err
	}
	committer, err := commitments.NewRSABasedCommitter(receiver.Homomorphism, receiver.HomomorphismInv,
		receiver.H, receiver.Q, receiver.Y)
	if err != nil {
		return false, err
	}
	a := common.GetRandomInt(committer.Q)
	b := common.GetRandomInt(committer.Q)
	A, err1 := committer.GetCommitMsg(a)
	_, r := committer.GetDecommitMsg()
	B, err2 := committer.GetCommitMsg(b)
	_, u := committer.GetDecommitMsg()
	c := new(big.Int).Mul(a, b)
	c.Mod(c, committer.Q) 
	C, o, t := committer.GetCommitmentToMultiplication(a, b, u)
	if err1 != nil || err2 != nil {
		return false, err
	}
	homomorphism := committer.Homomorphism
	homomorphismInv := receiver.HomomorphismInv
	H := committer.H
	Q := committer.Q
	Y := committer.Y
	commitments := common.NewTriple(A, B, C)
	committedValues := common.NewPair(a, b)
	randomValues := common.NewTriple(r, u, o)
	prover := NewQOneWayMultiplicationProver(homomorphism, homomorphismInv, H, Q, Y,
		commitments, committedValues, randomValues, t)
	verifier := NewQOneWayMultiplicationVerifier(homomorphism, H, Q, Y, commitments)
	m1, m2, m3 := prover.GetProofRandomData()
	verifier.SetProofRandomData(m1, m2, m3)
	challenge := verifier.GetChallenge()
	z1, w1, w2, z2, w3 := prover.GetProofData(challenge)
	proved := verifier.Verify(z1, w1, w2, z2, w3)
	return proved, nil
}
func ProveCommitmentMultiplication ( ) ( bool , error ) { receiver , err := commitments . NewRSABasedCommitReceiver ( 1024 ) if err != nil { return false , err } committer , err := commitments . NewRSABasedCommitter ( receiver . Homomorphism , receiver . HomomorphismInv , receiver . H , receiver . Q , receiver . Y ) if err != nil { return false , err } a := common . GetRandomInt ( committer . Q ) b := common . GetRandomInt ( committer . Q ) A , err1 := committer . GetCommitMsg ( a ) _ , r := committer . GetDecommitMsg ( ) B , err2 := committer . GetCommitMsg ( b ) _ , u := committer . GetDecommitMsg ( ) c := new ( big . Int ) . Mul ( a , b ) c . Mod ( c , committer . Q ) C , o , t := committer . GetCommitmentToMultiplication ( a , b , u ) if err1 != nil || err2 != nil { return false , err } homomorphism := committer . Homomorphism homomorphismInv := receiver . HomomorphismInv H := committer . H Q := committer . Q Y := committer . Y commitments := common . NewTriple ( A , B , C ) committedValues := common . NewPair ( a , b ) randomValues := common . NewTriple ( r , u , o ) prover := NewQOneWayMultiplicationProver ( homomorphism , homomorphismInv , H , Q , Y , commitments , committedValues , randomValues , t ) verifier := NewQOneWayMultiplicationVerifier ( homomorphism , H , Q , Y , commitments ) m1 , m2 , m3 := prover . GetProofRandomData ( ) verifier . SetProofRandomData ( m1 , m2 , m3 ) challenge := verifier . GetChallenge ( ) z1 , w1 , w2 , z2 , w3 := prover . GetProofData ( challenge ) proved := verifier . Verify ( z1 , w1 , w2 , z2 , w3 ) return proved , nil }
ProveCommitmentMultiplication demonstrates how, given commitments A, B, C, prover can
prove that C = A * B.
ProveCommitmentMultiplication demonstrates how given commitments A B C prover can prove that C = A * B .
// this management of commitments and decommitments is awkward, // see TODO in pedersen.go about refactoring commitment schemes API // c = a * b mod Q