Skip to content

Commit

Permalink
fix: point addition
Browse files Browse the repository at this point in the history
  • Loading branch information
Elvis339 committed Aug 1, 2023
1 parent aed72d7 commit cbed4c5
Show file tree
Hide file tree
Showing 2 changed files with 198 additions and 191 deletions.
12 changes: 10 additions & 2 deletions src/ecc/field_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ impl FieldElement {
})
}

pub fn get_num(&self) -> &BigInt {
&self.num
}

pub fn get_prime(&self) -> &BigInt {
&self.prime
}

pub fn pow_mod(&self, exponent: BigInt) -> FieldElement {
let mut n = exponent;
let prime = &self.prime;
Expand Down Expand Up @@ -183,7 +191,7 @@ mod tests {
}

#[test]
fn pow_test() {
fn pow_mod_test() {
let prime = 31;
let a = new_fe(17, prime.clone());
assert_eq!(a.pow_mod(BigInt::from(3)), new_fe(15, prime.clone()));
Expand All @@ -195,7 +203,7 @@ mod tests {
}

#[test]
fn pow_negative_test() {
fn pow_mod_negative_test() {
let prime = 31;
let a = new_fe(17, prime.clone());
assert_eq!(a.pow_mod(BigInt::from(-3)), new_fe(29, prime.clone()));
Expand Down
Loading

0 comments on commit cbed4c5

Please sign in to comment.