2022-06-30 05:42:29 -04:00
|
|
|
mod scalar;
|
|
|
|
|
mod schnorr;
|
|
|
|
|
|
|
|
|
|
use hex_literal::hex;
|
2022-07-05 19:10:30 -04:00
|
|
|
use rand_core::OsRng;
|
2022-06-30 05:42:29 -04:00
|
|
|
|
2022-07-02 02:46:40 -04:00
|
|
|
use ff::{Field, PrimeField};
|
2022-06-30 05:42:29 -04:00
|
|
|
use group::{Group, GroupEncoding};
|
|
|
|
|
|
|
|
|
|
use k256::{Scalar, ProjectivePoint};
|
2022-07-02 02:46:40 -04:00
|
|
|
use dalek_ff_group::{self as dfg, EdwardsPoint, CompressedEdwardsY};
|
|
|
|
|
|
2022-06-30 05:42:29 -04:00
|
|
|
use transcript::RecommendedTranscript;
|
|
|
|
|
|
2022-07-05 19:10:30 -04:00
|
|
|
use crate::{Generators, cross_group::linear::EfficientDLEq};
|
|
|
|
|
|
|
|
|
|
mod linear;
|
2022-06-30 05:42:29 -04:00
|
|
|
|
2022-07-05 19:10:30 -04:00
|
|
|
pub(crate) fn transcript() -> RecommendedTranscript {
|
2022-07-02 02:46:40 -04:00
|
|
|
RecommendedTranscript::new(b"Cross-Group DLEq Proof Test")
|
|
|
|
|
}
|
2022-06-30 05:42:29 -04:00
|
|
|
|
2022-07-05 19:10:30 -04:00
|
|
|
pub(crate) fn generators() -> (Generators<ProjectivePoint>, Generators<EdwardsPoint>) {
|
2022-07-02 02:46:40 -04:00
|
|
|
(
|
2022-06-30 05:42:29 -04:00
|
|
|
Generators::new(
|
|
|
|
|
ProjectivePoint::GENERATOR,
|
|
|
|
|
ProjectivePoint::from_bytes(
|
|
|
|
|
&(hex!("0250929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0").into())
|
|
|
|
|
).unwrap()
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
Generators::new(
|
|
|
|
|
EdwardsPoint::generator(),
|
|
|
|
|
CompressedEdwardsY::new(
|
|
|
|
|
hex!("8b655970153799af2aeadc9ff1add0ea6c7251d54154cfa92c173a0dd39c1f94")
|
|
|
|
|
).decompress().unwrap()
|
|
|
|
|
)
|
2022-07-02 02:46:40 -04:00
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_rejection_sampling() {
|
|
|
|
|
let mut pow_2 = Scalar::one();
|
|
|
|
|
for _ in 0 .. dfg::Scalar::CAPACITY {
|
|
|
|
|
pow_2 = pow_2.double();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert!(
|
2022-07-05 19:10:30 -04:00
|
|
|
EfficientDLEq::prove_without_bias(
|
2022-07-02 02:46:40 -04:00
|
|
|
&mut OsRng,
|
|
|
|
|
&mut RecommendedTranscript::new(b""),
|
|
|
|
|
generators(),
|
|
|
|
|
pow_2
|
|
|
|
|
).is_none()
|
2022-06-30 05:42:29 -04:00
|
|
|
);
|
2022-07-02 02:46:40 -04:00
|
|
|
}
|