Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
56dbcce
batch_mul comments
ledwards2225 Sep 18, 2025
7580b89
fixed base comments
ledwards2225 Sep 18, 2025
53d5084
initial variable base pass
ledwards2225 Sep 19, 2025
b78c471
add num gates pinning to cycle group tests
ledwards2225 Sep 18, 2025
4ae0886
latter half of variable base cleanup
ledwards2225 Sep 19, 2025
a7ab205
more comment updates
ledwards2225 Sep 19, 2025
921a024
improve block comment on variable
ledwards2225 Sep 19, 2025
69129be
some is constant simplification
ledwards2225 Sep 19, 2025
f49f69e
constant infnity method
ledwards2225 Sep 19, 2025
b5a7228
Merge branch 'merge-train/barretenberg' into lde/cycle-group-6
ledwards2225 Sep 19, 2025
60d201b
fix cast issue
ledwards2225 Sep 19, 2025
39ca255
clean and test dbl()
ledwards2225 Sep 19, 2025
5ff7567
few more dbl comments
ledwards2225 Sep 19, 2025
ec44b51
clean up unconditional add sub plus standalone tests
ledwards2225 Sep 21, 2025
be731f9
update block comments
ledwards2225 Sep 21, 2025
baf2ba2
constant point at infinity method
ledwards2225 Sep 21, 2025
3fa2dd6
add tests
ledwards2225 Sep 21, 2025
aec20bf
clean up operator+
ledwards2225 Sep 21, 2025
d482734
opinionated simplification of operator+-
ledwards2225 Sep 21, 2025
d5b11e0
undo simplification that removes micro optimization for now
ledwards2225 Sep 22, 2025
3032210
update gate coutns in tests to reflect prior commit
ledwards2225 Sep 22, 2025
2d205f0
add notr about methods only used by fuzzer
ledwards2225 Sep 22, 2025
aa1d670
comments and cleanup in smaller methods
ledwards2225 Sep 22, 2025
b15a84c
cleanup and reinstate some missed used_wtiness tagging
ledwards2225 Sep 22, 2025
ef74969
doxy updates
ledwards2225 Sep 23, 2025
b218d05
use fix witness for clarity
ledwards2225 Sep 23, 2025
37c6115
undo fix_witness usage
ledwards2225 Sep 23, 2025
18b5039
limit set_point_at_infinity to fuzzing only
ledwards2225 Sep 23, 2025
bed0c56
Merge branch 'merge-train/barretenberg' into lde/cycle-group-6
ledwards2225 Sep 24, 2025
20514aa
Merge branch 'merge-train/barretenberg' into lde/cycle-group-6
ledwards2225 Sep 25, 2025
929de9c
comment updates and minor tweaks based on review
ledwards2225 Sep 25, 2025
9519e5c
Merge branch 'merge-train/barretenberg' into lde/cycle-group-6
ledwards2225 Sep 25, 2025
edf4395
update vk
ledwards2225 Sep 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cd ..
# - Generate a hash for versioning: sha256sum bb-civc-inputs.tar.gz
# - Upload the compressed results: aws s3 cp bb-civc-inputs.tar.gz s3://aztec-ci-artifacts/protocol/bb-civc-inputs-[hash(0:8)].tar.gz
# Note: In case of the "Test suite failed to run ... Unexpected token 'with' " error, need to run: docker pull aztecprotocol/build:3.0
pinned_short_hash="daac61c3"
pinned_short_hash="a17603e4"
pinned_civc_inputs_url="https://aztec-ci-artifacts.s3.us-east-2.amazonaws.com/protocol/bb-civc-inputs-${pinned_short_hash}.tar.gz"

