Skip to content

Commit

Permalink
Existence Proofs -> Inclusion Proofs.
Browse files Browse the repository at this point in the history
Cleanup.
Update docs.
  • Loading branch information
wolfmcnally committed Oct 14, 2023
1 parent 3141a48 commit 3c0135b
Show file tree
Hide file tree
Showing 1,429 changed files with 1,457 additions and 1,114 deletions.
61 changes: 29 additions & 32 deletions Sources/Envelope/Envelope.docc/Envelope.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ The envelope protocol specifies a structured format for hierarchical binary data
- [Output Formats](https://github.com/BlockchainCommons/Gordian/blob/master/Envelope/OutputFormats.md) - A comparison of the various Envelope output formats.
- [Elision and Redaction](https://github.com/BlockchainCommons/Gordian/blob/master/Envelope/Elision.md) - Removing information without invalidating the digest tree.
- [Noncorrelation](https://github.com/BlockchainCommons/Gordian/blob/master/Envelope/Noncorrelation.md) - A discussion of noncorrelation, salt, and related concepts.
- [Existence Proofs](https://github.com/BlockchainCommons/Gordian/blob/master/Envelope/ExistenceProofs.md) - Computing and verifying minimal proofs that an envelope contains some target information.
- [Inclusion Proofs](https://github.com/BlockchainCommons/Gordian/blob/master/Envelope/InclusionProofs.md) - Computing and verifying minimal proofs that an envelope contains some target information.
- [Diffing Envelopes](https://github.com/BlockchainCommons/Gordian/blob/master/Envelope/Diffing.md) - Computing and applying the changes between two envelopes.
- [Envelope Expressions](https://github.com/BlockchainCommons/Gordian/blob/master/Envelope/Expressions.md) - Encoding machine-evaluatable expressions using envelopes.

## Topics

### Essentials

- <doc:Overview>
- <doc:OverviewArticle>
- <doc:Examples>
- ``Envelope/Envelope``

Expand Down Expand Up @@ -103,13 +103,12 @@ The envelope protocol specifies a structured format for hierarchical binary data
- ``Envelope/Envelope/extractObject(_:forPredicate:)-23b00``
- ``Envelope/Envelope/extractObject(_:forPredicate:)-1lsfm``
- ``Envelope/Envelope/extractObject(_:forPredicate:)-675fq``
- ``Envelope/Envelope/extractObject(forPredicate:)-7at6i``
- ``Envelope/Envelope/extractObject(forPredicate:)-ypga``
- ``Envelope/Envelope/extractObject(forPredicate:)-5pof``
- ``Envelope/Envelope/extractObjects(_:forPredicate:)-55b0m``
- ``Envelope/Envelope/extractObjects(_:forPredicate:)-85q2w``
- ``Envelope/Envelope/extractObjects(forPredicate:)-1cnrl``
- ``Envelope/Envelope/extractObjects(forPredicate:)-9e4gg``
- ``Envelope/Envelope/object(forPredicate:)-atr9``
- ``Envelope/Envelope/object(forPredicate:)-3pxqr``
- ``Envelope/Envelope/object(forPredicate:)-40b0q``
- ``Envelope/Envelope/objects(forPredicate:)-72jru``
- ``Envelope/Envelope/objects(forPredicate:)-1xpx1``
- ``Envelope/Envelope/isA(_:)``
- ``Envelope/Envelope/id(_:)``
- ``Envelope/Envelope/removeAssertion(_:)``
Expand All @@ -125,15 +124,15 @@ The envelope protocol specifies a structured format for hierarchical binary data
- ``Envelope/Envelope/shallowDigests``
- ``Envelope/Envelope/deepDigests``
- ``Envelope/Envelope/digests(levelLimit:)``
- ``Envelope/Envelope/elideRemoving(_:encryptingWith:)-66yx0``
- ``Envelope/Envelope/elideRemoving(_:encryptingWith:)-4p0a2``
- ``Envelope/Envelope/elideRemoving(_:encryptingWith:)-8tgiz``
- ``Envelope/Envelope/elideRevealing(_:encryptingWith:)-8o34i``
- ``Envelope/Envelope/elideRevealing(_:encryptingWith:)-139hi``
- ``Envelope/Envelope/elideRevealing(_:encryptingWith:)-3aeex``
- ``Envelope/Envelope/elide(_:isRevealing:encryptingWith:)-8qngj``
- ``Envelope/Envelope/elide(_:isRevealing:encryptingWith:)-8w1o6``
- ``Envelope/Envelope/elide(_:isRevealing:encryptingWith:)-i3mw``
- ``Envelope/Envelope/elideRemoving(_:action:)-4qvgb``
- ``Envelope/Envelope/elideRemoving(_:action:)-3w305``
- ``Envelope/Envelope/elideRemoving(_:action:)-94hor``
- ``Envelope/Envelope/elideRevealing(_:action:)-6hjlp``
- ``Envelope/Envelope/elideRevealing(_:action:)-8brht``
- ``Envelope/Envelope/elideRevealing(_:action:)-8g4hj``
- ``Envelope/Envelope/elide(_:isRevealing:action:)-9gy3k``
- ``Envelope/Envelope/elide(_:isRevealing:action:)-12xz7``
- ``Envelope/Envelope/elide(_:isRevealing:action:)-97kvt``
- ``Envelope/Envelope/unelide(_:)``

### Wrapping Envelopes
Expand Down Expand Up @@ -161,9 +160,9 @@ The envelope protocol specifies a structured format for hierarchical binary data

### Signatures

- ``Envelope/Envelope/sign(with:tag:randomGenerator:)``
- ``Envelope/Envelope/sign(with:note:tag:randomGenerator:)``
- ``Envelope/Envelope/sign(with:uncoveredAssertions:tag:randomGenerator:)``
- ``Envelope/Envelope/sign(with:tag:)``
- ``Envelope/Envelope/sign(with:note:tag:)``
- ``Envelope/Envelope/sign(with:uncoveredAssertions:tag:)``
- ``Envelope/Envelope/verifiedBy(signature:note:)``
- ``Envelope/Envelope/signatures``
- ``Envelope/Envelope/isVerifiedSignature(_:publicKeys:)``
Expand Down Expand Up @@ -202,7 +201,6 @@ The envelope protocol specifies a structured format for hierarchical binary data

### Splitting Envelopes with SSKR

- ``Envelope/Envelope/split(groupThreshold:groups:contentKey:testRandomGenerator:)``
- ``Envelope/Envelope/init(shares:)``
- ``Envelope/Envelope/addSSKRShare(_:)``

Expand All @@ -213,15 +211,14 @@ The envelope protocol specifies a structured format for hierarchical binary data
- ``Envelope/Envelope/addSalt(_:)-9lg7y``
- ``Envelope/Envelope/addSalt(_:)-7vbe0``
- ``Envelope/Envelope/addSalt(_:)-8vq5g``
- ``Envelope/Envelope/addSalt(using:)``

### Existence Proofs
### Inclusion Proofs

- <doc:ExistenceProofs>
- <doc:InclusionProofs>
- ``Envelope/Envelope/proof(contains:)-jpk9``
- ``Envelope/Envelope/proof(contains:)-fnjv``
- ``Envelope/Envelope/confirm(contains:using:)-28uny``
- ``Envelope/Envelope/confirm(contains:using:)-bjef``
- ``Envelope/Envelope/confirm(contains:proof:)-7h8bb``
- ``Envelope/Envelope/confirm(contains:proof:)-83824``

### Diffing Envelopes

Expand All @@ -242,13 +239,13 @@ The envelope protocol specifies a structured format for hierarchical binary data

### Envelope Expressions: Parameters

- ``Envelope/Envelope/addParameter(_:value:)-8g1uy``
- ``Envelope/Envelope/addParameter(_:value:)-5j06r``
- ``Envelope/Envelope/addParameter(_:value:)-2y1wr``
- ``Envelope/Envelope/addParameter(_:value:)-1e5yr``
- ``Envelope/Parameter``
- ``Envelope/Envelope/extractObject(_:forParameter:)``
- ``Envelope/Envelope/extractObjects(_:forParameter:)``
- ``Envelope/Envelope/parameter(_:value:)-8ag8n``
- ``Envelope/Envelope/parameter(_:value:)-9sbgf``
- ``Envelope/Envelope/parameter(_:value:)-12r6u``
- ``Envelope/Envelope/parameter(_:value:)-6o9s3``

### Envelope Expressions: Requests and Responses

Expand All @@ -261,12 +258,12 @@ The envelope protocol specifies a structured format for hierarchical binary data
- ``Envelope/Envelope/results()``
- ``Envelope/Envelope/result(_:)``
- ``Envelope/Envelope/results(_:)``
- ``Envelope/Envelope/isResultOK()``
- ``Envelope/Envelope/isResultOK``
- ``Envelope/Envelope/error(_:)``

### Debugging Tools

- ``Envelope/Envelope/checkEncoding(knownTags:)``
- ``Envelope/checkEncoding(tags:)``
- ``Envelope/EnvelopeError``

### Test Vectors
Expand Down
7 changes: 0 additions & 7 deletions Sources/Envelope/Envelope.docc/ExistenceProofs.md

This file was deleted.

7 changes: 7 additions & 0 deletions Sources/Envelope/Envelope.docc/InclusionProofs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Inclusion Proofs

Computing and verifying minimal proofs that an envelope contains some target information.

## Documentation on GitHub

- [Inclusion Proofs](https://github.com/BlockchainCommons/Gordian/blob/master/Envelope/InclusionProofs.md)
File renamed without changes.
20 changes: 5 additions & 15 deletions Sources/Envelope/Extensions/Proof.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import SecureComponents
public extension Envelope {
/// Returns a proof that this envelope includes every element in the target set.
///
/// - Parameter target: The elements if this envelope that the proof must include.
/// - Parameter target: The elements of this envelope that the proof must include.
/// - Returns: The proof, of `nil` if it cannot be proven that the envelope contains every element in the target set.
func proof(contains target: Set<Digest>) -> Envelope? {
let revealSet = revealSet(of: target)
Expand All @@ -14,7 +14,7 @@ public extension Envelope {

/// Returns a proof that this envelope includes the target element.
///
/// - Parameter target: The elements if this envelope that the proof must include.
/// - Parameter target: The element of this envelope that the proof must include.
/// - Returns: The proof, of `nil` if it cannot be proven that the envelope contains the targeted element.
func proof(contains target: DigestProvider) -> Envelope? {
proof(contains: [target.digest])
Expand All @@ -27,7 +27,7 @@ public extension Envelope {
/// - proof: The inclusion proof to use.
///
/// - Returns: `true` if every element of `target` is in this envelope as shown by `proof`, `false` otherwise.
func confirm(contains target: Set<Digest>, using proof: Envelope) -> Bool {
func confirm(contains target: Set<Digest>, proof: Envelope) -> Bool {
self.digest == proof.digest && proof.containsAll(in: target)
}

Expand All @@ -38,8 +38,8 @@ public extension Envelope {
/// - proof: The inclusion proof to use.
///
/// - Returns: `true` if `target` is in this envelope as shown by `proof`, `false` otherwise.
func confirm(contains target: DigestProvider, using proof: Envelope) -> Bool {
confirm(contains: [target.digest], using: proof)
func confirm(contains target: DigestProvider, proof: Envelope) -> Bool {
confirm(contains: [target.digest], proof: proof)
}
}

Expand All @@ -50,22 +50,12 @@ extension Envelope {
return result
}

func revealSet(of target: DigestProvider) -> Set<Digest> {
revealSet(of: [target.digest])
}

func containsAll(in target: Set<Digest>) -> Bool {
var target = target
removeAllFound(in: &target)
return target.isEmpty
}

func contains(_ target: DigestProvider) -> Bool {
containsAll(in: [target.digest])
}
}

extension Envelope {
func revealSets(of target: Set<Digest>, current: Set<Digest>, result: inout Set<Digest>) {
var current = current
current.insert(digest)
Expand Down
2 changes: 1 addition & 1 deletion Tests/EnvelopeTests/Core/TypeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class TypeTests: XCTestCase {
// print(envelope.diagnostic(annotate: true, context: globalFormatContext))
// print(envelope.diagnostic())

let e = Envelope(Date(timeIntervalSince1970: 1693454262.5))//.checkEncoding()
let _ = try Envelope(Date(timeIntervalSince1970: 1693454262.5)).checkEncoding()
// print(e.format(context: globalFormatContext))
// print(e.diagnostic(annotate: true, context: globalFormatContext))
// print(e.diagnostic())
Expand Down
8 changes: 4 additions & 4 deletions Tests/EnvelopeTests/ProofTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class ProofTests: XCTestCase {

/// The third party then uses the previously known and trusted root to confirm that
/// the envelope does indeed contain a "knows bob" assertion.
XCTAssertTrue(aliceFriendsRoot.confirm(contains: knowsBobAssertion, using: aliceKnowsBobProof))
XCTAssertTrue(aliceFriendsRoot.confirm(contains: knowsBobAssertion, proof: aliceKnowsBobProof))
}

func testMultiPosition() throws {
Expand Down Expand Up @@ -146,14 +146,14 @@ class ProofTests: XCTestCase {
)

/// The proof confirms the address, as intended.
XCTAssertTrue(credentialRoot.confirm(contains: addressAssertion, using: addressProof))
XCTAssertTrue(credentialRoot.confirm(contains: addressAssertion, proof: addressProof))

/// Assertions without salt can also be confirmed.
let issuerAssertion = Envelope(.issuer, "State of Example")
XCTAssertTrue(credentialRoot.confirm(contains: issuerAssertion, using: addressProof))
XCTAssertTrue(credentialRoot.confirm(contains: issuerAssertion, proof: addressProof))

/// The proof cannot be used to confirm salted assertions.
let firstNameAssertion = Envelope("firstName", "John")
XCTAssertFalse(credentialRoot.confirm(contains: firstNameAssertion, using: addressProof))
XCTAssertFalse(credentialRoot.confirm(contains: firstNameAssertion, proof: addressProof))
}
}
38 changes: 0 additions & 38 deletions Tests/EnvelopeTests/TestVectors/TableOfContents.swift
Original file line number Diff line number Diff line change
@@ -1,44 +1,6 @@
import Foundation
import XCTest

//final class TableOfContents: XCTestCase {
// func testGenerateTableOfContents() {
// (0..<tocItems.count).forEach {
// print(formatTableOfContents(itemIndex: $0))
// }
// }
//}
//
//let tocItems: [(title: String, filename: String)] = [
// ("Envelope Introduction", "INTRODUCTION.md"),
// ("Envelope Overview", "OVERVIEW.md"),
// ("Envelope Notation", "ENVELOPE-NOTATION.md"),
// ("Output Formats", "OUTPUT-FORMATS.md"),
// ("Envelope Expressions", "ENVELOPE-EXPRESSIONS.md"),
// ("Definitions", "DEFINITIONS.md"),
// ("Examples", "EXAMPLES.md"),
// ("Noncorrelation", "NONCORRELATION.md"),
// ("Elision and Redaction", "ELISION-REDACTION.md"),
// ("Existence Proofs", "EXISTENCE-PROOFS.md"),
// ("Diffing Envelopes", "DIFFING.md"),
// ("Appendix A: Envelope Test Vectors", "A-ENVELOPE-TEST-VECTORS.md"),
// ("Appendix B: Envelope SSKR Test Vectors", "B-ENVELOPE-SSKR-TEST-VECTORS.md"),
//]
//
//func tocFilename(at index: Int) -> String {
// "\(pad: index, toWidth: 2)-\(tocItems[index].filename)"
//}

//fileprivate func item(itemIndex: Int, index: Int) -> String {
// let title = tocItems[index].title
// let target = tocFilename(at: index)
// if index == itemIndex {
// return "\(title): This document"
// } else {
// return link(title, target)
// }
//}

@StringBuilder
func documentHeader(_ name: String) -> String {
header1(name)
Expand Down
9 changes: 9 additions & 0 deletions docs/css/chunk-c0335d80.10a2f091.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions docs/css/documentation-topic.1d1eec04.css

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions docs/css/documentation-topic.3bca6578.css

This file was deleted.

Loading

0 comments on commit 3c0135b

Please sign in to comment.