mirror of
https://github.com/arnaucube/arkeddsa.git
synced 2026-01-12 00:01:28 +01:00
allow to generate shared key
This commit is contained in:
10
src/eddsa.rs
10
src/eddsa.rs
@@ -140,6 +140,16 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<TE: TECurveConfig> SigningKey<TE> {
|
||||||
|
pub fn shared_key<D: Digest>(&self, recipient: &PublicKey<TE>) -> [u8; 32] {
|
||||||
|
let (x, _) = self.secret_key.expand::<TE::ScalarField, D>();
|
||||||
|
let shared_key: Affine<TE> = (*recipient.as_ref() * x).into();
|
||||||
|
let mut data = Vec::new();
|
||||||
|
shared_key.serialize_compressed(&mut data).unwrap();
|
||||||
|
data[00..32].try_into().unwrap()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<TE: TECurveConfig + Clone> PublicKey<TE>
|
impl<TE: TECurveConfig + Clone> PublicKey<TE>
|
||||||
where
|
where
|
||||||
TE::BaseField: PrimeField + Absorb,
|
TE::BaseField: PrimeField + Absorb,
|
||||||
|
|||||||
Reference in New Issue
Block a user