PrepareForSerialization

scalus.uplc.transform.PrepareForSerialization

Prepares a UPLC term for flat serialization by replacing BLS12-381 constants that cannot be directly flat-encoded with equivalent runtime expressions.

Standalone BLS constants become uncompress(compressed_bytes):

  • Const(BLS12_381_G1_Element(v))Apply(Builtin(Bls12_381_G1_uncompress), Const(ByteString(compress(v))))

List constants containing BLS elements are unrolled into MkCons chains:

  • Const(List(G1, [v1, v2]))MkCons(uncompress(compress(v1)), MkCons(uncompress(compress(v2)), Const(List(G1, [])))) The empty List[G1Element] at the end is flat-serializable because the stub Flat instance for BLS types is never invoked for empty lists.

Applied automatically before flat encoding in DeBruijnedProgram.flatEncoded.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def apply(term: Term): Term