package interpreter
- Alphabetic
- Public
- All
Type Members
-
abstract
class
CommitmentHint extends Hint
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).
-
case class
CompanionDesc(companion: ValueCompanion) extends OperationDesc with Product with Serializable
Operation descriptor based on ValueCompanion.
-
case class
ContextExtension(values: Map[Byte, EvaluatedValue[_ <: SType]]) extends Product with Serializable
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 usinggetVar[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 typeT
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
-
class
CostAccumulator extends AnyRef
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. -
class
CostCounter extends AnyRef
Encapsulate simple monotonic (add only) counter with reset.
-
abstract
class
CostDetails extends AnyRef
Abstract representation of cost results obtained during evaluation.
-
abstract
class
CostItem extends AnyRef
An item in the cost accumulation trace of a sigmastate.Values.ErgoTree evaluation.
- case class CostedProverResult(proof: Array[Byte], extension: ContextExtension, cost: Long) extends ProverResult with Product with Serializable
-
class
ErgoTreeEvaluator extends AnyRef
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 sigma.Coll, sigma.SigmaProp, 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.
-
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, evaluationMode: Option[EvaluationMode] = None, scriptCostLimitInEvaluator: Int = 1000000) extends Product with Serializable
Configuration parameters of the evaluation run.
-
case class
FixedCostItem(opDesc: OperationDesc, costKind: FixedCost) extends CostItem with Product with Serializable
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
-
case class
GivenCost(cost: JitCost, actualTimeNano: Option[Long] = None) extends CostDetails with Product with Serializable
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)
-
trait
Hint extends AnyRef
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").
-
case class
HintsBag(hints: Seq[Hint]) extends Product with Serializable
Collection of hints to be used by a prover
Collection of hints to be used by a prover
- hints
- hints stored in the bag
-
trait
Interpreter extends AnyRef
Base (verifying) interpreter of ErgoTrees.
Base (verifying) interpreter of ErgoTrees. Can perform: - ErgoTree evaluation (aka reduction) to sigma proposition (aka SigmaBoolean) in the given context. - verification of ErgoTree in the given context.
NOTE: In version v5.0 this interpreter contains two alternative implementations. 1) Old implementation from v4.x which is based on AOT costing 2) New implementation added in v5.0 which is based on JIT costing (see methods with JITC suffix).
Both implementations are equivalent in v5.0, but have different performance as result they produce different cost estimations.
The interpreter has evaluationMode which defines how it should execute scripts.
- See also
verify, fullReduction
-
trait
InterpreterContext extends AnyRef
Base class of the context passed to verifier and prover.
Base class of the context passed to verifier and prover.
-
case class
JitEvalResult[A](value: A, cost: JitCost) extends Product with Serializable
Result of JITC evaluation with costing.
-
case class
MethodCallCostItem(items: CostDetails) extends CostItem with Product with Serializable
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
-
case class
MethodDesc(method: SMethod) extends OperationDesc with Product with Serializable
Operation descriptor based on SMethod.
-
case class
NamedDesc(operationName: String) extends OperationDesc with Product with Serializable
Operation descriptor based on name.
-
case class
OperationCostInfo[C <: CostKind](costKind: C, opDesc: OperationDesc) extends Product with Serializable
Operation costing descriptors combined together.
-
abstract
class
OperationDesc extends AnyRef
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.
-
case class
OwnCommitment(image: SigmaLeaf, secretRandomness: BigInteger, commitment: FirstProverMessage, position: NodePosition) extends CommitmentHint with Product with Serializable
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
-
trait
ProverInterpreter extends Interpreter with ProverUtils
Interpreter with enhanced functionality to prove statements.
-
class
ProverResult extends AnyRef
Proof of correctness of tx spending
- trait ProverUtils extends Interpreter
-
case class
RealCommitment(image: SigmaLeaf, commitment: FirstProverMessage, position: NodePosition) extends CommitmentHint with Product with Serializable
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
-
case class
RealSecretProof(image: SigmaLeaf, challenge: Challenge, uncheckedTree: UncheckedTree, position: NodePosition) extends SecretProven with Product with Serializable
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.
-
abstract
class
SecretProven extends Hint
A hint which is indicating that a secret associated with its public image "image" is already proven.
-
case class
SeqCostItem(opDesc: OperationDesc, costKind: PerItemCost, nItems: Int) extends CostItem with Product with Serializable
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
-
case class
SimulatedCommitment(image: SigmaLeaf, commitment: FirstProverMessage, position: NodePosition) extends CommitmentHint with Product with Serializable
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
-
case class
SimulatedSecretProof(image: SigmaLeaf, challenge: Challenge, uncheckedTree: UncheckedTree, position: NodePosition) extends SecretProven with Product with Serializable
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 simulated (not real).
-
case class
TracedCost(trace: Seq[CostItem], actualTimeNano: Option[Long] = None) extends CostDetails with Product with Serializable
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)
-
case class
TypeBasedCostItem(opDesc: OperationDesc, costKind: TypeBasedCost, tpe: SType) extends CostItem with Product with Serializable
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
Value Members
- object ContextExtension extends Serializable
- object CostDetails
- object ErgoTreeEvaluator
- object EvalSettings extends Serializable
- object FixedCostItem extends Serializable
- object HintsBag extends Serializable
- object Interpreter
- object ProverResult
- object SeqCostItem extends Serializable
- object TypeBasedCostItem extends Serializable