Skip to content

Conversation

@georgepisaltu
Copy link
Contributor

Changes in this PR:

  • Replace the compile-time small-ring feature flag with runtime-configurable RingDomainSize enum supporting three domain sizes:
    • 11: max 255 members
    • 12: max 767 members (new domain with params added)
    • 16: max 16,127 members
    • Add DomainSize type with trait to GenerateVerifiable allowing domain_size to be passed to start_members(), open(), validate()
    • Make ring builder params that bloat library binary size feature gated behind builder-params.
    • Add generate-keys feature to gate the rand dependency used in the --bin compilation to generate keys.
    • Add test_for_all_domains! macro to run ring VRF tests against all domain sizes

Signed-off-by: georgepisaltu <[email protected]>
@georgepisaltu georgepisaltu requested a review from ggwpez January 28, 2026 12:18

#[cfg(feature = "std")]
fn ring_prover_params() -> &'static bandersnatch::RingProofParams {
fn ring_prover_params(domain_size: RingDomainSize) -> &'static bandersnatch::RingProofParams {
Copy link
Member

Choose a reason for hiding this comment

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

I think it could be enough to just use the spin lock variant of ring_prover_params. I dont think we will have many threads call this during the initialization phase.

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 added a todo to address it in the future.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe the opening should also be its own trait and not be implemented for BandersnatchVrfVerifiable unless no-std-prover is provided.
Just to avoid possibly panic paths in the runtime. But can be done in another MR for sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gated access to the function.

Copy link
Member

Choose a reason for hiding this comment

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

Also should maybe be moved into another trait in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gated access to the function.

Comment on lines 626 to 671
#[ignore = "ring builder generator - generates Domain11 ring data (max 255 members)"]
fn generate_empty_ring_builder_domain11() {
generate_ring_builder_for_domain(
RingDomainSize::Domain11,
concat!(
env!("CARGO_MANIFEST_DIR"),
"/src/ring-data/ring-builder-domain11.bin"
),
concat!(
env!("CARGO_MANIFEST_DIR"),
"/src/ring-data/ring-builder-params-domain11.bin"
),
);
}

#[test]
#[ignore = "ring builder generator - generates Domain12 ring data (max 767 members)"]
fn generate_empty_ring_builder_domain12() {
generate_ring_builder_for_domain(
RingDomainSize::Domain12,
concat!(
env!("CARGO_MANIFEST_DIR"),
"/src/ring-data/ring-builder-domain12.bin"
),
concat!(
env!("CARGO_MANIFEST_DIR"),
"/src/ring-data/ring-builder-params-domain12.bin"
),
);
}

#[test]
#[ignore = "ring builder generator - generates Domain16 ring data (max 16127 members)"]
fn generate_empty_ring_builder_domain16() {
generate_ring_builder_for_domain(
RingDomainSize::Domain16,
concat!(
env!("CARGO_MANIFEST_DIR"),
"/src/ring-data/ring-builder-domain16.bin"
),
concat!(
env!("CARGO_MANIFEST_DIR"),
"/src/ring-data/ring-builder-params-domain16.bin"
),
);
}
Copy link
Member

Choose a reason for hiding this comment

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

Could be put in to a function and use the RingDomainSize::ALL to do it for all sizes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

src/lib.rs Outdated
/// Trait for domain size types used in ring operations.
///
/// The domain size determines the maximum ring size that can be supported.
pub trait DomainSize: Clone + Copy {
Copy link
Member

@davxy davxy Jan 29, 2026

Choose a reason for hiding this comment

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

@georgepisaltu @ggwpez

The main concern here is that DomainSize outside the ring implementation doesn't make much sense
(as you correctly wrote: domain size types used in ring operations).
This can instead be confusing, as downstream users may have no knowledge of polynomial commitment schemes or related concepts. These are strictly implementation details of RingProof when it is based on such schemes. From the user's perspective, the only relevant factor is the number of members they are allowed to include.

I suggest removing this trait from this generic module and replacing it with a more appropriate abstraction.

In the GenerateVerifiable trait, you could introduce an associated type such as Capacity, for example:

trait Capacity {
    const fn size(&self) -> usize;
}

(feel free to choose a better name :-) )

With this approach, the ring implementation can use the ark-vrf helper to derive the required PCS size
(ark_vrf::ring::pcs_domain_size(ring_size)), and then select the appropriate static data based on that value.

In the ring implementation you have:

enum RingSize {
    /// Domain size 2^11, max ring size 255
	Small,
	/// Domain size 2^12, max ring size 767
	Mid,
	/// Domain size 2^16, max ring size 16127
	Big,
}

impl Capacity for RingSize {
    const fn size(&self) -> usize {
        match self {
             Small => max_ring_size_from_pcs_domain_size(1 << 11),
             Mid => max_ring_size_from_pcs_domain_size(1 << 12),
             Big => max_ring_size_from_pcs_domain_size(1 << 16),
        }
    }
}

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 removed the exponent function and redefined the trait and type to be Capacity.

@davxy davxy requested a review from ggwpez January 29, 2026 12:18
Signed-off-by: georgepisaltu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants