<PackageReference Include="BouncyCastle.Cryptography" Version="2.7.0" />

Org.BouncyCastle.Crypto.Parameters.X25519PrivateKeyParameters

X25519 private key (RFC 7748). Holds the 32-byte clamped scalar used in Curve25519 Diffie-Hellman.
public static readonly int KeySize

Length in bytes of an X25519 private-key scalar (32).

public static readonly int SecretSize

Length in bytes of the shared secret produced by an X25519 agreement (32).

Generate a fresh random X25519 private key using random.

public X25519PrivateKeyParameters(byte[] buf)

Construct from a 32-byte scalar buffer.

public X25519PrivateKeyParameters(byte[] buf, int off)

Construct from buf at off; reads KeySize bytes.

Read the 32-byte scalar from input.

public void Encode(byte[] buf, int off)

Write the 32-byte scalar into buf at off.

Compute the public key (u-coordinate) corresponding to this scalar.

public void GenerateSecret(X25519PublicKeyParameters publicKey, byte[] buf, int off)

Perform an X25519 Diffie-Hellman agreement against publicKey and write the resulting SecretSize-byte shared secret into buf starting at off.

public byte[] GetEncoded()

Return a fresh copy of the 32-byte scalar.