,
}
impl Pricer for Bls12ConstOperations {
fn cost(&self, _input: &[u8]) -> U256 {
self.price.into()
}
}
impl Pricer for Bls12PairingPricer {
fn cost(&self, input: &[u8]) -> U256 {
U256::from(self.price.base)
+ U256::from(self.price.pair) * U256::from(input.len() / BLS12_G1_AND_G2_PAIR_LEN)
}
}
impl {
fn cost(&self, input: &[u8]) -> U256 {
let num_pairs = input.len() / P::LENGTH;
if num_pairs == 0 {
return U256::zero();
}
let discount = if num_pairs > BLS12_MULTIEXP_PAIRS_FOR_MAX_DISCOUNT {
BLS12_MULTIEXP_MAX_DISCOUNT
} else {
let table_entry = BLS12_MULTIEXP_DISCOUNTS_TABLE[num_pairs - 1];
table_entry[1]
};
U256::from(self.base_price.price) * U256::from(num_pairs) * U256::from(discount)
/ U256::from(BLS12_MULTIEXP_DISCOUNT_DIVISOR)
}
}
/// Multiexp pricer in G1
pub type Bls12MultiexpPricerG1 = Bls12MultiexpPricer