stabilizaiton work - projects rework for maintenanceability and ui livening
This commit is contained in:
52
src/__Libraries/StellaOps.Provcache/VeriKeyBuilder.Signer.cs
Normal file
52
src/__Libraries/StellaOps.Provcache/VeriKeyBuilder.Signer.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace StellaOps.Provcache;
|
||||
|
||||
public sealed partial class VeriKeyBuilder
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets the signer set hash (sorted certificate chain hashes).
|
||||
/// </summary>
|
||||
/// <param name="signerSetHash">The pre-computed signer set hash.</param>
|
||||
/// <returns>This builder for fluent chaining.</returns>
|
||||
public VeriKeyBuilder WithSignerSetHash(string signerSetHash)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(signerSetHash))
|
||||
throw new ArgumentException("Signer set hash cannot be null or empty.", nameof(signerSetHash));
|
||||
|
||||
_signerSetHash = NormalizeHash(signerSetHash);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Computes signer set hash from individual certificate hashes.
|
||||
/// Hashes are sorted lexicographically before aggregation for determinism.
|
||||
/// </summary>
|
||||
/// <param name="certificateHashes">Individual certificate hashes.</param>
|
||||
/// <returns>This builder for fluent chaining.</returns>
|
||||
public VeriKeyBuilder WithCertificateHashes(IEnumerable<string> certificateHashes)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(certificateHashes);
|
||||
|
||||
var sortedHashes = certificateHashes
|
||||
.Where(h => !string.IsNullOrWhiteSpace(h))
|
||||
.Select(NormalizeHash)
|
||||
.Order(StringComparer.Ordinal)
|
||||
.ToList();
|
||||
|
||||
if (sortedHashes.Count == 0)
|
||||
{
|
||||
_signerSetHash = ComputeHash(Encoding.UTF8.GetBytes("empty-signer-set"));
|
||||
}
|
||||
else
|
||||
{
|
||||
var concatenated = string.Join("|", sortedHashes);
|
||||
_signerSetHash = ComputeHash(Encoding.UTF8.GetBytes(concatenated));
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user