Skip to content

Commit

Permalink
Make domain_size computation portable
Browse files Browse the repository at this point in the history
  • Loading branch information
davxy committed Aug 21, 2024
1 parent 1e5ecaa commit bd4ed7b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/ring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ where
piop_params: PiopParams<S>,
}

// Required evaluation domain size for the given ring size.
#[inline(always)]
fn domain_size(ring_size: usize) -> usize {
const RING_DOMAIN_OVERHEAD: usize = 257;
1 << ark_std::log2(ring_size + RING_DOMAIN_OVERHEAD)
fn domain_size<S: RingSuite>(ring_size: usize) -> usize {
1 << ark_std::log2(ring_size + ScalarField::<S>::MODULUS_BIT_SIZE as usize + 4)
}

#[allow(private_bounds)]
Expand All @@ -174,13 +174,13 @@ where
/// Construct a new random ring context suitable for the given ring size.
pub fn from_rand(ring_size: usize, rng: &mut impl ark_std::rand::RngCore) -> Self {
use ring_proof::pcs::PCS;
let domain_size = domain_size(ring_size);
let domain_size = domain_size::<S>(ring_size);
let pcs_params = Pcs::<S>::setup(3 * domain_size, rng);
Self::from_srs(ring_size, pcs_params).expect("PCS params is correct")
}

pub fn from_srs(ring_size: usize, mut pcs_params: PcsParams<S>) -> Result<Self, Error> {
let domain_size = domain_size(ring_size);
let domain_size = domain_size::<S>(ring_size);
if pcs_params.powers_in_g1.len() < 3 * domain_size + 1 || pcs_params.powers_in_g2.len() < 2
{
return Err(Error::InvalidData);
Expand Down

0 comments on commit bd4ed7b

Please sign in to comment.