-
Notifications
You must be signed in to change notification settings - Fork 311
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
fa63a71
commit 763e6bf
Showing
13 changed files
with
330 additions
and
57 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
33 changes: 33 additions & 0 deletions
33
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,33 @@ | ||
#include "barretenberg/vm/avm_trace/gadgets/avm_ecc.hpp" | ||
#include "barretenberg/vm/avm_trace/avm_common.hpp" | ||
|
||
namespace bb::avm_trace { | ||
using element = grumpkin::g1::affine_element; | ||
|
||
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(); | ||
} | ||
|
||
element AvmEccTraceBuilder::embedded_curve_add(element lhs, element rhs, uint32_t clk) | ||
{ | ||
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 |
29 changes: 29 additions & 0 deletions
29
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,29 @@ | ||
#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 |
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
Oops, something went wrong.