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

[6.0] UnsignedBigInt implementation #997

Open
wants to merge 137 commits into
base: i1006
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
137 commits
Select commit Hold shift + click to select a range
3d47f2a
initial raw, buggy & unversioned unsigned bit int impl
kushti May 24, 2024
b13cef6
failing schnorr sig check w. unsigned
kushti May 24, 2024
2e23a2c
v6.0-serialize: CheckMinimalErgoTreeVersion rule removed
aslesarenko May 28, 2024
fe68c66
v6.0-serialize: cleanup + ScalaDocs
aslesarenko May 28, 2024
a5321af
v6.0-serialize: added CoreByteWriter.checkCostLimit
aslesarenko May 28, 2024
432addc
v6.0-serialize: cost accumulation in SigmaByteWriter and serialize_ev…
aslesarenko May 29, 2024
97377c2
v6.0-serialize: cleanup + ScalaDocs
aslesarenko Jun 3, 2024
767fbb4
v6.0-serialize: tests for cost trace
aslesarenko Jun 3, 2024
7ce2446
merging w. 6.0.0
kushti Jun 3, 2024
744d8a5
conversion test stub
kushti Jun 3, 2024
a30e068
Merge branch 'v6.0.0' of github.com:ScorexFoundation/sigmastate-inter…
kushti Jun 3, 2024
2acc6db
more todos
kushti Jun 4, 2024
0478069
Merge branch 'v6.0.0' of github.com:ScorexFoundation/sigmastate-inter…
kushti Jun 6, 2024
e2faf71
merging with newfeature pr
kushti Jun 6, 2024
37ac921
BasicOpsSpecification tests for serialize
kushti Jun 6, 2024
074d609
MethodCall deserialization round trip for Global.serialize
kushti Jun 6, 2024
bf53a6b
spam tests, test for serialize(long) producing different result from …
kushti Jun 6, 2024
15e21a4
importing new test for ErgoTreeSpecification from i486
kushti Jun 7, 2024
15f4f67
removing modq methods
kushti Jun 7, 2024
303f969
expUnsigned impl (test still failing)
kushti Jun 8, 2024
982f32f
schnorr sig example passed
kushti Jun 9, 2024
eb47d17
eq test, DataValueComparer
kushti Jun 9, 2024
33033fc
importing CheckMinimalErgoTreeVersion from i994
kushti Jun 10, 2024
d7fd8e1
merging w. 6.0.0
kushti Jun 10, 2024
dd62bd7
failing tests
kushti Jun 11, 2024
aaef77e
close #906: lazy evaluation of default in Option.getOrElse and Coll.g…
kushti Jun 11, 2024
ea468c9
initial stubs along first todos for bulletproofs contracts
kushti Jun 11, 2024
e9b3253
original code
kushti Jun 12, 2024
7ccce9a
distinct and reverse (w. no costing)
kushti Jun 12, 2024
2fa224b
startsWith and endsWith
kushti Jun 12, 2024
b17c8c8
get
kushti Jun 12, 2024
fc3be57
non-execution of get_eval todo
kushti Jun 12, 2024
f7f31e3
fix w/out tests (only manual tests are done)
kushti Jun 13, 2024
e71d7c2
modInverse
kushti Jun 13, 2024
e989665
plusMod
kushti Jun 13, 2024
d776db3
multiplyMod
kushti Jun 13, 2024
72db85b
toUnsigned & toUnsignedMod
kushti Jun 14, 2024
fc6d856
mod, toSigned, subtractMod
kushti Jun 17, 2024
62fd2a3
initial stub and roundtrip test with longToByteArray
kushti Jun 17, 2024
8bcc1ef
impl and tests done without costing etc
kushti Jun 18, 2024
b7e2a38
first failing test
kushti Jun 19, 2024
828ba27
passing test from getVar from another input
kushti Jun 27, 2024
b80ef29
invalid tests
kushti Jun 28, 2024
6a3cbac
initial failing test & impl
kushti Jun 29, 2024
af92a3f
test passing
kushti Jun 29, 2024
8f9b549
Merge branch 'v6.0.0' of github.com:ScorexFoundation/sigmastate-inter…
kushti Jul 30, 2024
4c63a60
LSV5 & LSV6 tests
kushti Jul 30, 2024
61f90cd
assertEXceptionThrown
kushti Jul 31, 2024
26809c9
passing but improper changedFeature test
kushti Aug 2, 2024
57ba522
merging w. 6.0.0
kushti Aug 8, 2024
8da3575
fixed tests in LSV6
kushti Aug 9, 2024
26f92f1
merging w. 6.0.0
kushti Aug 12, 2024
12e888d
scala 2.11 compilation fix
kushti Aug 12, 2024
b0fbfbb
fixing getVar typing during tree building, simpler execution for getV…
kushti Aug 13, 2024
65144a9
merging w. 6.0.0
kushti Aug 13, 2024
49a393c
merged w. 6.0.0
kushti Aug 19, 2024
649069b
fixed cost, improved args list for SigmaDslBuilder.fromBigEndianBytes
kushti Aug 19, 2024
6bb7fe7
merging w. 6.0.0
kushti Aug 20, 2024
bcfb24d
removing unused CSigmaDslBuilder.validationSettings
kushti Aug 25, 2024
5063bae
Merge branch 'v6.0.0' of github.com:ScorexFoundation/sigmastate-inter…
kushti Aug 27, 2024
acb76c9
Merge branch 'v6.0.0' of github.com:ScorexFoundation/sigmastate-inter…
kushti Aug 27, 2024
877ed78
adding new methods to GraphIRReflection
kushti Aug 30, 2024
9a10d17
merging w. i1006 (numeric methods)
kushti Sep 9, 2024
89d4477
Merge branch 'i1006' of github.com:ScorexFoundation/sigmastate-interp…
kushti Sep 12, 2024
f20635e
merging w v6.0.0
kushti Sep 13, 2024
7e3b676
fixing method calls check test
kushti Sep 16, 2024
4343bc9
fix for longToByteArray support in JS
kushti Sep 17, 2024
343a385
Merge branch 'i1006' of github.com:ScorexFoundation/sigmastate-interp…
kushti Sep 17, 2024
1c2b99d
more polishing in UnsignedBigInt impl
kushti Sep 17, 2024
cb51ba8
removing access to type before 6.0, more tests
kushti Sep 17, 2024
3d88fc2
Merge pull request #1017 from ScorexFoundation/i1006
kushti Sep 20, 2024
9c310c7
merging w. 6.0.0
kushti Sep 20, 2024
f5feee5
Merge pull request #989 from ScorexFoundation/v6.0-serialize
kushti Sep 20, 2024
43db8df
scrypto 3.0.0
kushti Sep 23, 2024
9fd499a
merging w. 6.0.0
kushti Sep 24, 2024
8136c8f
new methods added to ReflectionData
kushti Sep 24, 2024
1999a2a
merging w. 6.0.0
kushti Sep 26, 2024
586aadd
LSV6 tests, predefined method
kushti Sep 26, 2024
2cdc34e
fixing JS tests
kushti Sep 26, 2024
d738ac5
fixing JS tests
kushti Sep 27, 2024
1989d19
LSV6 tests
kushti Sep 27, 2024
8f45909
merging w 6.0.0
kushti Sep 27, 2024
6459b07
fix ErgoTreeSpec
kushti Sep 27, 2024
ee35792
merging w. 6.0.0
kushti Sep 29, 2024
a3f25ef
LSV6 tests
kushti Sep 30, 2024
f24e9ad
predefined fn, LangSpec notes, polishing PR
kushti Sep 30, 2024
166c261
merging w. 6.0.0
kushti Sep 30, 2024
edc91ba
tests
kushti Sep 30, 2024
af792b5
addressing review comments
kushti Oct 1, 2024
6fa801c
Merge pull request #1013 from ScorexFoundation/i993
kushti Oct 1, 2024
e052255
merging w. 6.0.0
kushti Oct 3, 2024
d8fab5e
Merge branch 'v6.0.0' of github.com:ScorexFoundation/sigmastate-inter…
kushti Oct 3, 2024
5c4ccf1
merging w. 6.0.0
kushti Oct 3, 2024
1d47d5f
addressing review comments
kushti Oct 7, 2024
83ba4a4
Merge pull request #1010 from ScorexFoundation/i1004
kushti Oct 7, 2024
11d869f
merging w. 6.0.0
kushti Oct 7, 2024
29ed83a
Merge branch 'v6.0.0' of github.com:ScorexFoundation/sigmastate-inter…
kushti Oct 8, 2024
f151e1d
merging w. 6.0.0
kushti Oct 8, 2024
7b48ddd
merging w. 6.0.0
kushti Oct 8, 2024
09ec5f1
ignoring bulletproof test, impoving comments
kushti Oct 18, 2024
5cabedd
equalsPairCollWithCollOverArray
kushti Oct 18, 2024
571e721
Merge pull request #1011 from ergoplatform/i909
kushti Oct 18, 2024
c21ed63
Merge pull request #1008 from ergoplatform/i906
kushti Oct 21, 2024
35fe87a
merging w. 6.0.0
kushti Oct 21, 2024
9036aec
improving tests in BasicOpsSpecification, type test for getVarFromInput
kushti Oct 21, 2024
8ae51e4
split in LSV6
kushti Oct 21, 2024
1fbd4e5
Update docs/LangSpec.md
kushti Oct 24, 2024
208a191
Update docs/LangSpec.md
kushti Oct 24, 2024
b074b28
Merge pull request #1016 from ergoplatform/i978
kushti Oct 24, 2024
06fff23
merging w. 6.0.0
kushti Oct 24, 2024
a160997
UnsignedBigInt support in DataSerializerSpecification
kushti Oct 31, 2024
fdf712e
ErgoTreeSpecification update
kushti Oct 31, 2024
dde7f6e
fixing DataJsonEncoderSpecification
kushti Oct 31, 2024
a18967c
SigmaTyperTest fix
kushti Oct 31, 2024
2d8af9d
adding UnsignedBigInt to JS reflection , pt1
kushti Nov 1, 2024
933b2cc
improving UnsignedBigInt support in JS
kushti Nov 1, 2024
3a5c6d6
JS tests fixed
kushti Nov 4, 2024
b1d2b17
toUnsigned test in LSV6
kushti Nov 4, 2024
f84bce5
toUnsignedMod test in LSV6, more tests in BOS
kushti Nov 4, 2024
1496770
tests for .toBytes, UnsignedBigInt support added to to new Numeric me…
kushti Nov 5, 2024
ac4bbbc
unsigned encoding, .toBytes & .toBits tests passing
kushti Nov 5, 2024
a87bfb3
bitwiseInverse
kushti Nov 5, 2024
77be8a6
more .toBytes and .toBits tests
kushti Nov 11, 2024
626edc8
bitwise or/and/xor and tests
kushti Nov 11, 2024
aa246c3
shiftLeft/shiftRight and tests
kushti Nov 11, 2024
7fdcdbd
more tests for shiftLeft/shiftRight
kushti Nov 11, 2024
9566177
LSV6 tests for UnsignedBigInt
kushti Nov 13, 2024
503f0c7
bitwiseInverse fix, tests fixes
kushti Nov 13, 2024
6a15e5f
expUnsigned test
kushti Nov 13, 2024
b0e41a8
mod ops tests
kushti Nov 14, 2024
8da5f89
_eval mathods removed
kushti Nov 14, 2024
11bc3d0
More descriptions, some code cleaning
kushti Nov 14, 2024
8c5172b
costing
kushti Nov 14, 2024
dd33642
arith test
kushti Nov 14, 2024
8109a28
embeddable type list / serializers versioning, code cleaning , toUnsi…
kushti Nov 14, 2024
ae0421a
fixing JS test
kushti Nov 14, 2024
aa3fbbd
JS test comment
kushti Nov 14, 2024
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*.fdb_latexmk
*.gz


