Skip to content

Commit

Permalink
impl Fq::power
Browse files Browse the repository at this point in the history
  • Loading branch information
redshiftzero committed Apr 2, 2024
1 parent 0bfb1c7 commit 1c0b354
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/fields/fq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@ impl Fq {
pub fn to_bytes(&self) -> [u8; N_8] {
self.to_bytes_le()
}

/// Raise this element to a given power.
///
/// Note: Arkworks provides another method for this, called `pow`.
pub fn power<S: AsRef<[u64]>>(&self, exp: S) -> Self {
let mut res = Fq::from(1u64);
let exp_u64 = exp.as_ref();
for _ in 0..exp_u64[0] {
res *= self;
}
res
}
}

#[cfg(test)]
Expand Down

0 comments on commit 1c0b354

Please sign in to comment.