Skip to content

Commit efb7952

Browse files
committed
Add high-trust-rdf-bloom-tamper-contrast example
1 parent aa0f388 commit efb7952

File tree

2 files changed

+58
-14
lines changed

2 files changed

+58
-14
lines changed

examples/high-trust-rdf-bloom-tamper-contrast.n3

Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ==============================================================================
1+
# =============================================================================
22
# High-trust RDF Bloom filter hardening: trusted artifact vs tampered artifact
33
#
44
# Why this example exists:
@@ -19,16 +19,16 @@
1919
# * :trustedArtifact is accepted under both the weak and hardened rules
2020
# * :tamperedArtifact can pass the weak budget-only path
2121
# * :tamperedArtifact is rejected by the hardened path, with explicit reasons
22-
# ==============================================================================
22+
# =============================================================================
2323

2424
@prefix : <http://example.org/high-trust-rdf#>.
2525
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
2626
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
2727
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
2828

29-
# ----------------
29+
# -----------------
3030
# Trusted artifact
31-
# ----------------
31+
# -----------------
3232

3333
:trustedArtifact a :HighTrustRdfArtifact;
3434
:canonicalTripleCount 1200;
@@ -45,9 +45,9 @@
4545
:maybePositivePolicy :ConfirmAgainstCanonicalGraph;
4646
:definiteNegativePolicy :ReturnAbsent.
4747

48-
# -----------------
48+
# ------------------
4949
# Tampered artifact
50-
# -----------------
50+
# ------------------
5151

5252
:tamperedArtifact a :HighTrustRdfArtifact;
5353
:canonicalTripleCount 1200;
@@ -94,12 +94,11 @@
9494
?a :lambda ?lambda.
9595
}.
9696

97-
# ----------------------------------------------------------------------------
97+
# ==========================
9898
# Weak path (pre-hardening)
99-
#
99+
# ==========================
100100
# This path deliberately computes a budget envelope from whatever numbers were
101101
# supplied, without first proving that they form a sane certificate.
102-
# ----------------------------------------------------------------------------
103102

104103
{
105104
?a :hashFunctions ?k;
@@ -158,9 +157,9 @@
158157
?a :weakDecision :AcceptUnderWeakBudgetOnlyRules.
159158
}.
160159

161-
# ------------------------------
160+
# ==============================
162161
# Hardened path (current design)
163-
# ------------------------------
162+
# ==============================
164163

165164
# Parameter sanity is explicit and required.
166165
{
@@ -263,11 +262,10 @@
263262
?a :hardenedDecision :AcceptForHighTrustUse.
264263
}.
265264

266-
# -------------------------------------------------
265+
# ======================================
267266
# Explicit tamper evidence / reject path
268-
#
267+
# ======================================
269268
# These rules make hardening visible in the output.
270-
# -------------------------------------------------
271269

272270
{
273271
?a :bloomBits ?m.
@@ -324,6 +322,42 @@
324322
?a :hardenedDecision :RejectForHighTrustUse.
325323
}.
326324

325+
326+
# ---------------------------------
327+
# Explicit contrast for wide readers
328+
# ---------------------------------
329+
330+
{
331+
:trustedArtifact :weakDecision :AcceptUnderWeakBudgetOnlyRules;
332+
:hardenedDecision :AcceptForHighTrustUse.
333+
}
334+
=>
335+
{
336+
:result :trustedArtifactBehavesAsExpected true.
337+
}.
338+
339+
{
340+
:tamperedArtifact :weakDecision :AcceptUnderWeakBudgetOnlyRules;
341+
:hardenedDecision :RejectForHighTrustUse.
342+
}
343+
=>
344+
{
345+
:result :tamperedArtifactShowsWhyHardeningMatters true.
346+
}.
347+
348+
{
349+
?a :weakDecision ?weak;
350+
:hardenedDecision ?hard.
351+
}
352+
log:query
353+
{
354+
:result :decision [
355+
:artifact ?a;
356+
:weak ?weak;
357+
:hardened ?hard
358+
].
359+
}.
360+
327361
# ---------------
328362
# Readable output
329363
# ---------------

examples/output/high-trust-rdf-bloom-tamper-contrast.n3

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
@prefix : <http://example.org/high-trust-rdf#> .
22
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
33

4+
:result :decision [
5+
:artifact :trustedArtifact ;
6+
:hardened :AcceptForHighTrustUse ;
7+
:weak :AcceptUnderWeakBudgetOnlyRules
8+
] .
9+
:result :decision [
10+
:artifact :tamperedArtifact ;
11+
:hardened :RejectForHighTrustUse ;
12+
:weak :AcceptUnderWeakBudgetOnlyRules
13+
] .
414
:result :rejectReason [
515
:artifact :tamperedArtifact ;
616
:why :NonPositiveBloomBits

0 commit comments

Comments
 (0)