-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathML_DSA_Keys.cs
More file actions
72 lines (65 loc) · 1.92 KB
/
ML_DSA_Keys.cs
File metadata and controls
72 lines (65 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
namespace Waher.Security.PQC
{
/// <summary>
/// ML-DSA public and private keys, as defined in §6.1.
/// </summary>
public class ML_DSA_Keys
{
/// <summary>
/// ML-DSA public and private keys, as defined in §6.1.
/// </summary>
/// <param name="Â">Internal matrix used to generate encryption key.</param>
/// <param name="PublicKey">Public Encryption key.</param>
/// <param name="PrivateKey">Private Decryption key.</param>
/// <param name="Seed">Seed value, if seed is to be remembered.</param>
public ML_DSA_Keys(uint[,][] Â, byte[] PublicKey, byte[] PrivateKey, byte[] Seed)
{
this. = Â;
this.PublicKey = PublicKey;
this.PrivateKey = PrivateKey;
this.Seed = Seed;
}
/// <summary>
/// Matrix of encryption keys, as defined in §6.1.
/// </summary>
public uint[,][] Â
{
get;
internal set;
}
/// <summary>
/// Encoded public key, as defined in §6.1.
/// </summary>
public byte[] PublicKey { get; }
/// <summary>
/// Encoded private key, as defined in §6.1.
/// </summary>
public byte[] PrivateKey { get; }
/// <summary>
/// If the key contains a private key.
/// </summary>
public bool HasPrivateKey => (this.PrivateKey?.Length ?? 0) > 0;
/// <summary>
/// Seed that generated key, if available.
/// </summary>
public byte[] Seed { get; }
/// <summary>
/// Creates a key object instance from a public key.
/// </summary>
/// <param name="PublicKey">Public key.</param>
/// <returns>Object instance.</returns>
public static ML_DSA_Keys FromPublicKey(byte[] PublicKey)
{
return new ML_DSA_Keys(null, PublicKey, null, null);
}
/// <summary>
/// Creates a key object instance from a private key.
/// </summary>
/// <param name="PrivateKey">Private key.</param>
/// <returns>Object instance.</returns>
public static ML_DSA_Keys FromPrivateKey(byte[] PrivateKey)
{
return new ML_DSA_Keys(null, null, PrivateKey, null);
}
}
}