pub struct SharedKey(/* private fields */);Expand description
2つの鍵から導出した、AES-256-GCM の鍵。使い終わるとメモリを0で上書きする。
Implementations§
Sourcepub fn derive(
private_key: &PrivateKey,
other_public_key: &PublicKey,
) -> Result<Self, InvalidPublicKey>
pub fn derive( private_key: &PrivateKey, other_public_key: &PublicKey, ) -> Result<Self, InvalidPublicKey>
自分の秘密鍵と相手の公開鍵から導出する。catapult の DeriveSharedKey。
秘密鍵の SHA-512 の前半をクランプしたスカラーを相手の点に掛け、 圧縮した点を HKDF-HMAC-SHA256 にかける。相手の公開鍵は、署名の検証と同じく y が正規で、曲線上にあり、位数 L の部分群に入っているものだけを受け付ける。
pub fn as_bytes(&self) -> &[u8; 32]
Sourcepub fn candidates_from_x25519(shared: &[u8; 32]) -> Option<[Self; 2]>
pub fn candidates_from_x25519(shared: &[u8; 32]) -> Option<[Self; 2]>
X25519 の結果(共有した点の u)から、SharedKey::derive と同じ鍵の候補を2つ作る。
catapult は共有した点を Edwards の形(y と x の符号)で圧縮して使うが、X25519 の結果には x の符号がない。
符号の両方を候補にし、どちらが合うかは AES-GCM の認証タグで決める(open_x25519)
Trait Implementations§
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more