11class InternalEccException :
public std::runtime_error {
13 using std::runtime_error::runtime_error;
28 BB_ASSERT((p.
x() == 0) && (p.
y() == 0),
"Point p is not normalized");
31 BB_ASSERT((q.
x() == 0) && (q.
y() == 0),
"Point q is not normalized");
35 add_events.emit({ .p = p, .q = q, .result = result });
45 BB_ASSERT(point.
on_curve(),
"Point must be on the curve for scalar multiplication");
48 auto bits =
to_radix.to_le_bits(scalar, 254).first;
58 intermediate_states[0] = { result, temp, bit };
60 for (
size_t i = 1; i < 254; i++) {
62 temp =
add(temp, temp);
65 result =
add(result, temp);
67 intermediate_states[i] = { result, temp, bit };
71 .intermediate_states =
std::move(intermediate_states),
82 uint16_t space_id =
memory.get_space_id();
89 uint64_t max_write_address =
static_cast<uint64_t
>(
dst_address) + 2;
91 throw InternalEccException(
"dst address out of range");
95 throw InternalEccException(
"One of the points is not on the curve");
109 .space_id = space_id,
114 }
catch (
const InternalEccException& e) {
119 .space_id = space_id,
124 throw EccException(
"Add failed: " + std::string(e.what()));
#define BB_ASSERT(expression,...)
#define AVM_HIGHEST_MEM_ADDRESS
static const StandardAffinePoint & infinity()
constexpr bool is_infinity() const noexcept
constexpr const BaseField & x() const noexcept
constexpr const BaseField & y() const noexcept
constexpr bool on_curve() const noexcept
EventEmitterInterface< ScalarMulEvent > & scalar_mul_events
EmbeddedCurvePoint add(const EmbeddedCurvePoint &p, const EmbeddedCurvePoint &q) override
EmbeddedCurvePoint scalar_mul(const EmbeddedCurvePoint &point, const FF &scalar) override
EventEmitterInterface< EccAddMemoryEvent > & add_memory_events
ExecutionIdManagerInterface & execution_id_manager
EventEmitterInterface< EccAddEvent > & add_events
virtual uint32_t get_execution_id() const =0
StandardAffinePoint< AvmFlavorSettings::EmbeddedCurve::AffineElement > EmbeddedCurvePoint
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept