mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
3.2.2 Use a hash to point for random points in dfg
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -1517,6 +1517,7 @@ dependencies = [
|
|||||||
"ff-group-tests",
|
"ff-group-tests",
|
||||||
"group",
|
"group",
|
||||||
"rand_core 0.6.4",
|
"rand_core 0.6.4",
|
||||||
|
"sha2 0.9.9",
|
||||||
"subtle",
|
"subtle",
|
||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ ff = "0.12"
|
|||||||
group = "0.12"
|
group = "0.12"
|
||||||
|
|
||||||
crypto-bigint = "0.4"
|
crypto-bigint = "0.4"
|
||||||
|
|
||||||
|
sha2 = "0.9"
|
||||||
curve25519-dalek = "3.2"
|
curve25519-dalek = "3.2"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|||||||
@@ -354,15 +354,12 @@ macro_rules! dalek_group {
|
|||||||
type Scalar = Scalar;
|
type Scalar = Scalar;
|
||||||
fn random(mut rng: impl RngCore) -> Self {
|
fn random(mut rng: impl RngCore) -> Self {
|
||||||
loop {
|
loop {
|
||||||
let mut bytes = field::FieldElement::random(&mut rng).to_repr();
|
let mut bytes = [0; 64];
|
||||||
bytes[31] |= u8::try_from(rng.next_u32() % 2).unwrap() << 7;
|
rng.fill_bytes(&mut bytes);
|
||||||
let opt = Self::from_bytes(&bytes);
|
let point = $Point($DPoint::hash_from_bytes::<sha2::Sha512>(&bytes));
|
||||||
if opt.is_some().into() {
|
// Ban identity, per the trait specification
|
||||||
let opt = opt.unwrap();
|
if !bool::from(point.is_identity()) {
|
||||||
// Ban identity, per the trait specification
|
return point;
|
||||||
if !bool::from(opt.is_identity()) {
|
|
||||||
return opt;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user