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.0] Support Header (de)serialization #972

Merged
merged 15 commits into from
Sep 2, 2024
2 changes: 1 addition & 1 deletion core/shared/src/main/scala/sigma/SigmaDsl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ trait Header {
def unparsedBytes: Coll[Byte]

/**
* @return bytes without proof of work, needed for working to get the proof on
* @return header bytes without proof of work, a PoW is generated over them
*/
def serializeWithoutPoW: Coll[Byte]

Expand Down
12 changes: 6 additions & 6 deletions data/shared/src/main/scala/org/ergoplatform/ErgoHeader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import sigma.serialization.{GroupElementSerializer, SigmaByteReader, SigmaByteWr
* @param d - distance between pseudo-random number, corresponding to nonce `n` and a secret,
* corresponding to `pk`. The lower `d` is, the harder it was to find this solution.
*/
case class AutolykosSolution(pk: EcPointType,
w: EcPointType,
n: Array[Byte],
d: BigInt) {
class AutolykosSolution(val pk: EcPointType,
val w: EcPointType,
val n: Array[Byte],
val d: BigInt) {
aslesarenko marked this conversation as resolved.
Show resolved Hide resolved

val encodedPk: Array[Byte] = GroupElementSerializer.toBytes(pk)

Expand Down Expand Up @@ -52,7 +52,7 @@ object AutolykosSolution {
val nonce = r.getBytes(8)
val dBytesLength = r.getUByte()
val d = BigInt(BigIntegers.fromUnsignedByteArray(r.getBytes(dBytesLength)))
AutolykosSolution(pk, w, nonce, d)
new AutolykosSolution(pk, w, nonce, d)
}
}

Expand All @@ -66,7 +66,7 @@ object AutolykosSolution {
override def parse(r: SigmaByteReader): AutolykosSolution = {
val pk = GroupElementSerializer.parse(r)
val nonce = r.getBytes(8)
AutolykosSolution(pk, wForV2, nonce, dForV2)
new AutolykosSolution(pk, wForV2, nonce, dForV2)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion data/shared/src/main/scala/sigma/data/CHeader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ object CHeader {
votes: Coll[Byte],
unparsedBytes: Coll[Byte]): CHeader = {

val solution = AutolykosSolution(
val solution = new AutolykosSolution(
minerPk.asInstanceOf[CGroupElement].wrappedValue,
powOnetimePk.asInstanceOf[CGroupElement].wrappedValue,
powNonce.toArray,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ trait SerializationSpecification extends AnyPropSpec
}
withVersion match {
case Some(ver) =>
VersionContext.withVersions(ver, 1) {
VersionContext.withVersions(ver, 0) {
test()
}
case None =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class DataJsonEncoderSpecification extends SerializationSpecification {

withVersion match {
case Some(ver) =>
VersionContext.withVersions(ver, 1) {
VersionContext.withVersions(ver, 0) {
test()
}
case None =>
Expand Down Expand Up @@ -233,7 +233,7 @@ class DataJsonEncoderSpecification extends SerializationSpecification {
}

if (tpe == SHeader) {
VersionContext.withVersions(VersionContext.V6SoftForkVersion, 1) {
VersionContext.withVersions(VersionContext.V6SoftForkVersion, 0) {
test()
}
} else {
Expand Down
Loading