stabilizaiton work - projects rework for maintenanceability and ui livening
This commit is contained in:
52
src/__Libraries/StellaOps.Provcache/VeriKeyBuilder.Vex.cs
Normal file
52
src/__Libraries/StellaOps.Provcache/VeriKeyBuilder.Vex.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 VEX hash set hash (sorted aggregation of VEX statement hashes).
|
||||
/// </summary>
|
||||
/// <param name="vexHashSetHash">The pre-computed VEX hash set hash.</param>
|
||||
/// <returns>This builder for fluent chaining.</returns>
|
||||
public VeriKeyBuilder WithVexHashSet(string vexHashSetHash)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(vexHashSetHash))
|
||||
throw new ArgumentException("VEX hash set hash cannot be null or empty.", nameof(vexHashSetHash));
|
||||
|
||||
_vexHashSetHash = NormalizeHash(vexHashSetHash);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Computes VEX hash set from individual VEX statement hashes.
|
||||
/// Hashes are sorted lexicographically before aggregation for determinism.
|
||||
/// </summary>
|
||||
/// <param name="vexStatementHashes">Individual VEX statement hashes.</param>
|
||||
/// <returns>This builder for fluent chaining.</returns>
|
||||
public VeriKeyBuilder WithVexStatementHashes(IEnumerable<string> vexStatementHashes)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(vexStatementHashes);
|
||||
|
||||
var sortedHashes = vexStatementHashes
|
||||
.Where(h => !string.IsNullOrWhiteSpace(h))
|
||||
.Select(NormalizeHash)
|
||||
.Order(StringComparer.Ordinal)
|
||||
.ToList();
|
||||
|
||||
if (sortedHashes.Count == 0)
|
||||
{
|
||||
_vexHashSetHash = ComputeHash(Encoding.UTF8.GetBytes("empty-vex-set"));
|
||||
}
|
||||
else
|
||||
{
|
||||
var concatenated = string.Join("|", sortedHashes);
|
||||
_vexHashSetHash = ComputeHash(Encoding.UTF8.GetBytes(concatenated));
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user