Skip to content

Commit

Permalink
check constant points values
Browse files Browse the repository at this point in the history
  • Loading branch information
davxy committed Nov 10, 2024
1 parent f6e80d3 commit 6cc0a2d
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/pedersen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,24 @@ pub(crate) mod testing {
);
}

pub fn blinding_base_check<S: PedersenSuite>() {
const BLINDING_BASE_SEED: &[u8] = b"w3f/ring-proof/blinding";
let p = S::data_to_point(BLINDING_BASE_SEED).unwrap();
assert_eq!(S::BLINDING_BASE, p);
}

#[macro_export]
macro_rules! pedersen_suite_tests {
($suite:ident) => {
#[test]
fn pedersen_prove_verify() {
$crate::pedersen::testing::prove_verify::<$suite>();
}

#[test]
fn pedersen_blinding_base_check() {
$crate::pedersen::testing::blinding_base_check::<$suite>();
}
};
}

Expand Down
32 changes: 32 additions & 0 deletions src/ring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,45 @@ pub(crate) mod testing {
assert!(result.is_ok());
}

#[allow(unused)]
pub fn padding_check<S: RingSuite>()
where
BaseField<S>: ark_ff::PrimeField,
AffinePoint<S>: ring_proof::AffineCondAdd,
{
const PADDING_SEED: &[u8] = b"w3f/ring-proof/padding";
let p = S::data_to_point(PADDING_SEED).unwrap();
assert_eq!(S::PADDING, p);
}

#[allow(unused)]
pub fn accumulator_base_check<S: RingSuite>()
where
BaseField<S>: ark_ff::PrimeField,
AffinePoint<S>: ring_proof::AffineCondAdd,
{
const ACCUMULATOR_BASE_SEED: &[u8] = b"w3f/ring-proof/accumulator";
let p = S::data_to_point(ACCUMULATOR_BASE_SEED).unwrap();
assert_eq!(S::ACCUMULATOR_BASE, p);
}

#[macro_export]
macro_rules! ring_suite_tests {
($suite:ident) => {
#[test]
fn ring_prove_verify() {
$crate::ring::testing::prove_verify::<$suite>()
}

#[test]
fn ring_padding_check() {
$crate::ring::testing::padding_check::<$suite>()
}

#[test]
fn ring_accumulator_base_check() {
$crate::ring::testing::accumulator_base_check::<$suite>()
}
};
}

Expand Down
4 changes: 2 additions & 2 deletions src/suites/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ impl Suite for TestSuite {
impl PedersenSuite for TestSuite {
const BLINDING_BASE: AffinePoint = {
const X: BaseField =
MontFp!("1181072390894490040170698195029164902368238760122173135634802939739986120753");
MontFp!("2842812182132742151291439804105987992770071362848070020835328675429531065386");
const Y: BaseField = MontFp!(
"16819438535150625131748701663066892288775529055803151482550035706857354997714"
"51537589290258453714586392305999864217349499404270029291993413345863140891436"
);
AffinePoint::new_unchecked(X, Y)
};
Expand Down

0 comments on commit 6cc0a2d

Please sign in to comment.