TrustBeat 0.6.0
dotnet add package TrustBeat --version 0.6.0
NuGet\Install-Package TrustBeat -Version 0.6.0
<PackageReference Include="TrustBeat" Version="0.6.0" />
<PackageVersion Include="TrustBeat" Version="0.6.0" />
<PackageReference Include="TrustBeat" />
paket add TrustBeat --version 0.6.0
#r "nuget: TrustBeat, 0.6.0"
#:package TrustBeat@0.6.0
#addin nuget:?package=TrustBeat&version=0.6.0
#tool nuget:?package=TrustBeat&version=0.6.0
TrustBeat C# / .NET SDK
Qualified electronic timestamps and Merkle anchoring — eIDAS-compliant, over a simple API.
Part of TrustBeat — digital trust infrastructure for the EU. All SDKs (Python, TypeScript, Java, C#, Go): trustbeat.eu/en/sdks.
Install
dotnet add package TrustBeat
Quickstart
using TrustBeat;
var tb = new TrustBeatClient("tb_live_...");
// Anchor a file (SHA-256 computed locally, file never leaves your machine).
// AnchorFileWaitAsync() blocks until the proof is ready (next batch, up to 11 min).
var proof = await tb.AnchorFileWaitAsync("contract.pdf");
Console.WriteLine(proof.Id); // tracking ID
Console.WriteLine(proof.AnchoredAt); // ISO 8601 timestamp
Console.WriteLine(proof.MerkleRoot); // Merkle root of the batch
// Verify locally — no network call
bool valid = tb.Verify(proof);
// Or anchor a raw SHA-256 hash without blocking, then wait for the proof.
var job = await tb.AnchorAsync("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855");
var waited = await tb.AnchorWaitAsync(job.Id); // polls up to 11 min
Tamper-Evident Logs (NIS2)
Anchor a log hash together with canonical metadata for NIS2 Article 21 audit trails. The server seals the metadata into the Merkle leaf, so the proof covers both the log content and its context.
using TrustBeat;
var tb = new TrustBeatClient("tb_live_...");
// Hash the log yourself — content never leaves your machine.
var logHash = await TrustBeatClient.HashFileAsync("app.log");
var meta = new LogMetadata(
new LogSource("/var/log/app.log", "Application log"),
new LogSourceIdentity(Hostname: "web-01", ServiceName: "payments"),
new LogTimeEnvelope("2026-04-15T00:00:00Z", "2026-04-15T23:59:59Z"));
var job = await tb.AnchorLogAsync(logHash, meta, "incident-2026-05");
Console.WriteLine($"{job.Id} {job.CombinedHash}");
// Wait for the qualified anchor (next batch, up to ~11 min).
var proof = await tb.AnchorLogWaitAsync(job.Id);
Console.WriteLine(proof.VerificationStatus); // "VERIFIED"
Signature Preservation
Preserves the electronic signatures of a signed file (PAdES, XAdES, CAdES, ASiC-E, ASiC-S) for 30
years. The signed file never reaches TrustBeat, and this SDK does not read it: the
trustbeat-signature extractor reads it on your machine and writes a submission JSON (the signatures and the digests that
bind them to the file), which the SDK sends unchanged.
trustbeat-signature extract contract.pdf --out contract.submission.json
var submission = await File.ReadAllTextAsync("contract.submission.json");
var rec = await tb.PreserveSignaturesAsync(submission, clientRef: "contract-17"); // one preserved file of your Signature Preservation plan
rec = await tb.GetSignaturePreservationAsync(rec.Id); // Status: pending -> anchored -> preserved
var recs = await tb.ListSignaturePreservationsAsync(limit: 50);
await File.WriteAllBytesAsync("package.zip", await tb.DownloadSignaturePreservationPackageAsync(rec.Id)); // offline verification
// Years later: the file presented now, extracted again
var now = await File.ReadAllTextAsync("now.submission.json");
var report = await tb.VerifySignaturePreservationAsync(rec.Id, now);
Console.WriteLine($"{report.Result} {report.Steps[0].Name} {report.Steps[0].Result}");
var pdf = await tb.VerifySignaturePreservationPdfAsync(rec.Id, now);
// Delete a record — final; the id is repeated as a guard, and the account is emailed
await tb.DeleteSignaturePreservationAsync(rec.Id, rec.Id);
Verifying later works with the original file only: trustbeat-signature extract it again and pass that
submission. A file that does not match is a report with failed steps, not an error. Offline, without
TrustBeat: trustbeat-signature verify contract.pdf --package package.zip.
Preserving needs a Signature Preservation subscription (Starter €19 / month for 100 files, Business €299 /
month for 2,000; no free trial). Without one the call fails with HTTP 402 — QuotaException, whose message
says SUBSCRIPTION_REQUIRED and gives the billing link. Over the monthly allowance the file is still preserved
and billed per file. It does not use Document Anchoring quota, and reading, downloading, verifying and
deleting records never need a plan.
Webhooks
If your account has a webhook secret configured, every delivery is signed with
an X-TrustBeat-Signature header. Verify it with the raw request body —
before any JSON parsing:
var ok = WebhookVerifier.VerifyWebhookSignature(rawBody, signatureHeader, webhookSecret);
if (!ok) throw new UnauthorizedAccessException("Invalid webhook signature");
Also available as TrustBeatClient.VerifyWebhookSignature(...). Rejects replays
older than 5 minutes by default (toleranceSecs parameter to override).
Portable proof bundles for offline verification: ExportAiDecisionAsync(id),
ExportVerificationAsync(id), ExportLogAsync(id) — each returns raw JSON bundle bytes.
Batches and rate limits
A batch carries up to 1,000 hashes and is all-or-nothing: if the call fails, none of them was queued. (API servers deployed before 26 Sep 2026 accept at most 100.)
Anchoring is rate-limited per account (see your plan). A rate-limited request (HTTP 429) is
retried automatically, waiting the Retry-After the server sends — twice by default.
Retrying is always safe: a refused submission was never queued. When the retries run out you
get the rate-limit error, carrying the wait the server asked for.
var tb = new TrustBeatClient("tb_live_...") { MaxRetries = 2 }; // 0 turns retrying off
try
{
var submission = await tb.AnchorBatchAsync(hashes); // up to TrustBeatClient.MaxBatchSize (1,000)
}
catch (RateLimitException ex)
{
Console.WriteLine($"still limited; server asked to wait {ex.RetryAfter}");
}
Requirements
- .NET 6+
- Zero runtime dependencies (System.Net.Http, System.Security.Cryptography from stdlib)
Documentation
Full API reference and guides at api.trustbeat.eu/docs
License
MIT — see LICENSE
Merkle algorithm
Every proof declares how it must be folded, in proof.MerkleAlgorithm:
| Value | Construction |
|---|---|
trustbeat-legacy-sha256 |
leaf = your hash, parent = SHA-256(left \|\| right) |
rfc6962-sha256 |
leaf = SHA-256(0x00 \|\| hash), parent = SHA-256(0x01 \|\| left \|\| right) |
Verify dispatches on it for you. A proof with no label was issued before the
field existed and is legacy. An algorithm this SDK version does not implement
throws UnsupportedAlgorithmException rather than returning false — "cannot
check" is not "invalid".
Audit event proofs
VerifyAuditEvent folds an audit event proof the same way:
var proof = await client.GetAuditEventProofAsync(eventId);
try
{
Console.WriteLine(client.VerifyAuditEvent(proof!));
}
catch (IncompleteProofException)
{
// The server predates API 1.46 and sent no MerkleRoot, so there is nothing
// to fold against. The proof is not invalid — verify it server-side instead.
}
Treating that exception as a failed proof would be wrong: it means "cannot check", not "tampered".
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.