Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::avm2::simulation::Ecc Class Reference

#include <ecc.hpp>

Inheritance diagram for bb::avm2::simulation::Ecc:
bb::avm2::simulation::EccInterface

Public Member Functions

 Ecc (ExecutionIdManagerInterface &execution_id_manager, GreaterThanInterface &gt, ToRadixInterface &to_radix, EventEmitterInterface< EccAddEvent > &ecadd_event_emitter, EventEmitterInterface< ScalarMulEvent > &scalar_mul_event_emitter, EventEmitterInterface< EccAddMemoryEvent > &add_memory_event_emitter)
 
EmbeddedCurvePoint add (const EmbeddedCurvePoint &p, const EmbeddedCurvePoint &q) override
 Adds Grumpkin curve points P and Q and emits an EccAddEvent. Corresponds to the non-memory aware subtrace ecc.pil.
 
EmbeddedCurvePoint scalar_mul (const EmbeddedCurvePoint &point, const FF &scalar) override
 Performs scalar multiplication of an FF value with a Grumpkin curve point using the double and add algorithm, and emits a ScalarMulEvent. Corresponds to the non-memory aware subtrace scalar_mul.pil.
 
void add (MemoryInterface &memory, const EmbeddedCurvePoint &p, const EmbeddedCurvePoint &q, MemoryAddress dst_address) override
 Adds Grumpkin curve points P and Q and emits an EccAddMemoryEvent. Corresponds to the memory aware subtrace ecc_mem.pil (namespace ecc_add_mem).
 
- Public Member Functions inherited from bb::avm2::simulation::EccInterface
virtual ~EccInterface ()=default
 

Private Attributes

EventEmitterInterface< EccAddEvent > & add_events
 
EventEmitterInterface< ScalarMulEvent > & scalar_mul_events
 
EventEmitterInterface< EccAddMemoryEvent > & add_memory_events
 
GreaterThanInterfacegt
 
ToRadixInterfaceto_radix
 
ExecutionIdManagerInterfaceexecution_id_manager
 

Detailed Description

Definition at line 15 of file ecc.hpp.

Constructor & Destructor Documentation

◆ Ecc()

bb::avm2::simulation::Ecc::Ecc ( ExecutionIdManagerInterface execution_id_manager,
GreaterThanInterface gt,
ToRadixInterface to_radix,
EventEmitterInterface< EccAddEvent > &  ecadd_event_emitter,
EventEmitterInterface< ScalarMulEvent > &  scalar_mul_event_emitter,
EventEmitterInterface< EccAddMemoryEvent > &  add_memory_event_emitter 
)
inline

Definition at line 17 of file ecc.hpp.

Member Function Documentation

◆ add() [1/2]

EmbeddedCurvePoint bb::avm2::simulation::Ecc::add ( const EmbeddedCurvePoint p,
const EmbeddedCurvePoint q 
)
overridevirtual

Adds Grumpkin curve points P and Q and emits an EccAddEvent. Corresponds to the non-memory aware subtrace ecc.pil.

Exceptions
Unexpectedexception if points are not on the curve or not normalized. Note: This function assumes that the points p and q are on the curve. You should only use this function internally if you can guarantee this. Otherwise it is called via the opcode ECADD, see the overloaded function Ecc::add (which performs the curve check).
Parameters
pThe point P.
qThe point Q.
Returns
The result of P + Q.

Implements bb::avm2::simulation::EccInterface.

Definition at line 30 of file ecc.cpp.

◆ add() [2/2]

void bb::avm2::simulation::Ecc::add ( MemoryInterface memory,
const EmbeddedCurvePoint p,
const EmbeddedCurvePoint q,
MemoryAddress  dst_address 
)
overridevirtual

Adds Grumpkin curve points P and Q and emits an EccAddMemoryEvent. Corresponds to the memory aware subtrace ecc_mem.pil (namespace ecc_add_mem).

Exceptions
InternalEccExceptionif
  • the memory write is out of bounds
  • either point is not on the curve Note: The memory reads are handled by dispatching in execution (Execution::ecc_add(), #[DISPATCH_TO_ECC_ADD]).
Parameters
memoryThe memory interface.
pThe point P.
qThe point Q.
dst_addressThe memory address to write the result of P + Q to.

Implements bb::avm2::simulation::EccInterface.

Definition at line 118 of file ecc.cpp.

◆ scalar_mul()

EmbeddedCurvePoint bb::avm2::simulation::Ecc::scalar_mul ( const EmbeddedCurvePoint point,
const FF scalar 
)
overridevirtual

Performs scalar multiplication of an FF value with a Grumpkin curve point using the double and add algorithm, and emits a ScalarMulEvent. Corresponds to the non-memory aware subtrace scalar_mul.pil.

Exceptions
Unexpectedexception if the input point is not on the curve. Note: This function assumes that the point is on the curve. As this should only be used internally, it is treated as a catastrophic failure if the point is not on the curve. Note: Though Grumpkin scalars are in Fq, not Fr (= our FF), our use cases require FF values. This is safe because |Fr| < |Fq|, so we cannot multiply by invalid scalars.
Parameters
pointThe point P.
scalarThe FF scalar.
Returns
The result of scalar * P.

Implements bb::avm2::simulation::EccInterface.

Definition at line 62 of file ecc.cpp.

Member Data Documentation

◆ add_events

EventEmitterInterface<EccAddEvent>& bb::avm2::simulation::Ecc::add_events
private

Definition at line 39 of file ecc.hpp.

◆ add_memory_events

EventEmitterInterface<EccAddMemoryEvent>& bb::avm2::simulation::Ecc::add_memory_events
private

Definition at line 41 of file ecc.hpp.

◆ execution_id_manager

ExecutionIdManagerInterface& bb::avm2::simulation::Ecc::execution_id_manager
private

Definition at line 44 of file ecc.hpp.

◆ gt

GreaterThanInterface& bb::avm2::simulation::Ecc::gt
private

Definition at line 42 of file ecc.hpp.

◆ scalar_mul_events

EventEmitterInterface<ScalarMulEvent>& bb::avm2::simulation::Ecc::scalar_mul_events
private

Definition at line 40 of file ecc.hpp.

◆ to_radix

ToRadixInterface& bb::avm2::simulation::Ecc::to_radix
private

Definition at line 43 of file ecc.hpp.


The documentation for this class was generated from the following files: