Skip to content

Commit

Permalink
Assumptions check
Browse files Browse the repository at this point in the history
  • Loading branch information
davxy committed Nov 2, 2024
1 parent 3c7a251 commit 56d554c
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/suites/bandersnatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,14 @@ pub mod edwards {
AffinePoint::new_unchecked(X, Y)
};
}

#[test]
fn check_assumptions() {
use crate::ring::RingSuite;
check_point(BandersnatchSha512Ell2::BLINDING_BASE);
check_point(BandersnatchSha512Ell2::ACCUMULATOR_BASE);
check_point(BandersnatchSha512Ell2::PADDING);
}
}
#[cfg(feature = "ring")]
pub use ring_defs::*;
Expand All @@ -224,11 +232,15 @@ pub mod edwards {
#[cfg(test)]
suite_tests!(BandersnatchSha512Ell2);

fn check_point(p: AffinePoint) {
assert!(p.is_on_curve());
assert!(p.is_in_correct_subgroup_assuming_on_curve());
}

#[test]
fn elligator2_hash_to_curve() {
let point = BandersnatchSha512Ell2::data_to_point(b"foo").unwrap();
assert!(point.is_on_curve());
assert!(point.is_in_correct_subgroup_assuming_on_curve());
let p = BandersnatchSha512Ell2::data_to_point(b"foo").unwrap();
check_point(p);
}
}

Expand Down

0 comments on commit 56d554c

Please sign in to comment.