yarn.lock
*.log
yarn.lock
Expand Down
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ ThisBuild / dynverSeparator := "-"

val bouncycastleBcprov = "org.bouncycastle" % "bcprov-jdk15on" % "1.66"

val scrypto = "org.scorexfoundation" %% "scrypto" % "2.3.0-4-a0bc6176-SNAPSHOT"
val scrypto = "org.scorexfoundation" %% "scrypto" % "3.0.0"
val scryptoDependency =
libraryDependencies += "org.scorexfoundation" %%% "scrypto" % "2.3.0-4-a0bc6176-SNAPSHOT"
libraryDependencies += "org.scorexfoundation" %%% "scrypto" % "3.0.0"

val scorexUtil = "org.scorexfoundation" %% "scorex-util" % "0.2.1"
val scorexUtilDependency =
Expand Down
1 change: 1 addition & 0 deletions core/js/src/main/scala/sigma/crypto/Platform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ object Platform {
case _: Boolean => tpe == SBoolean
case _: Byte | _: Short | _: Int | _: Long => tpe.isInstanceOf[SNumericType]
case _: BigInt => tpe == SBigInt
case _: UnsignedBigInt => tpe == SUnsignedBigInt
case _: String => tpe == SString
case _: GroupElement => tpe.isGroupElement
case _: SigmaProp => tpe.isSigmaProp
Expand Down
14 changes: 13 additions & 1 deletion core/js/src/main/scala/sigma/js/Isos.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package sigma.js

import sigma.{Coll, Colls}
import sigma.data.{CBigInt, Iso, RType}
import sigma.data.{CBigInt, CUnsignedBigInt, Iso, RType}

import java.math.BigInteger
import scala.reflect.ClassTag
Expand Down Expand Up @@ -42,6 +42,18 @@ object Isos {
}
}

