Class Curve25519
Elliptic Curve methods used for Diffie Hellman key exchange.
Inheritance
Namespace: SuperNet.Netcode.Crypto
Assembly: cs.temp.dll.dll
Syntax
public static class Curve25519
Fields
KeySize
Key size in bytes.
Declaration
public const int KeySize = 32
Field Value
Type | Description |
---|---|
System.Int32 |
Methods
ClampPrivateKey(Byte[])
Private key clamping.
Declaration
public static byte[] ClampPrivateKey(byte[] rawKey)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | rawKey | [in] Random 32 bytes |
Returns
Type | Description |
---|---|
System.Byte[] | Clamped private key. |
ClampPrivateKeyInline(Byte[])
Private key clamping (inline, for performance).
Declaration
public static void ClampPrivateKeyInline(byte[] key)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | key | [out] Random 32 bytes. |
CreateRandomPrivateKey()
Create a random clamped private key.
Declaration
public static byte[] CreateRandomPrivateKey()
Returns
Type | Description |
---|---|
System.Byte[] | Random 32 bytes that are clamped to a suitable private key. |
GetPublicKey(Byte[])
Generate the public key out of the clamped private key.
Declaration
public static byte[] GetPublicKey(byte[] privateKey)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | privateKey | [in] Private key (must be clamped). |
Returns
Type | Description |
---|---|
System.Byte[] | Public key. |
GetPublicKeyInline(Byte[], Byte[])
Generate the public key out of the clamped private key (inline, for performance).
Declaration
public static void GetPublicKeyInline(byte[] privateKey, byte[] publicKey)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | privateKey | [in] Private key (must be clamped). |
System.Byte[] | publicKey | [out] Public key. |
GetSharedSecret(Byte[], Byte[])
Key agreement.
Declaration
public static byte[] GetSharedSecret(byte[] privateKey, byte[] peerPublicKey)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | privateKey | [in] Your private key for key agreement. |
System.Byte[] | peerPublicKey | [in] Peer's public key. |
Returns
Type | Description |
---|---|
System.Byte[] | Shared secret (needs hashing before use). |
GetSharedSecretInline(Byte[], Byte[], Byte[])
Key agreement.
Declaration
public static void GetSharedSecretInline(byte[] privateKey, byte[] peerPublicKey, byte[] sharedSecret)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | privateKey | [in] Your private key for key agreement. |
System.Byte[] | peerPublicKey | [in] Peer's public key. |
System.Byte[] | sharedSecret | [out] Shared secret (needs hashing before use). |
GetSigningKey(Byte[])
Generate signing key out of the clamped private key.
Declaration
public static byte[] GetSigningKey(byte[] privateKey)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | privateKey | [in] Private key (must be clamped). |
Returns
Type | Description |
---|---|
System.Byte[] | Signing key. |
KeyGenInline(Byte[], Byte[], Byte[])
Generate key-pair (inline, for performance).
Declaration
public static void KeyGenInline(byte[] publicKey, byte[] signingKey, byte[] privateKey)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | publicKey | [out] Public key. |
System.Byte[] | signingKey | [out] Signing key (ignored if NULL). |
System.Byte[] | privateKey | [out] Private key. |
Remarks
WARNING: if signingKey is not NULL, this function has data-dependent timing.