diff --git a/common/shared/src/test/scala/scalan/BaseTests.scala b/common/shared/src/test/scala/scalan/BaseTests.scala index 64a8c7f615..e015ff948e 100644 --- a/common/shared/src/test/scala/scalan/BaseTests.scala +++ b/common/shared/src/test/scala/scalan/BaseTests.scala @@ -34,7 +34,8 @@ abstract class BaseShouldTests extends AnyFlatSpec with TestUtils { } } - protected implicit def convertToInAndIgnoreMethods2(resultOfStringPassedToVerb: ResultOfStringPassedToVerb) = + protected implicit def convertToInAndIgnoreMethods2( + resultOfStringPassedToVerb: ResultOfStringPassedToVerb): InAndIgnoreMethods2 = new InAndIgnoreMethods2(resultOfStringPassedToVerb) } diff --git a/interpreter/shared/src/main/scala/sigmastate/UncheckedTree.scala b/interpreter/shared/src/main/scala/sigmastate/UncheckedTree.scala index 99e26be99e..4b4b28fa0d 100644 --- a/interpreter/shared/src/main/scala/sigmastate/UncheckedTree.scala +++ b/interpreter/shared/src/main/scala/sigmastate/UncheckedTree.scala @@ -16,23 +16,21 @@ sealed trait UncheckedSigmaTree extends UncheckedTree { trait UncheckedConjecture extends UncheckedSigmaTree with ProofTreeConjecture -trait UncheckedLeaf[SP <: SigmaBoolean] extends UncheckedSigmaTree with ProofTreeLeaf { - val proposition: SigmaBoolean -} +trait UncheckedLeaf extends UncheckedSigmaTree with ProofTreeLeaf case class UncheckedSchnorr( override val proposition: ProveDlog, override val commitmentOpt: Option[FirstDLogProverMessage], override val challenge: Challenge, secondMessage: SecondDLogProverMessage -) extends UncheckedLeaf[ProveDlog] +) extends UncheckedLeaf case class UncheckedDiffieHellmanTuple( override val proposition: ProveDHTuple, override val commitmentOpt: Option[FirstDHTupleProverMessage], override val challenge: Challenge, secondMessage: SecondDHTupleProverMessage -) extends UncheckedLeaf[ProveDHTuple] +) extends UncheckedLeaf case class CAndUncheckedNode( override val challenge: Challenge, diff --git a/interpreter/shared/src/main/scala/sigmastate/UnprovenTree.scala b/interpreter/shared/src/main/scala/sigmastate/UnprovenTree.scala index db5aed3a37..a01c937a1f 100644 --- a/interpreter/shared/src/main/scala/sigmastate/UnprovenTree.scala +++ b/interpreter/shared/src/main/scala/sigmastate/UnprovenTree.scala @@ -25,7 +25,7 @@ object ConjectureType extends Enumeration { trait ProofTree extends Product trait ProofTreeLeaf extends ProofTree { - val proposition: SigmaBoolean + val proposition: SigmaLeaf val commitmentOpt: Option[FirstProverMessage] } diff --git a/interpreter/shared/src/main/scala/sigmastate/interpreter/Hint.scala b/interpreter/shared/src/main/scala/sigmastate/interpreter/Hint.scala index 13570e846c..ab2530f653 100644 --- a/interpreter/shared/src/main/scala/sigmastate/interpreter/Hint.scala +++ b/interpreter/shared/src/main/scala/sigmastate/interpreter/Hint.scala @@ -1,8 +1,7 @@ package sigmastate.interpreter import java.math.BigInteger - -import sigmastate.{NodePosition, UncheckedTree} +import sigmastate.{NodePosition, SigmaLeaf, UncheckedTree} import sigmastate.Values.SigmaBoolean import sigmastate.basics.FirstProverMessage import sigmastate.basics.VerifierMessage.Challenge @@ -13,6 +12,10 @@ import sigmastate.basics.VerifierMessage.Challenge * prover knows that pk2 is known to another party, the prover may prove the statement (with an empty proof for "pk2"). */ trait Hint { + /** + * Public image of a secret + */ + def image: SigmaLeaf /** * A hint is related to a subtree (or a leaf) of a tree. This field encodes a position in the tree. @@ -25,12 +28,6 @@ trait Hint { * A hint which is indicating that a secret associated with its public image "image" is already proven. */ abstract class SecretProven extends Hint { - - /** - * Public image of a secret which is proven - */ - def image: SigmaBoolean - /** * Challenge used for a proof */ @@ -46,16 +43,16 @@ abstract class SecretProven extends Hint { * A hint which contains a proof-of-knowledge for a secret associated with its public image "image", * with also the mark that the proof is real. */ -case class RealSecretProof(image: SigmaBoolean, +case class RealSecretProof(image: SigmaLeaf, challenge: Challenge, uncheckedTree: UncheckedTree, override val position: NodePosition) extends SecretProven /** * A hint which contains a proof-of-knowledge for a secret associated with its public image "image", - * with also the mark that the proof is real. + * with also the mark that the proof is simulated (not real). */ -case class SimulatedSecretProof(image: SigmaBoolean, +case class SimulatedSecretProof(image: SigmaLeaf, challenge: Challenge, uncheckedTree: UncheckedTree, override val position: NodePosition) extends SecretProven @@ -66,7 +63,7 @@ case class SimulatedSecretProof(image: SigmaBoolean, * to randomness ("a" in a sigma protocol). */ abstract class CommitmentHint extends Hint { - def image: SigmaBoolean + /** Commitment to randomness (first message in a sigma protocol) */ def commitment: FirstProverMessage } @@ -78,7 +75,7 @@ abstract class CommitmentHint extends Hint { * @param secretRandomness - randomness * @param commitment - commitment to randomness used while proving knowledge of the secret */ -case class OwnCommitment(override val image: SigmaBoolean, +case class OwnCommitment(override val image: SigmaLeaf, secretRandomness: BigInteger, commitment: FirstProverMessage, override val position: NodePosition) extends CommitmentHint @@ -89,7 +86,7 @@ case class OwnCommitment(override val image: SigmaBoolean, * @param image - image of a secret * @param commitment - commitment to randomness used while proving knowledge of the secret */ -case class RealCommitment(override val image: SigmaBoolean, +case class RealCommitment(override val image: SigmaLeaf, commitment: FirstProverMessage, override val position: NodePosition) extends CommitmentHint @@ -99,7 +96,7 @@ case class RealCommitment(override val image: SigmaBoolean, * @param image - image of a secret * @param commitment - commitment to randomness used while proving knowledge of the secret */ -case class SimulatedCommitment(override val image: SigmaBoolean, +case class SimulatedCommitment(override val image: SigmaLeaf, commitment: FirstProverMessage, override val position: NodePosition) extends CommitmentHint diff --git a/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverUtils.scala b/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverUtils.scala index 46138ca9d7..e2b0fe8f5a 100644 --- a/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverUtils.scala +++ b/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverUtils.scala @@ -115,7 +115,7 @@ trait ProverUtils extends Interpreter { inner.children.zipWithIndex.foldLeft(hintsBag) { case (hb, (c, idx)) => traverseNode(c, realPropositions, simulatedPropositions, hb, position.child(idx)) } - case leaf: UncheckedLeaf[_] => + case leaf: UncheckedLeaf => val realFound = realPropositions.contains(leaf.proposition) val simulatedFound = simulatedPropositions.contains(leaf.proposition) if (realFound || simulatedFound) {