implicit val isoUnsignedBigInt: Iso[js.BigInt, sigma.UnsignedBigInt] = new Iso[js.BigInt, sigma.UnsignedBigInt] {
override def to(x: js.BigInt): sigma.UnsignedBigInt = {
CUnsignedBigInt(new BigInteger(x.toString(10)))
}

override def from(x: sigma.UnsignedBigInt): js.BigInt = {
val bi = x.asInstanceOf[CUnsignedBigInt].wrappedValue
val s = bi.toString(10)
js.BigInt(s)
}
}

implicit val isoBigIntToLong: Iso[js.BigInt, Long] = new Iso[js.BigInt, Long] {
override def to(x: js.BigInt): Long = java.lang.Long.parseLong(x.toString(10))

Expand Down
3 changes: 3 additions & 0 deletions core/js/src/main/scala/sigma/js/Type.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ object Type extends js.Object {
/** Descriptor of ErgoScript type BigInt. */
val BigInt = new Type(sigma.BigIntRType)

/** Descriptor of ErgoScript type BigInt. */
val UnsignedBigInt = new Type(sigma.UnsignedBigIntRType)

/** Descriptor of ErgoScript type GroupElement. */
val GroupElement = new Type(sigma.GroupElementRType)

Expand Down
1 change: 1 addition & 0 deletions core/jvm/src/main/scala/sigma/crypto/Platform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ object Platform {
case _: Int => tpe == SInt
case _: Long => tpe == SLong
case _: BigInt => tpe == SBigInt
case _: UnsignedBigInt => tpe == SUnsignedBigInt
case _: String => tpe == SString // TODO v6.0: remove this case (see https://github.com/ScorexFoundation/sigmastate-interpreter/issues/905)
case _: GroupElement => tpe.isGroupElement
case _: SigmaProp => tpe.isSigmaProp
Expand Down
25 changes: 25 additions & 0 deletions core/shared/src/main/scala/sigma/Colls.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ trait Coll[@specialized A] {
*/
def apply(i: Int): A

/** The element at given index or None if there is no such element. Indices start at `0`.
*
* @param i the index
* @return the element at the given index, or None if there is no such element
*/
def get(i: Int): Option[A] = {
if (isDefinedAt(i)) {
Some(apply(i))
} else {
None
}
}

/** Tests whether this $coll contains given index.
*
* The implementations of methods `apply` and `isDefinedAt` turn a `Coll[A]` into
Expand Down Expand Up @@ -76,6 +89,18 @@ trait Coll[@specialized A] {
* produces a collection ((x0, y0), ..., (xK, yK)) where K = min(N, M) */
def zip[@specialized B](ys: Coll[B]): Coll[(A, B)]

/**
* @return true if first elements of this collection form given `ys` collection, false otherwise.
* E.g. [1,2,3] starts with [1,2]
*/
def startsWith(ys: Coll[A]): Boolean

/**
* @return true if last elements of this collection form given `ys` collection, false otherwise.
* E.g. [1,2,3] ends with [2,3]
*/
def endsWith(ys: Coll[A]): Boolean

/** Tests whether a predicate holds for at least one element of this collection.
* @param p the predicate used to test elements.
* @return `true` if the given predicate `p` is satisfied by at least one element of this collection, otherwise `false`
Expand Down
2 changes: 2 additions & 0 deletions core/shared/src/main/scala/sigma/Evaluation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ object Evaluation {
case SAny => AnyType
case SUnit => UnitType
case SBigInt => BigIntRType
case SUnsignedBigInt => UnsignedBigIntRType
case SBox => BoxRType
case SContext => ContextRType
case SGlobal => SigmaDslBuilderRType
Expand Down Expand Up @@ -67,6 +68,7 @@ object Evaluation {
case AnyType => SAny
case UnitType => SUnit
case BigIntRType => SBigInt
case UnsignedBigIntRType => SUnsignedBigInt
case GroupElementRType => SGroupElement
case AvlTreeRType => SAvlTree
case ot: OptionType[_] => SOption(rtypeToSType(ot.tA))
Expand Down
189 changes: 186 additions & 3 deletions core/shared/src/main/scala/sigma/SigmaDsl.scala
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package sigma

import java.math.BigInteger

import sigma.data._

/**
* Functions defined for 256-bit signed integers
* */
* Base class for signed 256-bits integers
*/
trait BigInt {
/** Convert this BigInt value to Byte.
* @throws ArithmeticException if overflow happens.
Expand Down Expand Up @@ -168,8 +167,167 @@ trait BigInt {
* @return a 256-bit signed integer whose value is (this >> n). `n` should be in 0..255 range (inclusive).
*/
def shiftRight(n: Int): BigInt

/**
* @return unsigned representation of this BigInt, or exception if its value is negative
*/
def toUnsigned: UnsignedBigInt

/**
* @return unsigned representation of this BigInt modulo `m`. Cryptographic mod operation is done, so result is
* always non-negative
*/
def toUnsignedMod(m: UnsignedBigInt): UnsignedBigInt
}

/**
* Base class for unsigned 256-bits integers
*/
trait UnsignedBigInt {
/** Convert this BigInt value to Byte.
* @throws ArithmeticException if overflow happens.
*/
def toByte: Byte

/** Convert this BigInt value to Short.
* @throws ArithmeticException if overflow happens.
*/
def toShort: Short

/** Convert this BigInt value to Int.
* @throws ArithmeticException if overflow happens.
*/
def toInt: Int

/** Convert this BigInt value to Int.
* @throws ArithmeticException if overflow happens.
*/
def toLong: Long

/** Returns a big-endian representation of this BigInt in a collection of bytes.
* For example, the value {@code 0x1213141516171819} would yield the
* byte array {@code {0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19}}.
* @since 2.0
*/
def toBytes: Coll[Byte]


/** Compares this numeric with that numeric for order. Returns a negative integer, zero, or a positive integer as the
* `this` is less than, equal to, or greater than `that`.
*/
def compareTo(that: UnsignedBigInt): Int

/** Returns a BigInt whose value is {@code (this + that)}.
*
* @param that value to be added to this BigInt.
* @return { @code this + that}
*/
def add(that: UnsignedBigInt): UnsignedBigInt
def +(that: UnsignedBigInt): UnsignedBigInt = add(that)

/** Returns a BigInt whose value is {@code (this - that)}.
*
* @param that value to be subtracted from this BigInt.
* @return { @code this - that}
*/
def subtract(that: UnsignedBigInt): UnsignedBigInt

def -(that: UnsignedBigInt): UnsignedBigInt = subtract(that)

/** Returns a BigInt whose value is {@code (this * that)}.
*
* @implNote An implementation may offer better algorithmic
* performance when { @code that == this}.
* @param that value to be multiplied by this BigInt.
* @return { @code this * that}
*/
def multiply(that: UnsignedBigInt): UnsignedBigInt
def *(that: UnsignedBigInt): UnsignedBigInt = multiply(that)

/** Returns a BigInt whose value is {@code (this / that)}.
*
* @param that value by which this BigInt is to be divided.
* @return { @code this / that}
* @throws ArithmeticException if { @code that} is zero.
*/
def divide(that: UnsignedBigInt): UnsignedBigInt
def /(that: UnsignedBigInt): UnsignedBigInt = divide(that)

/**
* Returns a BigInt whose value is {@code (this mod m}). This method
* differs from {@code remainder} in that it always returns a
* <i>non-negative</i> BigInteger.
*
* @param m the modulus.
* @return { @code this mod m}
* @throws ArithmeticException { @code m} &le; 0
* @see #remainder
*/
def mod(m: UnsignedBigInt): UnsignedBigInt
def %(m: UnsignedBigInt): UnsignedBigInt = mod(m)

/**
* Returns the minimum of this BigInteger and {@code val}.
*
* @param that value with which the minimum is to be computed.
* @return the BigInteger whose value is the lesser of this BigInteger and
* { @code val}. If they are equal, either may be returned.
*/
def min(that: UnsignedBigInt): UnsignedBigInt

/**
* Returns the maximum of this BigInteger and {@code val}.
*
* @param that value with which the maximum is to be computed.
* @return the BigInteger whose value is the greater of this and
* { @code val}. If they are equal, either may be returned.
*/
def max(that: UnsignedBigInt): UnsignedBigInt

/** Returns a BigInteger whose value is `(this & that)`.
* @param that value to be AND'ed with this BigInteger.
* @return `this & that`
*/
def and(that: UnsignedBigInt): UnsignedBigInt
def &(that: UnsignedBigInt): UnsignedBigInt = and(that)

/** Returns a BigInteger whose value is `(this | that)`.
*
* @param that value to be OR'ed with this BigInteger.
* @return `this | that`
*/
def or(that: UnsignedBigInt): UnsignedBigInt
def |(that: UnsignedBigInt): UnsignedBigInt = or(that)

def modInverse(m: UnsignedBigInt): UnsignedBigInt
def plusMod(that: UnsignedBigInt, m: UnsignedBigInt): UnsignedBigInt
def subtractMod(that: UnsignedBigInt, m: UnsignedBigInt): UnsignedBigInt
def multiplyMod(that: UnsignedBigInt, m: UnsignedBigInt): UnsignedBigInt

/**
* @return a big integer whose value is `this xor that`
*/
def xor(that: UnsignedBigInt): UnsignedBigInt

/**
* @return a 256-bit signed integer whose value is (this << n). The shift distance, n, may be negative,
* in which case this method performs a right shift. (Computes floor(this * 2n).)
*/
def shiftLeft(n: Int): UnsignedBigInt

/**
* @return a 256-bit signed integer whose value is (this >> n). Sign extension is performed. The shift distance, n,
* may be negative, in which case this method performs a left shift. (Computes floor(this / 2n).)
*/
def shiftRight(n: Int): UnsignedBigInt

def bitwiseInverse(): UnsignedBigInt

def toSigned(): BigInt
}



/** Base class for points on elliptic curves. */
trait GroupElement {
/** Checks if the provided element is an identity element. */
Expand All @@ -182,6 +340,12 @@ trait GroupElement {
*/
def exp(k: BigInt): GroupElement

/** Exponentiate this <code>GroupElement</code> to the given unsigned 256 bit integer.
* @param k The power.
* @return <code>this to the power of k</code>.
*/
def expUnsigned(k: UnsignedBigInt): GroupElement

/** Group operation. */
def multiply(that: GroupElement): GroupElement

Expand Down Expand Up @@ -588,6 +752,17 @@ trait Context {
*/
def getVar[T](id: Byte)(implicit cT: RType[T]): Option[T]

/**
* A variant of `getVar` to extract a context variable by id and type from any input
*
* @param inputIndex - input index
* @param id - context variable id
* @tparam T - expected type of the variable
* @return Some(value) if the variable is defined in the context AND has the given type.
* None otherwise
*/
def getVarFromInput[T](inputIndex: Short, id: Byte)(implicit cT: RType[T]): Option[T]

def vars: Coll[AnyValue]

/** Maximum version of ErgoTree currently activated on the network.
Expand Down Expand Up @@ -752,13 +927,21 @@ trait SigmaDslBuilder {
/** Create DSL big integer from existing `java.math.BigInteger`*/
def BigInt(n: BigInteger): BigInt

def UnsignedBigInt(n: BigInteger): UnsignedBigInt

/** Extract `java.math.BigInteger` from DSL's `BigInt` type*/
def toBigInteger(n: BigInt): BigInteger

/** Construct a new authenticated dictionary with given parameters and tree root digest. */
def avlTree(operationFlags: Byte, digest: Coll[Byte], keyLength: Int, valueLengthOpt: Option[Int]): AvlTree

/** Serializes the given `value` into bytes using the default serialization format. */
def serialize[T](value: T)(implicit cT: RType[T]): Coll[Byte]

/** Returns a byte-wise XOR of the two collections of bytes. */
def xor(l: Coll[Byte], r: Coll[Byte]): Coll[Byte]

/** Returns a number decoded from provided big-endian bytes array. */
def fromBigEndianBytes[T](bytes: Coll[Byte])(implicit cT: RType[T]): T
}

Loading
Loading