-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00c3ee5
commit e8a754e
Showing
15 changed files
with
861 additions
and
557 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
barretenberg/cpp/src/barretenberg/vm/avm_trace/gadgets/avm_ecc.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
#include "barretenberg/vm/avm_trace/gadgets/avm_ecc.hpp" | ||
#include "barretenberg/vm/avm_trace/avm_common.hpp" | ||
|
||
namespace bb::avm_trace { | ||
|
||
AvmEccTraceBuilder::AvmEccTraceBuilder() | ||
{ | ||
ecc_trace.reserve(AVM_TRACE_SIZE); | ||
} | ||
|
||
std::vector<AvmEccTraceBuilder::EccTraceEntry> AvmEccTraceBuilder::finalize() | ||
{ | ||
return std::move(ecc_trace); | ||
} | ||
|
||
void AvmEccTraceBuilder::reset() | ||
{ | ||
ecc_trace.clear(); | ||
} | ||
|
||
grumpkin::g1::affine_element AvmEccTraceBuilder::embedded_curve_add(grumpkin::g1::affine_element lhs, | ||
grumpkin::g1::affine_element rhs, | ||
uint32_t clk) | ||
{ | ||
grumpkin::g1::affine_element result = lhs + rhs; | ||
std::tuple<FF, FF, bool> p1 = { lhs.x, lhs.y, lhs.is_point_at_infinity() }; | ||
std::tuple<FF, FF, bool> p2 = { rhs.x, rhs.y, rhs.is_point_at_infinity() }; | ||
std::tuple<FF, FF, bool> result_tuple = { result.x, result.y, result.is_point_at_infinity() }; | ||
ecc_trace.push_back({ clk, p1, p2, result_tuple }); | ||
|
||
return result; | ||
} | ||
|
||
} // namespace bb::avm_trace |
30 changes: 30 additions & 0 deletions
30
barretenberg/cpp/src/barretenberg/vm/avm_trace/gadgets/avm_ecc.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
#pragma once | ||
|
||
#include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" | ||
#include "barretenberg/ecc/groups/affine_element.hpp" | ||
#include "barretenberg/vm/avm_trace/avm_common.hpp" | ||
|
||
namespace bb::avm_trace { | ||
class AvmEccTraceBuilder { | ||
public: | ||
struct EccTraceEntry { | ||
uint32_t clk = 0; | ||
std::tuple<FF, FF, bool> p1; // x, y, is_infinity | ||
std::tuple<FF, FF, bool> p2; | ||
std::tuple<FF, FF, bool> result; | ||
}; | ||
|
||
AvmEccTraceBuilder(); | ||
void reset(); | ||
// Finalize the trace | ||
std::vector<EccTraceEntry> finalize(); | ||
grumpkin::g1::affine_element embedded_curve_add(grumpkin::g1::affine_element lhs, | ||
grumpkin::g1::affine_element rhs, | ||
uint32_t clk); | ||
|
||
private: | ||
std::vector<EccTraceEntry> ecc_trace; | ||
}; | ||
|
||
} // namespace bb::avm_trace |
Oops, something went wrong.