Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to sigma v5.0.14 #235

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import org.scalatest.matchers.should.Matchers
import org.scalatest.propspec.AnyPropSpec
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
import scorex.util.encode.Base16
import sigmastate.serialization.ErgoTreeSerializer
import sigma.ast.ErgoTree
import sigma.serialization.ErgoTreeSerializer



Expand Down Expand Up @@ -97,7 +98,7 @@ class AddressSpec extends AnyPropSpec with Matchers with ScalaCheckDrivenPropert
val ergoTree = ErgoTreeSerializer.DefaultSerializer.deserializeErgoTree(Base16.decode(tree).get)
val addr = Address.fromErgoTree(ergoTree, NetworkType.MAINNET)
val addr2 = encoder.fromProposition(ergoTree).get
val addr3 = encoder.fromProposition(ergoTree.proposition).get
val addr3 = encoder.fromProposition(ErgoTree.fromProposition(ergoTree.toProposition(ergoTree.isConstantSegregation))).get
val addr4 = Address.fromPropositionBytes(NetworkType.MAINNET, Base16.decode(tree).get)
addr.getErgoAddress shouldBe addr2
addr.getErgoAddress shouldBe addr3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import org.ergoplatform.appkit.testing.AppkitTesting
import org.scalatest.matchers.should.Matchers
import org.scalatest.propspec.AnyPropSpec
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
import sigmastate.crypto.CryptoConstants
import sigmastate.eval._
import sigma.crypto.CryptoConstants
import sigmastate.helpers.NegativeTesting
import sigma.GroupElement
import sigma.data.{CGroupElement, CBigInt}

import java.math.BigInteger

class AnonymousAccessSpec extends AnyPropSpec with Matchers
with ScalaCheckDrivenPropertyChecks
Expand Down Expand Up @@ -63,9 +65,9 @@ class AnonymousAccessSpec extends AnyPropSpec with Matchers
)
val firstTxSenderStorage = "storage/E2.json"
val secondTxSenderStorage = "storage/E1.json"
val g: GroupElement = CryptoConstants.dlogGroup.generator
val x = BigInt("187235612876647164378132684712638457631278").bigInteger
val y = BigInt("340956873409567839086738967389673896738906").bigInteger
val g: GroupElement = CGroupElement(CryptoConstants.dlogGroup.generator)
val x = CBigInt(new BigInteger("187235612876647164378132684712638457631278"))
val y = CBigInt(new BigInteger("340956873409567839086738967389673896738906"))
val g_x:GroupElement = g.exp(x)
val g_y:GroupElement = g.exp(y)
val g_xy = g_x.exp(y)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import org.ergoplatform.validation.ValidationRules
import org.scalatest.matchers.should.Matchers
import org.scalatest.propspec.AnyPropSpec
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
import sigmastate.Values.SigmaPropConstant
import sigmastate.serialization.ErgoTreeSerializer
import sigma.ast.SigmaPropConstant
import sigma.serialization.ErgoTreeSerializer

class ApiClientSpec
extends AnyPropSpec
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.ergoplatform.appkit

import org.ergoplatform.appkit.impl.{BlockchainContextImpl, InputBoxImpl, UnsignedTransactionBuilderImpl, UnsignedTransactionImpl}
import org.ergoplatform.sdk.{ErgoToken, ExtendedInputBox, Iso, JavaHelpers, SecretString, TokenBalanceException}
import org.ergoplatform.sdk.{ErgoToken, ExtendedInputBox, SdkIsos, JavaHelpers, SecretString, TokenBalanceException}
import org.ergoplatform.sdk.JavaHelpers._
import org.ergoplatform.sdk.Iso._
import sigma.data.Iso._
import org.ergoplatform.settings.ErgoAlgos
import org.ergoplatform.{ErgoBox, ErgoTreePredef, UnsignedErgoLikeTransaction}
import org.scalatest.matchers.should.Matchers
Expand All @@ -15,6 +15,7 @@ import sigmastate.helpers.NegativeTesting
import sigmastate.helpers.TestingHelpers.createBox
import java.util
import java.util.{Collections, List => JList}
import SdkIsos._

class AppkitProvingInterpreterSpec extends AnyPropSpec
with Matchers
Expand Down Expand Up @@ -79,8 +80,8 @@ class AppkitProvingInterpreterSpec extends AnyPropSpec
val tree2 = ErgoTreePredef.FalseProp(ergoTreeHeaderInTests)
val token1 = (ErgoAlgos.hash("id1").toTokenId, 10L)
val token2 = (ErgoAlgos.hash("id2").toTokenId, 20L)
val ergoToken1 = Iso.isoErgoTokenToPair.from(token1)
val ergoToken2 = Iso.isoErgoTokenToPair.from(token2)
val ergoToken1 = SdkIsos.isoErgoTokenToPair.from(token1)
val ergoToken2 = SdkIsos.isoErgoTokenToPair.from(token2)

