Skip to content

Commit

Permalink
test vectors for Blake2b256 and Long -> BigInt
Browse files Browse the repository at this point in the history
  • Loading branch information
kushti committed Jul 31, 2024
1 parent ba878b8 commit b41d16c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ class HeaderWithoutPow(val version: Byte, // 1 byte
def toHeader(powSolution: AutolykosSolution, bytes: Array[Byte]): ErgoHeader =
ErgoHeader(version, parentId, ADProofsRoot, stateRoot, transactionsRoot, timestamp,
nBits, height, extensionRoot, powSolution, votes, unparsedBytes, bytes)

override def toString: String = {
s"HeaderWithoutPow($version, $parentId, ${bytesToId(ADProofsRoot)}, ${bytesToId(stateRoot)}, " +
s"${bytesToId(transactionsRoot)}, $timestamp, $nBits, $height, ${bytesToId(extensionRoot)}, ${bytesToId(votes)}, " +
s"${bytesToId(unparsedBytes)} )"
}
}

object HeaderWithoutPow {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import scorex.util.encode.Base58
import sigma.Colls
import sigma.VersionContext.V6SoftForkVersion
import sigma.VersionContext
import sigma.crypto.CryptoConstants
import sigma.data.{CAND, CAvlTree, ProveDlog, SigmaBoolean, TrivialProp}
import sigma.interpreter.ContextExtension
import sigma.util.Extensions.IntOps
Expand Down Expand Up @@ -436,6 +435,24 @@ class TestingInterpreterSpecification extends CompilerTestingCommons
verifier.verify(prop3, env, proof, challenge).map(_._1).getOrElse(false) shouldBe false
}

property("blake2b - test vector") {
testEval(
""" {
| val input = fromBase16("68656c6c6f20776f726c64")
| val output = fromBase16("256c83b297114d201b30179f3f0ef0cace9783622da5974326b436178aeef610")
| blake2b256(input) == output
| }""".stripMargin)
}

property("blake2b - test vector #2") {
testEval(
""" {
| val input = fromBase16("02ac2101807f0000ca01ff0119db227f202201007f62000177a080005d440896d05d3f80dcff7f5e7f59007294c180808d0158d1ff6ba10000f901c7f0ef87dcfff17fffacb6ff7f7f1180d2ff7f1e24ffffe1ff937f807f0797b9ff6ebdae007e5c8c00b8403d3701557181c8df800001b6d5009e2201c6ff807d71808c00019780d085adb3fcdbc0b3441480887f80007f4b01cf7f013ff1ffff564a0000b9a54f00770e807f41ff88c00240000080c02500000000")
| val output = fromBase16("bdb84cda5b105c3eb522857b50a0882f88ed5bb3cc8cf3325a1edf7eeb6a0954")
| blake2b256(input) == output
| }""".stripMargin)
}

property("passing a lambda argument") {
// single expression
testEval(
Expand Down
6 changes: 6 additions & 0 deletions sdk/js/src/test/scala/org/ergoplatform/sdk/js/IsosSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ class IsosSpec extends IsosSpecBase with sdk.generators.ObjectGenerators {
}
}

property("Iso.isoBigIntToLong - test vector") {
val l = 4928911477310178288L
val js = sigma.js.Isos.isoBigIntToLong.from(l)
l.toString shouldBe js.toString()
}

property("Iso.isoAmount") {
forAll { (c: Long) =>
roundtrip(DataIsos.isoAmount)(c)
Expand Down

0 comments on commit b41d16c

Please sign in to comment.