Struct KeyAgreementAlgorithmBuilder

Source
pub struct KeyAgreementAlgorithmBuilder;
Expand description

Builder for constructing key agreement algorithm instances.

用于构建密钥协商算法实例的构建器。

§Usage Pattern | 使用模式

use seal_crypto_wrapper::algorithms::asymmetric::key_agreement::KeyAgreementAlgorithm;

// Select ECDH P-256 algorithm
let algorithm = KeyAgreementAlgorithm::build().ecdh_p256();

§Security Considerations | 安全考虑

When selecting a key agreement algorithm, consider:

  • Required security level
  • Performance requirements
  • Compatibility with other systems
  • Forward secrecy requirements

选择密钥协商算法时,考虑:

  • 所需的安全级别
  • 性能要求
  • 与其他系统的兼容性
  • 前向保密要求

Implementations§

Source§

impl KeyAgreementAlgorithmBuilder

Source

pub fn ecdh_p256(self) -> KeyAgreementAlgorithm

Selects ECDH P-256 key agreement algorithm.

选择 ECDH P-256 密钥协商算法。

§Algorithm Details | 算法详情

ECDH (Elliptic Curve Diffie-Hellman) over the NIST P-256 curve provides:

  • 128-bit security level
  • Efficient computation
  • Wide industry support
  • FIPS 140-2 compliance

基于 NIST P-256 曲线的 ECDH(椭圆曲线 Diffie-Hellman)提供:

  • 128 位安全级别
  • 高效计算
  • 广泛的行业支持
  • FIPS 140-2 合规性
§Performance | 性能
  • Key Generation: Very fast (~0.1ms)
  • Key Agreement: Fast (~0.2ms)
  • Memory Usage: Low (64 bytes per key pair)
  • Hardware Support: Available on many platforms
§Use Cases | 使用场景

Ideal for applications requiring:

  • High performance key exchange
  • Standards compliance
  • Interoperability
  • Moderate security requirements

适用于需要以下功能的应用:

  • 高性能密钥交换
  • 标准合规性
  • 互操作性
  • 中等安全要求
§Examples | 示例
use seal_crypto_wrapper::algorithms::asymmetric::key_agreement::KeyAgreementAlgorithm;

let algorithm = KeyAgreementAlgorithm::build().ecdh_p256();
let ka = algorithm.into_wrapper();

// Generate key pairs for Alice and Bob
let alice_keypair = ka.generate_keypair()?;
let bob_keypair = ka.generate_keypair()?;

// Derive shared secrets
let (alice_public, alice_private) = alice_keypair.into_keypair();
let (bob_public, bob_private) = bob_keypair.into_keypair();

let alice_shared = ka.agree(&alice_private, &bob_public)?;
let bob_shared = ka.agree(&bob_private, &alice_public)?;
assert_eq!(alice_shared, bob_shared);

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V