val input1 = createBox(oneErg + Parameters.MinFee, tree1, additionalTokens = Seq(token1))
val input2 = createBox(oneErg, tree2, additionalTokens = Seq(token2))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ import org.ergoplatform.sdk.{ErgoToken, JavaHelpers}
import org.scalatest.matchers.should.Matchers
import org.scalatest.propspec.AnyPropSpec
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
import sigmastate.crypto.CryptoConstants
import sigmastate.eval._
import sigma.crypto.CryptoConstants
import sigma.GroupElement
import sigma.data.{CGroupElement, CBigInt}
import sigma.util.Extensions.{BigIntegerOps, BigIntOps}
import org.ergoplatform.sdk.SdkIsos._

import java.math.BigInteger
import java.util.{Arrays, List => JList}

class ChangeOutputSpec extends AnyPropSpec with Matchers
Expand All @@ -20,9 +23,9 @@ class ChangeOutputSpec extends AnyPropSpec with Matchers

property("YesChangeOutput") {
val ergoClient = createMockedErgoClient(MockData(Nil, Nil))
val g: GroupElement = CryptoConstants.dlogGroup.generator
val x = BigInt("187235612876647164378132684712638457631278").bigInteger
val y = BigInt("340956873409567839086738967389673896738906").bigInteger
val g: GroupElement = CGroupElement(CryptoConstants.dlogGroup.generator)
val x = CBigInt(new BigInteger("187235612876647164378132684712638457631278"))
val y = CBigInt(new BigInteger("340956873409567839086738967389673896738906"))
val gX:GroupElement = g.exp(x)
val gY:GroupElement = g.exp(y)
val gXY:GroupElement = gX.exp(y)
Expand Down Expand Up @@ -68,9 +71,9 @@ class ChangeOutputSpec extends AnyPropSpec with Matchers

property("NoChangeOutput") {
val ergoClient = createMockedErgoClient(MockData(Nil, Nil))
val g: GroupElement = CryptoConstants.dlogGroup.generator
val x = BigInt("187235612876647164378132684712638457631278").bigInteger
val y = BigInt("340956873409567839086738967389673896738906").bigInteger
val g: GroupElement = CGroupElement(CryptoConstants.dlogGroup.generator)
val x = CBigInt(new BigInteger("187235612876647164378132684712638457631278"))
val y = CBigInt(new BigInteger("340956873409567839086738967389673896738906"))
val gX:GroupElement = g.exp(x)
val gY:GroupElement = g.exp(y)
val gXY:GroupElement = gX.exp(y)
Expand Down Expand Up @@ -117,9 +120,9 @@ class ChangeOutputSpec extends AnyPropSpec with Matchers

property("NoTokenChangeOutput + token burning") {
val ergoClient = createMockedErgoClient(MockData(Nil, Nil))
val g: GroupElement = CryptoConstants.dlogGroup.generator
val x = BigInt("187235612876647164378132684712638457631278").bigInteger
val y = BigInt("340956873409567839086738967389673896738906").bigInteger
val g: GroupElement = CGroupElement(CryptoConstants.dlogGroup.generator)
val x = CBigInt(new BigInteger("187235612876647164378132684712638457631278"))
val y = CBigInt(new BigInteger("340956873409567839086738967389673896738906"))
val gX:GroupElement = g.exp(x)
val gY:GroupElement = g.exp(y)
val gXY:GroupElement = gX.exp(y)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ import org.ergoplatform.sdk.JavaHelpers
import org.scalatest.matchers.should.Matchers
import org.scalatest.propspec.AnyPropSpec
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
import sigmastate.crypto.CryptoConstants
import sigmastate.eval._
import sigma.crypto.CryptoConstants
import sigma.GroupElement
import sigma.data.CBigInt
import sigma.util.Extensions.{BigIntegerOps, BigIntOps, EcpOps}

import java.math.BigInteger

class DHTProverSpec extends AnyPropSpec with Matchers
with ScalaCheckDrivenPropertyChecks
Expand All @@ -16,9 +19,9 @@ class DHTProverSpec extends AnyPropSpec with Matchers

property("DHTProver") {
val ergoClient = createMockedErgoClient(MockData(Nil, Nil))
val g: GroupElement = CryptoConstants.dlogGroup.generator
val x = BigInt("187235612876647164378132684712638457631278").bigInteger
val y = BigInt("340956873409567839086738967389673896738906").bigInteger
val g: GroupElement = CryptoConstants.dlogGroup.generator.toGroupElement
val x = CBigInt(new BigInteger("187235612876647164378132684712638457631278"))
val y = CBigInt(new BigInteger("340956873409567839086738967389673896738906"))
val gX:GroupElement = g.exp(x)
val gY:GroupElement = g.exp(y)
val gXY:GroupElement = gX.exp(y)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import java.math.BigInteger;

import sigmastate.eval.CBigInt;
import sigma.data.CBigInt;
import sigma.Coll;
import sigma.BigInt;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package org.ergoplatform.appkit
import sigma.util.{FileUtil => SFileUtil}
import org.ergoplatform.appkit
import org.ergoplatform.sdk.JavaHelpers.UniversalConverter

import org.ergoplatform.sdk.SdkIsos._
import java.util.{List => JList}
import java.lang.{String => JString}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import org.ergoplatform.wallet.mnemonic.{Mnemonic => WMnemonic}
import org.scalatest.matchers.should.Matchers
import org.scalatest.propspec.AnyPropSpec
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
import sigmastate.Values.{ByteArrayConstant, EvaluatedValue, IntConstant}
import sigma.ast.{EvaluatedValue, ByteArrayConstant, SType, IntConstant, ErgoTree}
import sigma.data.TrivialProp
import sigmastate.helpers.TestingHelpers._
import sigmastate.{SType, TrivialProp}
import org.ergoplatform.sdk.SdkIsos._

class JavaHelpersSpec extends AnyPropSpec with Matchers
with ScalaCheckDrivenPropertyChecks
Expand All @@ -20,7 +21,7 @@ class JavaHelpersSpec extends AnyPropSpec with Matchers
type Registers = Map[NonMandatoryRegisterId, _ <: EvaluatedValue[_ <: SType]]

def boxWithRegs(regs: Registers) = {
testBox(10, TrivialProp.TrueProp, 100, Nil, regs)
testBox(10, ErgoTree.fromSigmaBoolean(TrivialProp.TrueProp), 100, Nil, regs)
}

def check(regs: Registers, expRegs: IndexedSeq[ErgoValue[_]]) = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import org.ergoplatform.sdk.JavaHelpers
import org.scalatest.matchers.should.Matchers
import org.scalatest.propspec.AnyPropSpec
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
import sigmastate.crypto.CryptoConstants
import sigmastate.eval._
import sigma.crypto.CryptoConstants
import sigma.GroupElement
import sigma.data.{CGroupElement, CBigInt}

import java.math.BigInteger
import scala.util.Try

class MultiProveDHTSpec extends AnyPropSpec with Matchers
Expand All @@ -18,15 +19,15 @@ class MultiProveDHTSpec extends AnyPropSpec with Matchers

property("Multi DHTProver") {
val ergoClient = createMockedErgoClient(MockData(Nil, Nil))
val g: GroupElement = CryptoConstants.dlogGroup.generator
val x = BigInt("187235612876647164378132684712638457631278").bigInteger
val y = BigInt("340956873409567839086738967389673896738906").bigInteger
val g: GroupElement = CGroupElement(CryptoConstants.dlogGroup.generator)
val x = CBigInt(new BigInteger("187235612876647164378132684712638457631278"))
val y = CBigInt(new BigInteger("340956873409567839086738967389673896738906"))
val gX:GroupElement = g.exp(x)
val gY:GroupElement = g.exp(y)
val gXY:GroupElement = gX.exp(y)

val x1 = BigInt("287235612876647164378132684712638457").bigInteger
val y1 = BigInt("640956873409567839086738967389673896").bigInteger
val x1 = CBigInt(new BigInteger("287235612876647164378132684712638457"))
val y1 = CBigInt(new BigInteger("640956873409567839086738967389673896"))

val gX1:GroupElement = g.exp(x1)
val gY1:GroupElement = g.exp(y1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import org.ergoplatform.sdk.JavaHelpers
import org.scalatest.matchers.should.Matchers
import org.scalatest.propspec.AnyPropSpec
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
import sigmastate.crypto.CryptoConstants
import sigmastate.eval._
import sigma.crypto.CryptoConstants
import sigma.GroupElement
import sigma.data.{CGroupElement, CBigInt}

import java.math.BigInteger
import scala.util.Try

class MultiProveDlogSpec extends AnyPropSpec with Matchers
Expand All @@ -18,9 +19,9 @@ class MultiProveDlogSpec extends AnyPropSpec with Matchers

property("Multi DlogProver") {
val ergoClient = createMockedErgoClient(MockData(Nil, Nil))
val g: GroupElement = CryptoConstants.dlogGroup.generator
val x = BigInt("187235612876647164378132684712638457631278").bigInteger
val y = BigInt("340956873409567839086738967389673896738906").bigInteger
val g: GroupElement = CGroupElement(CryptoConstants.dlogGroup.generator)
val x = CBigInt(new BigInteger("187235612876647164378132684712638457631278"))
val y = CBigInt(new BigInteger("340956873409567839086738967389673896738906"))
val gX:GroupElement = g.exp(x)
val gY:GroupElement = g.exp(y)

Expand Down Expand Up @@ -55,10 +56,16 @@ class MultiProveDlogSpec extends AnyPropSpec with Matchers
val unsigned = txB.boxesToSpend(inputs).outputs(output).fee(10000000).sendChangeTo(changeAddr).build()

// Dlog with two different secrets
Try(ctx.newProverBuilder().withDLogSecret(x).withDLogSecret(y).build().sign(unsigned)).isSuccess shouldBe true
Try(ctx.newProverBuilder()
.withDLogSecret(x)
.withDLogSecret(y)
.build().sign(unsigned)).isSuccess shouldBe true

// Dlog with wrong secret(s)
Try(ctx.newProverBuilder().withDLogSecret(x).withDLogSecret(BigInt(1).bigInteger).build().sign(unsigned)).isSuccess shouldBe false
Try(ctx.newProverBuilder()
.withDLogSecret(x)
.withDLogSecret(BigInt(1).bigInteger)
.build().sign(unsigned)).isSuccess shouldBe false

// Dlog with duplicate secrets
Try(ctx.newProverBuilder().withDLogSecret(x).withDLogSecret(y).withDLogSecret(x).build().sign(unsigned)).isSuccess shouldBe false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ package org.ergoplatform.appkit
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import org.ergoplatform.appkit.AppkitHelpers._
import org.ergoplatform.appkit.InputBoxesSelectionException.{InputBoxLimitExceededException, NotEnoughCoinsForChangeException, NotEnoughErgsException}
import org.ergoplatform.appkit.InputBoxesSelectionException.{InputBoxLimitExceededException, NotEnoughErgsException, NotEnoughCoinsForChangeException}
import org.ergoplatform.appkit.impl.{Eip4TokenBuilder, ErgoTreeContract}
import org.ergoplatform.appkit.testing.AppkitTesting
import org.ergoplatform.explorer.client.model.{Items, TokenInfo}
import org.ergoplatform.sdk.JavaHelpers._
import org.ergoplatform.sdk.{ErgoToken, SecretString}
import org.ergoplatform.{ErgoBox, ErgoTreePredef, appkit}
import org.ergoplatform.sdk.SdkIsos._
import org.ergoplatform.{appkit, ErgoBox, ErgoTreePredef}
import org.scalacheck.Gen
import org.scalatest.matchers.should.Matchers
import org.scalatest.propspec.AnyPropSpec
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
import sigma.util.{FileUtil => SFileUtil}
import scorex.util.ModifierId
import sigmastate.eval.CBigInt
import sigmastate.helpers.NegativeTesting
import sigmastate.interpreter.HintsBag

Expand Down Expand Up @@ -112,7 +112,7 @@ class TxBuilderSpec extends AnyPropSpec with Matchers
ergoClient.execute { ctx: BlockchainContext =>
val contextVars = Seq(
ContextVar.of(1.toByte, 100),
ContextVar.of(10.toByte, CBigInt(BigInteger.valueOf(100)))
ContextVar.of(10.toByte, BigInteger.valueOf(100))
)
val input = createTestInput(ctx)
.withContextVars(contextVars:_*)
Expand All @@ -133,7 +133,7 @@ class TxBuilderSpec extends AnyPropSpec with Matchers
// alice signing bob's box. Does not work here but works in other cases.
val prover = ctx.newProverBuilder().build()
val signed = prover.sign(unsigned)
signed.getCost shouldBe 14565
signed.getCost shouldBe 12310

// check the signed transaction contains all the context variables
// we attached to the input box
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package org.ergoplatform.appkit.cli
import org.ergoplatform.appkit
import sigma.util.{FileUtil => SFileUtil}
import org.ergoplatform.sdk.JavaHelpers._

import org.ergoplatform.sdk.SdkIsos._
import java.util.{List => JList}
import java.lang.{String => JString}
import org.ergoplatform.appkit.FileMockedErgoClient
Expand Down
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ assemblyMergeStrategy in assembly := {

lazy val allConfigDependency = "compile->compile;test->test"

val sigmaStateVersion = "5.0.12"
val ergoWalletVersion = "5.0.15"
val sigmaStateVersion = "5.0.13-181-c2d4cc97-SNAPSHOT"
val ergoWalletVersion = "5.0.19-4-9f5a24bf-SNAPSHOT"
lazy val sigmaState = ("org.scorexfoundation" %% "sigma-state" % sigmaStateVersion).force()
.exclude("ch.qos.logback", "logback-classic")
.exclude("org.scorexfoundation", "scrypto")
Expand Down
Loading
Loading