Package

sigmastate

interpreter

Permalink

package interpreter

Visibility
  1. Public
  2. All

Type Members

  1. case class CacheKey(ergoTreeBytes: Seq[Byte], vs: SigmaValidationSettings) extends Product with Serializable

    Permalink

    Represents keys in the cache of precompiled ErgoTrees for repeated evaluation.

    Represents keys in the cache of precompiled ErgoTrees for repeated evaluation. Note, SigmaValidationSettings are part of the key, which is important, because the output of compilation depends on validation settings.

    ergoTreeBytes

    serialized bytes of ErgoTree instance (returned by ErgoTreeSerializer)

    vs

    validation settings which where used for soft-forkable compilation.

  2. abstract class CommitmentHint extends Hint

    Permalink

    A family of hints which are about a correspondence between a public image of a secret image and prover's commitment to randomness ("a" in a sigma protocol).

  3. case class CompanionDesc(companion: ValueCompanion) extends OperationDesc with Product with Serializable

    Permalink

    Operation descriptor based on ValueCompanion.

  4. case class ContextExtension(values: Map[Byte, EvaluatedValue[_ <: SType]]) extends Product with Serializable

    Permalink

    User-defined variables to be put into context.

    User-defined variables to be put into context. Each variable is identified by id: Byte and can be accessed from a script using getVar[T](id) operation. The value of the variable is represented by sigmastate.Values.Constant instance, which contains both data value and SType descriptor. The descriptor is checked against the type T expected in the script operation. If the types don't match, exception is thrown and the box spending (protected by the script) fails.

    values

    internal container of the key-value pairs

  5. class CostAccumulator extends AnyRef

    Permalink

    Implements finite state machine with stack of graph blocks (scopes), which correspond to lambdas and thunks.

    Implements finite state machine with stack of graph blocks (scopes), which correspond to lambdas and thunks. It accepts messages: startScope(), endScope(), add(), reset() At any time totalCost is the currently accumulated cost.

  6. class CostCounter extends AnyRef

    Permalink

    Encapsulate simple monotonic (add only) counter with reset.

  7. abstract class CostDetails extends AnyRef

    Permalink

    Abstract representation of cost results obtained during evaluation.

  8. abstract class CostItem extends AnyRef

    Permalink

    An item in the cost accumulation trace of a sigmastate.Values.ErgoTree evaluation.

  9. case class CostedProverResult(proof: Array[Byte], extension: ContextExtension, cost: Long) extends ProverResult with Product with Serializable

    Permalink
  10. class ErgoTreeEvaluator extends AnyRef

    Permalink

    Implements a simple and fast direct-style interpreter of ErgoTrees.

    Implements a simple and fast direct-style interpreter of ErgoTrees.

    ### Motivation ErgoTree is a simple declarative intermediate representation for Ergo contracts. It is designed to be compact in serialized form and directly executable, i.e. no additional transformation is necessary before it can be efficiently executed.

    This class implements a big-step recursive interpreter that works directly with ErgoTree HOAS. Because of this the evaluator is very simple and follows denotational semantics of ErgoTree (see https://ergoplatform.org/docs/ErgoTree.pdf). Or, the other way around, this implementation of ErgoTreeEvaluator is purely functional with immutable data structures and can be used as definition of ErgoTree's semantics.

    ### Implementation ErgoTreeEvaluator takes ErgoTree directly as it is deserialized as part of a transaction. No additional transformation is performed. ErgoTree is interpreted directly and all the intermediate data is stored in the runtime types. The runtime types are such types as special.collection.Coll, special.sigma.SigmaProp, special.sigma.AvlTree, BigInt, etc. It also use immutable Map to keep current DataEnv of computed ValDefs, as result only addition is used from the map, and deletion is essentially a garbage collection.

    ### Performance Since this interpreter directly works with SigmaDsl types (Coll, BigInt, SigmaProp etc), it turns out to be very fast. Since it also does JIT style costing instead of AOT style, it is 5-6x faster than existing implementation.

  11. case class EvalSettings(isMeasureOperationTime: Boolean, isMeasureScriptTime: Boolean, isDebug: Boolean = false, isLogEnabled: Boolean = false, costTracingEnabled: Boolean = false, profilerOpt: Option[Profiler] = None, isTestRun: Boolean = false, printTestVectors: Boolean = false) extends Product with Serializable

    Permalink

    Configuration parameters of the evaluation run.

  12. case class FixedCostItem(opDesc: OperationDesc, costKind: FixedCost) extends CostItem with Product with Serializable

    Permalink

    An item in the cost accumulation trace of a sigmastate.Values.ErgoTree evaluation.

    An item in the cost accumulation trace of a sigmastate.Values.ErgoTree evaluation. Represents cost of simple operation. Used for debugging, testing and profiling of costing.

    opDesc

    descriptor of the ErgoTree operation

    costKind

    kind of the cost to be added to accumulator

  13. case class GivenCost(cost: Int, actualTimeNano: Option[Long] = None) extends CostDetails with Product with Serializable

    Permalink

    Result of cost evaluation represented using simple given value.

    Result of cost evaluation represented using simple given value. Used to represent cost of AOT costing.

    cost

    the given value of the total cost

    actualTimeNano

    measured time of execution (if some)

  14. trait Hint extends AnyRef

    Permalink

    A hint for a prover which helps the prover to prove a statement.

    A hint for a prover which helps the prover to prove a statement. For example, if the statement is "pk1 && pk2", and the prover knows only a secret for the public key pk1, the prover fails on proving without a hint. But if the prover knows that pk2 is known to another party, the prover may prove the statement (with an empty proof for "pk2").

  15. case class HintsBag(hints: Seq[Hint]) extends Product with Serializable

    Permalink

    Collection of hints to be used by a prover

    Collection of hints to be used by a prover

    hints

    - hints stored in the bag

  16. trait Interpreter extends ScorexLogging

    Permalink
  17. trait InterpreterContext extends AnyRef

    Permalink

    Base class of the context passed to verifier and prover.

    Base class of the context passed to verifier and prover.

    See also

    sigmastate.interpreter.Interpreter

  18. case class MethodCallCostItem(items: CostDetails) extends CostItem with Product with Serializable

    Permalink

    An item in the cost accumulation trace of a sigmastate.Values.ErgoTree evaluation.

    An item in the cost accumulation trace of a sigmastate.Values.ErgoTree evaluation. Represents cost of MethodCall operation. Used for debugging, testing and profiling of costing.

    items

    cost details obtained as part of MethodCall evaluation

  19. case class MethodDesc(method: SMethod) extends OperationDesc with Product with Serializable

    Permalink

    Operation descriptor based on SMethod.

  20. case class NamedDesc(operationName: String) extends OperationDesc with Product with Serializable

    Permalink

    Operation descriptor based on name.

  21. case class OperationCostInfo[C <: CostKind](costKind: C, opDesc: OperationDesc) extends Product with Serializable

    Permalink

    Operation costing descriptors combined together.

  22. abstract class OperationDesc extends AnyRef

    Permalink

    Each costable operation is described in one of the following ways: 1) using ValueCompanion - operation with separate node class 2) using SMethod - operation represented as method.

    Each costable operation is described in one of the following ways: 1) using ValueCompanion - operation with separate node class 2) using SMethod - operation represented as method. 3) using string name - intermediate sub-operation present in cost model, but which is not a separate operation of ErgoTree.

  23. case class OwnCommitment(image: SigmaBoolean, secretRandomness: BigInteger, commitment: FirstProverMessage, position: NodePosition) extends CommitmentHint with Product with Serializable

    Permalink

    A hint which a commitment to randomness associated with a public image of a secret, as well as randomness itself.

    A hint which a commitment to randomness associated with a public image of a secret, as well as randomness itself. Please note that this randomness should be kept in secret by the prover.

    image

    - image of a secret

    secretRandomness

    - randomness

    commitment

    - commitment to randomness used while proving knowledge of the secret

  24. class PrecompiledScriptProcessor extends AnyRef

    Permalink

    Script processor which holds pre-compiled reducers for the given scripts.

    Script processor which holds pre-compiled reducers for the given scripts. This class is thread-safe.

  25. case class PrecompiledScriptReducer(scriptBytes: Seq[Byte])(implicit IR: IRContext) extends ScriptReducer with Product with Serializable

    Permalink

    This class implements optimized reduction of the given pre-compiled script.

    This class implements optimized reduction of the given pre-compiled script. Pre-compilation of the necessary graphs is performed as part of constructor and the graphs are stored in the given IR instance.

    The code make the following assumptions: 1) the given script doesn't contain both sigmastate.utxo.DeserializeContext and sigmastate.utxo.DeserializeRegister

    The code should correspond to reduceToCrypto method, but some operations may be optimized due to assumptions above.

  26. case class ProcessorStats(cacheStats: CacheStats, predefHits: Seq[Int]) extends Product with Serializable

    Permalink

    Statistics of ScriptProcessor operations.

    Statistics of ScriptProcessor operations.

    cacheStats

    cache statistics such as hits and misses

    predefHits

    one hit counter for each predefined script

  27. trait ProverInterpreter extends Interpreter with ProverUtils with AttributionCore

    Permalink

    Interpreter with enhanced functionality to prove statements.

  28. class ProverResult extends AnyRef

    Permalink

    Proof of correctness of tx spending

  29. trait ProverUtils extends Interpreter

    Permalink
  30. case class RealCommitment(image: SigmaBoolean, commitment: FirstProverMessage, position: NodePosition) extends CommitmentHint with Product with Serializable

    Permalink

    A hint which contains a commitment to randomness associated with a public image of a secret.

    A hint which contains a commitment to randomness associated with a public image of a secret.

    image

    - image of a secret

    commitment

    - commitment to randomness used while proving knowledge of the secret

  31. case class RealSecretProof(image: SigmaBoolean, challenge: Challenge, uncheckedTree: UncheckedTree, position: NodePosition) extends SecretProven with Product with Serializable

    Permalink

    A hint which contains a proof-of-knowledge for a secret associated with its public image "image", with also the mark that the proof is real.

  32. case class ScriptProcessorSettings(predefScripts: Seq[CacheKey], maxCacheSize: Int = 1000, recordCacheStats: Boolean = false, reportingInterval: Int = 100) extends Product with Serializable

    Permalink

    Settings to configure script processor.

    Settings to configure script processor.

    predefScripts

    collection of scripts to ALWAYS pre-compile (each given by ErgoTree bytes)

    maxCacheSize

    maximum number of entries in the cache

    recordCacheStats

    if true, then cache statistics is recorded

    reportingInterval

    number of cache load operations between two reporting events

  33. trait ScriptReducer extends AnyRef

    Permalink

    A reducer which represents precompiled script reduction function.

    A reducer which represents precompiled script reduction function. The function takes script execution context and produces the ReductionResult, which contains both sigma proposition and the approximation of the cost taken by the reduction.

  34. abstract class SecretProven extends Hint

    Permalink

    A hint which is indicating that a secret associated with its public image "image" is already proven.

  35. case class SeqCostItem(opDesc: OperationDesc, costKind: PerItemCost, nItems: Int) extends CostItem with Product with Serializable

    Permalink

    An item in the cost accumulation trace of a sigmastate.Values.ErgoTree evaluation.

    An item in the cost accumulation trace of a sigmastate.Values.ErgoTree evaluation. Represents cost of a sequence of operation. Used for debugging, testing and profiling of costing.

    opDesc

    descriptor of the ErgoTree operation

    costKind

    descriptor of the cost added to accumulator

    nItems

    number of items in the sequence

  36. case class SimulatedCommitment(image: SigmaBoolean, commitment: FirstProverMessage, position: NodePosition) extends CommitmentHint with Product with Serializable

    Permalink

    A hint which contains a commitment to randomness associated with a public image of a secret.

    A hint which contains a commitment to randomness associated with a public image of a secret.

    image

    - image of a secret

    commitment

    - commitment to randomness used while proving knowledge of the secret

  37. case class SimulatedSecretProof(image: SigmaBoolean, challenge: Challenge, uncheckedTree: UncheckedTree, position: NodePosition) extends SecretProven with Product with Serializable

    Permalink

    A hint which contains a proof-of-knowledge for a secret associated with its public image "image", with also the mark that the proof is real.

  38. case class TracedCost(trace: Seq[CostItem], actualTimeNano: Option[Long] = None) extends CostDetails with Product with Serializable

    Permalink

    Detailed results of cost evaluation represented by trace.

    Detailed results of cost evaluation represented by trace. NOTE: the trace is obtained during execution of ErgoTree operations.

    trace

    accumulated trace of all cost items (empty for AOT costing)

    actualTimeNano

    measured time of execution (if some)

  39. case class TypeBasedCostItem(opDesc: OperationDesc, costKind: TypeBasedCost, tpe: SType) extends CostItem with Product with Serializable

    Permalink

    An item in the cost accumulation trace of a sigmastate.Values.ErgoTree evaluation.

    An item in the cost accumulation trace of a sigmastate.Values.ErgoTree evaluation. Represents cost of an operation which depends on type (e.g. type of arguments). Used for debugging, testing and profiling of costing.

    opDesc

    descriptor of the ErgoTree operation

    costKind

    type based cost descriptor added to accumulator

    tpe

    concrete type on this the operation is executed

    See also

    sigmastate.LE, sigmastate.GT

Value Members

  1. object ContextExtension extends Serializable

    Permalink
  2. object CostDetails

    Permalink
  3. object CryptoConstants

    Permalink
  4. object CryptoFunctions

    Permalink
  5. object ErgoTreeEvaluator

    Permalink
  6. object FixedCostItem extends Serializable

    Permalink
  7. object HintsBag extends Serializable

    Permalink
  8. object Interpreter

    Permalink
  9. object PrecompiledScriptProcessor

    Permalink
  10. object ProverResult

    Permalink
  11. object SeqCostItem extends Serializable

    Permalink
  12. object TypeBasedCostItem extends Serializable

    Permalink
  13. object WhenSoftForkReducer extends ScriptReducer with Product with Serializable

    Permalink

    Used as a fallback reducer when precompilation failed due to soft-fork condition.

Ungrouped