This PR contains new Global.deserializeRaw method which is allowing to deserialize a typed object from underlying type bytes (see below).
Types supported are:
Short - deserialization is from 2 (big-endian) bytes (Short JVM type big-endian serialization)
Int - deserialization is from 4 (big-endian) bytes (Int JVM type big-endian serialization)
Long - synonym of Global.byteArrayToLong
BigInt - synonym of Global.byteArrayToBigInt
Box - deserialization is from ErgoBox bytes (ErgoBox.sigmaSerializer.toBytes(box))
GroupElement - deserialization works for serialized secp256k1 points (33 bytes)
SigmaProp - deserialization works only for fully evaluated (cryptographic) trees (e.g. SigmaPropConstant(CSigmaProp(CAND(Seq(dlogSecrets(0).publicImage, dhSecrets(0).publicImage))))
AvlTree - deserialization works for avl tree fields (digest, modification flags, key length, value lentgh), see AvlTreeData.serializer.serialize() for serialization
Header - deserialization works for ErgoHeader bytes
examples:
{
val ba = fromBase16("028a5b7f7f7f7f7f7f6c");
val b = Global.deserialize[BigInt](ba)
b == byteArrayToBigInt(ba)
}
{
val ba = getVar[Coll[Byte]](21).get
val prop = Global.deserialize[SigmaProp](ba)
prop
}
The method is called deserializeRaw as we may have deserializeTyped as well in future (to deserialize data with type information attached, e.g. Coll[Header])
This PR contains new Global.deserializeRaw method which is allowing to deserialize a typed object from underlying type bytes (see below).
Types supported are:
Global.byteArrayToLong
Global.byteArrayToBigInt
ErgoBox
bytes (ErgoBox.sigmaSerializer.toBytes(box)
)SigmaPropConstant(CSigmaProp(CAND(Seq(dlogSecrets(0).publicImage, dhSecrets(0).publicImage))))
AvlTreeData.serializer.serialize()
for serializationexamples:
The method is called
deserializeRaw
as we may havedeserializeTyped
as well in future (to deserialize data with type information attached, e.g.Coll[Header]
)