function compress_and_upload {
Expand Down
765 changes: 376 additions & 389 deletions barretenberg/cpp/src/barretenberg/stdlib/primitives/group/cycle_group.cpp

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,10 @@

namespace bb::stdlib {

template <typename Builder>
concept IsUltraArithmetic = (Builder::CIRCUIT_TYPE == CircuitType::ULTRA);

/**
* @brief cycle_group represents a group Element of the proving system's embedded curve
* i.e. a curve with a cofactor 1 defined over a field equal to the circuit's native field Builder::FF
*
* (todo @zac-williamson) once the pedersen refactor project is finished, this class will supercede
* `stdlib::group`
* @brief cycle_group represents a group Element of the proving system's embedded curve, i.e. a curve with a cofactor 1
* defined over a field equal to the circuit's native field Builder::FF
* @details In barretenberg, cycle group is used to represent the Grumpkin curve defined over the bn254 scalar field.
*
* @tparam Builder
*/
Expand All @@ -49,10 +44,12 @@ template <typename Builder> class cycle_group {
using BigScalarField = stdlib::bigfield<Builder, bb::fq::Params>;
using cycle_scalar = ::bb::stdlib::cycle_scalar<Builder>;
using straus_lookup_table = ::bb::stdlib::straus_lookup_table<Builder>;
using straus_scalar_slice = ::bb::stdlib::straus_scalar_slice<Builder>;
using straus_scalar_slices = ::bb::stdlib::straus_scalar_slices<Builder>;

static constexpr size_t TABLE_BITS = 4;
// Bit-size for scalars represented in the ROM lookup tables used in the variable-base MSM algorithm
static constexpr size_t ROM_TABLE_BITS = 4;
static constexpr size_t NUM_BITS_FULL_FIELD_SIZE = bb::fq::modulus.get_msb() + 1;
// Domain separator for generating offset generator points in the variable-base MSM algorithm
static constexpr std::string_view OFFSET_GENERATOR_DOMAIN_SEPARATOR = "cycle_group_offset_generator";

// Since the cycle_group base field is the circuit's native field, it can be stored using two public inputs.
Expand All @@ -74,20 +71,26 @@ template <typename Builder> class cycle_group {
cycle_group(const bb::fr& _x, const bb::fr& _y, bool _is_infinity);
cycle_group(const AffineElement& _in);
static cycle_group one(Builder* _context);
static cycle_group constant_infinity(Builder* _context = nullptr);
static cycle_group from_witness(Builder* _context, const AffineElement& _in);
static cycle_group from_constant_witness(Builder* _context, const AffineElement& _in);
Builder* get_context(const cycle_group& other) const;
Builder* get_context() const { return context; }
AffineElement get_value() const;
[[nodiscard]] bool is_constant() const { return _is_constant; }
[[nodiscard]] bool is_constant() const { return x.is_constant() && y.is_constant() && _is_infinity.is_constant(); }
bool_t is_point_at_infinity() const { return _is_infinity; }
[[nodiscard]] bool is_constant_point_at_infinity() const
{
return _is_infinity.is_constant() && _is_infinity.get_value();
}
#ifdef FUZZING
void set_point_at_infinity(const bool_t& is_infinity);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've marked this overly complicated method as fuzzing only since its not used elsewhere. It seems odd to have the fuzzer use methods that aren't used/accessible from production code but this can be sorted out with pending fuzzer updates

#endif
void standardize();
bool is_standard() const { return this->_is_standard; };
cycle_group get_standard_form();
void validate_on_curve() const;
cycle_group dbl(const std::optional<AffineElement> hint = std::nullopt) const
requires IsUltraArithmetic<Builder>;
cycle_group dbl(const std::optional<AffineElement> hint = std::nullopt) const;
cycle_group unconditional_add(const cycle_group& other,
const std::optional<AffineElement> hint = std::nullopt) const;
cycle_group unconditional_subtract(const cycle_group& other,
Expand Down Expand Up @@ -207,7 +210,6 @@ template <typename Builder> class cycle_group {

private:
bool_t _is_infinity;
bool _is_constant;
// The point is considered to be `standard` or in `standard form` when:
// - It's not a point at infinity, and the coordinates belong to the curve
// - It's a point at infinity and both of the coordinates are set to be 0. (0, 0)
Expand Down
Loading
Loading