blob: 13028ea1bb837fd3551aadbbde8607040a44a530 (
plain) (
blame)
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
|
using System;
using Org.BouncyCastle.Utilities;
namespace Org.BouncyCastle.Pqc.Crypto.SphincsPlus
{
public sealed class SphincsPlusPublicKeyParameters
: SphincsPlusKeyParameters
{
private readonly PK m_pk;
public SphincsPlusPublicKeyParameters(SphincsPlusParameters parameters, byte[] pkEncoded)
: base(false, parameters)
{
int n = parameters.N;
if (pkEncoded.Length != 2 * n)
throw new ArgumentException("public key encoding does not match parameters", nameof(pkEncoded));
m_pk = new PK(Arrays.CopyOfRange(pkEncoded, 0, n), Arrays.CopyOfRange(pkEncoded, n, 2 * n));
}
internal SphincsPlusPublicKeyParameters(SphincsPlusParameters parameters, PK pk)
: base(false, parameters)
{
m_pk = pk;
}
public byte[] GetEncoded()
{
return Arrays.ConcatenateAll(Parameters.GetEncoded(), m_pk.seed, m_pk.root);
}
public byte[] GetRoot()
{
return Arrays.Clone(m_pk.root);
}
public byte[] GetSeed()
{
return Arrays.Clone(m_pk.seed);
}
}
}
|