Skip to content

Commit

Permalink
expUnsigned test
Browse files Browse the repository at this point in the history
  • Loading branch information
kushti committed Nov 13, 2024
1 parent 503f0c7 commit 6a15e5f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/shared/src/main/scala/sigma/ast/SType.scala
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ object SType {
SGlobal, SHeader, SPreHeader, SAvlTree, SGroupElement, SSigmaProp, SString, SBox,
SUnit, SAny)

// V6 types, see `allPredefTypes` scaladoc below
// V6 types, see `allPredefTypes` scaladoc below. Contains SUnsignedBigInt type in addition to v5 types.
private val v6PredefTypes = v5PredefTypes ++ Array(SUnsignedBigInt)

/** All pre-defined types should be listed here. Note, NoType is not listed.
Expand Down
22 changes: 21 additions & 1 deletion sc/shared/src/test/scala/sigma/LanguageSpecificationV6.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import sigma.ast.ErgoTree.{HeaderType, ZeroHeader}
import sigma.ast.SCollection.SByteArray
import sigma.ast.syntax.TrueSigmaProp
import sigma.ast.{SInt, _}
import sigma.data.{AvlTreeData, AvlTreeFlags, CAnyValue, CAvlTree, CBigInt, CBox, CHeader, CSigmaDslBuilder, CSigmaProp, CUnsignedBigInt, ExactNumeric, PairOfCols, ProveDHTuple, RType}
import sigma.data.{AvlTreeData, AvlTreeFlags, CAnyValue, CAvlTree, CBigInt, CBox, CGroupElement, CHeader, CSigmaDslBuilder, CSigmaProp, CUnsignedBigInt, ExactNumeric, PairOfCols, ProveDHTuple, RType}
import sigma.eval.{CostDetails, SigmaDsl, TracedCost}
import sigma.serialization.ValueCodes.OpCode
import sigma.util.Extensions.{BooleanOps, IntOps}
Expand All @@ -23,6 +23,7 @@ import sigmastate.exceptions.MethodNotFound
import sigmastate.utils.Extensions.ByteOpsForSigma
import sigmastate.utils.Helpers
import sigma.Extensions.{ArrayOps, CollOps}
import sigma.crypto.CryptoConstants
import sigma.interpreter.{ContextExtension, ProverResult}

import java.math.BigInteger
Expand Down Expand Up @@ -2417,5 +2418,24 @@ class LanguageSpecificationV6 extends LanguageSpecificationBase { suite =>
preGeneratedSamples = Some(Seq())
)
}

property("GroupElement.expUnsigned") {
import sigma.data.OrderingOps.UnsignedBigIntOrdering

val f = newFeature[(GroupElement, UnsignedBigInt), GroupElement](
{ (xs: (GroupElement, UnsignedBigInt)) => xs._1.expUnsigned(xs._2) },
"""{ (xs: (GroupElement, UnsignedBigInt)) => xs._1.expUnsigned(xs._2) }""".stripMargin,
sinceVersion = VersionContext.V6SoftForkVersion
)

verifyCases(
Seq(
(CGroupElement(CryptoConstants.dlogGroup.generator), CUnsignedBigInt(new BigInteger("1"))) -> Expected(ExpectedResult(Success(CGroupElement(CryptoConstants.dlogGroup.generator)), None)),
(CGroupElement(CryptoConstants.dlogGroup.generator), CUnsignedBigInt(new BigInteger("0"))) -> Expected(ExpectedResult(Success(CGroupElement(CryptoConstants.dlogGroup.identity)), None)),
(CGroupElement(CryptoConstants.dlogGroup.generator), CUnsignedBigInt(CryptoConstants.dlogGroup.order)) -> Expected(ExpectedResult(Success(CGroupElement(CryptoConstants.dlogGroup.identity)), None))
),
f
)
}

}

0 comments on commit 6a15e5f

Please sign in to comment.