Skip to content

Commit ebc70b7

Browse files
committed
General copy edits
1 parent 70ffa3c commit ebc70b7

5 files changed

Lines changed: 32 additions & 75 deletions

File tree

docs/context-settings.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ with open("config/settings.json", "r") as f:
9292
ctx = Context(settings)
9393
```
9494

95-
## Class diagram
95+
## Class diagram
9696

9797
```mermaid
9898
classDiagram
@@ -222,7 +222,7 @@ ctx = Context.from_dict({
222222
}
223223
})
224224

225-
builder = Builder(manifest_json, ctx)
225+
builder = Builder(manifest_json, context=ctx)
226226

227227
with open("source.jpg", "rb") as src, open("output.jpg", "w+b") as dst:
228228
builder.sign(signer, "image/jpeg", src, dst)
@@ -246,7 +246,7 @@ ctx = Context.from_dict({
246246
})
247247

248248
with open("manifest.c2pa", "rb") as archive:
249-
builder = Builder({}, ctx)
249+
builder = Builder({}, context=ctx)
250250
builder.with_archive(archive)
251251
# builder now has the archived definition + context settings
252252
```
@@ -644,7 +644,7 @@ ctx = Context.from_dict({
644644
}
645645
})
646646

647-
builder = Builder(manifest_json, ctx)
647+
builder = Builder(manifest_json, context=ctx)
648648
with open("source.jpg", "rb") as src, open("output.jpg", "w+b") as dst:
649649
builder.sign("image/jpeg", src, dst)
650650
```
@@ -664,7 +664,7 @@ signer = Signer.from_info(signer_info)
664664
ctx = Context(settings, signer)
665665
# signer is now invalid and must not be used directly again
666666

667-
builder = Builder(manifest_json, ctx)
667+
builder = Builder(manifest_json, context=ctx)
668668
with open("source.jpg", "rb") as src, open("output.jpg", "w+b") as dst:
669669
builder.sign("image/jpeg", src, dst)
670670
```
@@ -675,7 +675,7 @@ For full programmatic control, pass a `Signer` directly to `Builder.sign()`:
675675

676676
```py
677677
signer = Signer.from_info(signer_info)
678-
builder = Builder(manifest_json, ctx)
678+
builder = Builder(manifest_json, context=ctx)
679679

680680
with open("source.jpg", "rb") as src, open("output.jpg", "w+b") as dst:
681681
builder.sign(signer, "image/jpeg", src, dst)

docs/intents.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Using Builder intents
22

3-
_Intents_ enable validation, add required actions that are required by the C2PA specification, and help prevent invalid operations when using a `Builder`. Intents are about the operation (create, edit, update) executed on the source asset.
3+
_Intents_ enable validation, add the actions required by the C2PA specification, and help prevent invalid operations when using a `Builder`. Intents are about the operation (create, edit, update) executed on the source asset.
44

55
## Why use intents?
66

@@ -125,7 +125,7 @@ flowchart TD
125125

126126
## How intents relate to the source stream
127127

128-
The intent operates on the source passed to `sign()`, not on any ingredient added via `add_ingredient`.
128+
The intent operates on the source passed to `sign()`, not on any ingredient added via `add_ingredient()`.
129129

130130
The following diagram shows what happens at sign time for each intent:
131131

@@ -168,7 +168,7 @@ For `Edit` and `Update` intents, `Builder` looks at the source stream, and if no
168168

169169
### How intent relates to `add_ingredient`
170170

171-
The `Builder` intent controls what the Builder does with the source stream (source asset) at sign time. The `add_ingredient` method adds other ingredients explicitly. These are separate concerns.
171+
The `Builder` intent controls what the `Builder` does with the source stream (source asset) at sign time. The `add_ingredient` method adds other ingredients explicitly. These are separate concerns.
172172

173173
```mermaid
174174
flowchart TD

docs/selective-manifests.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ The fundamental workflow is:
3434

3535
## Reading an existing manifest
3636

37-
Use `Reader` with a `Context` to extract the manifest store JSON and any binary resources (thumbnails, manifest data). The source asset is never modified. The context is used for trust configuration (which certificates are trusted when validating signatures) and verification settings. See [Configuring Reader](../context.md#configuring-reader) and [Trust configuration](../context.md#trust-configuration) for details.
37+
Use `Reader` with a `Context` to extract the manifest store JSON and any binary resources (thumbnails, manifest data). The source asset is never modified. The context is used for trust configuration (which certificates are trusted when validating signatures) and verification settings. See [Configuring `Reader`](context-settings.md#with-reader) and [Trust configuration](context-settings.md#trust) for details.
3838

3939
```py
4040
ctx = Context.from_dict({
@@ -70,7 +70,7 @@ with open("thumbnail.jpg", "wb") as f:
7070
## Filtering into a new Builder
7171

7272
> [!NOTE]
73-
> All examples on this page use `Context` with `Reader` and `Builder`. For `Reader`, the context provides trust configuration and verification settings: `Reader(format, source, context=ctx)`. For `Builder`, the context provides custom settings (thumbnails, claim generator, intent): `Builder(manifest_json, context=ctx)`. When a signer is configured in the context, `builder.sign()` is called without a signer instance. See [Context](../context.md) for details.
73+
> All examples on this page use `Context` with `Reader` and `Builder`. For `Reader`, the context provides trust configuration and verification settings: `Reader(format, source, context=ctx)`. For `Builder`, the context provides custom settings (thumbnails, claim generator, intent): `Builder(manifest_json, context=ctx)`. When a signer is configured in the context, `builder.sign()` is called without a signer instance. See [Context and settings](context-settings.md) for details.
7474
7575
Each example below creates a **new `Builder`** from filtered data. The original asset and its manifest store are never modified.
7676

@@ -482,7 +482,7 @@ with open("signed_asset.jpg", "rb") as signed:
482482

483483
## Working with archives
484484

485-
A `Builder` represents a **working store**: a manifest that is being assembled but has not yet been signed. Archives serialize this working store (definition + resources) to a `.c2pa` binary format, allowing to save, transfer, or resume the work later. For more background on working stores and archives, see [Working stores](https://opensource.contentauthenticity.org/docs/rust-sdk/docs/working-stores).
485+
A `Builder` represents a **working store**: a manifest that is being assembled but has not yet been signed. Archives serialize this working store (definition + resources) to a `.c2pa` binary format, allowing to save, transfer, or resume the work later. For more background on working stores and archives, see [Working stores and archives](working-stores.md).
486486

487487
There are two distinct types of archives, sharing the same binary format but being conceptually different: builder archives (working store archives) and ingredient archives.
488488

@@ -632,7 +632,8 @@ layer_actions = [
632632
]
633633
```
634634

635-
> **Naming convention:** Vendor parameters must use reverse domain notation with period-separated components (e.g., `com.mycompany.tool`, `net.example.session_id`). Some namespaces (e.g., `c2pa` or `cawg`) may be reserved.
635+
> [!NOTE]
636+
> Vendor parameters must use reverse domain notation with period-separated components (for example, `com.mycompany.tool`, `net.example.session_id`). Some namespaces (for example, `c2pa` or `cawg`) may be reserved.
636637
637638
### Extracting ingredients from a working store
638639

@@ -692,7 +693,7 @@ with Builder({
692693
```
693694

694695
> [!NOTE]
695-
> When restoring from an archive, `with_archive()` preserves context settings while `from_archive()` does not. See [Working with archives](../working-stores.md#working-with-archives) for the full comparison.
696+
> When restoring from an archive, `with_archive()` preserves context settings while `from_archive()` does not. See [Working with archives](working-stores.md#working-with-archives) for the full comparison.
696697
697698
**Step 2:** Read the archive and extract ingredients:
698699

@@ -733,7 +734,7 @@ with Reader("application/c2pa", archive_stream, context=ctx) as reader:
733734
### Merging multiple working stores
734735

735736
> [!NOTE]
736-
> The `Builder` construction and signing in the merge workflow also support `Context`. The caller can pass `context=ctx` to `Builder()` and call `sign()` without a signer argument when the context has one. See [Context](../context.md) for details.
737+
> The `Builder` construction and signing in the merge workflow also support `Context`. The caller can pass `context=ctx` to `Builder()` and call `sign()` without a signer argument when the context has one. See [Context and settings](context-settings.md) for details.
737738
738739
In some cases it is necessary to merge ingredients from multiple working stores (builder archives) into a single `Builder`. This should be a **fallback strategy**. The recommended practice is to maintain a single active working store and add ingredients incrementally (archived ingredient catalogs help with this). Merging is available when multiple working stores must be consolidated.
739740

docs/usage.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,12 @@ Use the `Reader` to read C2PA data from the specified asset file.
154154

155155
This examines the specified media file for C2PA data and generates a report of any data it finds. If there are validation errors, the report includes a `validation_status` field.
156156

157-
An asset file may contain many manifests in a manifest store. The most recent manifest is identified by the value of the `active_manifest` field in the manifests map. The manifests may contain binary resources such as thumbnails which can be retrieved with `resource_to_stream` using the associated `identifier` field values and a `uri`.
157+
An asset file may contain many manifests in a manifest store. The most recent manifest is identified by the value of the `active_manifest` field in the manifests map. The manifests may contain binary resources such as thumbnails which can be retrieved with `resource_to_stream()` using the associated `identifier` field value as the URI.
158158

159159
> [!NOTE]
160160
> For a comprehensive reference to the JSON manifest structure, see the [Manifest store reference](https://opensource.contentauthenticity.org/docs/manifest/manifest-ref).
161161
162-
Pass a `Context` to apply custom settings to the Reader, such as trust anchors or verification flags.
162+
Pass a `Context` to apply custom settings to the `Reader`, such as trust anchors or verification flags.
163163

164164
```py
165165
try:
@@ -181,7 +181,7 @@ except Exception as err:
181181
> [!WARNING]
182182
> This example accesses the private key and security certificate directly from the local file system. This is fine during development, but doing so in production is insecure. Instead use a Key Management Service (KMS) or a hardware security module (HSM) to access the certificate and key; for example as show in the [C2PA Python Example](https://github.com/contentauth/c2pa-python-example).
183183
184-
Pass a `Context` to the Builder to apply custom settings during signing. The signer is still passed explicitly to `builder.sign()`.
184+
Pass a `Context` to the `Builder` to apply custom settings during signing. The signer is still passed explicitly to `builder.sign()`.
185185

186186
```py
187187
try:

docs/working-stores.md

Lines changed: 13 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ For more information, see:
4545

4646
- [Reading manifest stores from assets](#reading-manifest-stores-from-assets)
4747
- [Creating and signing manifests](#creating-and-signing-manifests)
48-
- [Embedded vs external manifests](#embedded-vs-external-manifests)
48+
- [Embedded versus external manifests](#embedded-versus-external-manifests)
4949

5050
### Working store
5151

@@ -59,7 +59,7 @@ A _working store_ is a `Builder` object representing an editable, in-progress ma
5959

6060
**Example:** When you create a `Builder` object and add assertions to it, you're dealing with a working store, as it is an "in progress" manifest being built.
6161

62-
For more information, see [Using Working stores](#using-working-stores).
62+
For more information, see [Using working stores](#using-working-stores).
6363

6464
### Archive
6565

@@ -68,7 +68,7 @@ A _C2PA archive_ (or just _archive_) contains the serialized bytes of a working
6868
**Characteristics:**
6969

7070
- Portable serialization of a working store (`Builder`).
71-
- Save an archive by using `Builder.to_archive()` and restore a full working store from an archive by using `Builder.with_archive()` (with a Builder created from a Context).
71+
- Save an archive by using `Builder.to_archive()` and restore a full working store from an archive by using `Builder.with_archive()` (with a `Builder` created from a `Context`).
7272
- Useful for separating manifest preparation ("work in progress") from final signing.
7373

7474
For more information, see [Working with archives](#working-with-archives).
@@ -99,7 +99,7 @@ with open("signed_image.jpg", "rb") as stream:
9999
manifest_json = reader.json()
100100
```
101101

102-
For full details on `Context` and `Settings`, see [Using Context to configure the SDK](../context.md).
102+
For full details on `Context` and `Settings`, see [Context and settings](context-settings.md).
103103

104104
### Understanding Reader output
105105

@@ -242,17 +242,6 @@ manifest_store_json = reader.json()
242242

243243
## Creating and signing manifests
244244

245-
### Creating a Builder (working store)
246-
247-
```py
248-
ctx = Context.from_dict({
249-
"builder": {
250-
"thumbnail": {"enabled": True}
251-
}
252-
})
253-
builder = Builder(manifest_json, context=ctx)
254-
```
255-
256245
### Creating a Signer
257246

258247
For testing, create a `Signer` with certificates and private key:
@@ -417,10 +406,11 @@ with open("source.jpg", "rb") as src, open("signed.jpg", "w+b") as dst:
417406

418407
## Working with ingredients
419408

420-
Ingredients represent source materials used to create an asset, preserving the provenance chain. Adding an ingredient to a manifest creates a verifiable link from the current asset back to its source material.
421-
The `relationship` field describes how the source (ingredient) was used: `"parentOf"` for a direct edit, `"componentOf"` for an element composited into a larger work, or `"inputTo"` for a general input.
409+
Ingredients represent source materials used to create an asset, preserving the provenance chain. Adding an ingredient to a manifest creates a verifiable link from the current asset back to its source material.
422410

423-
Ingredients themselves can be turned into ingredient archives (`.c2pa`). An ingredient archive is a serialized `Builder` with _exactly one_ ingredient. Once archived with only one ingredient, the Builder archive is an ingredient archive. Such ingredient archives can be used as ingredient in other working stores, as an ingredient archive can be added back directly to a working store (no un-archiving of the ingredient needed, use `application/c2pa` format when adding an ingredient archive to a Builder instance).
411+
The `relationship` field describes how the source (ingredient) was used: `"parentOf"` for a direct edit, `"componentOf"` for an element composited into a larger work, or `"inputTo"` for a general input.
412+
413+
Ingredients themselves can be turned into ingredient archives (`.c2pa`). An ingredient archive is a `Builder` archive containing _exactly one_ ingredient. Ingredient archives can be added directly as an ingredient to another working store using the `application/c2pa` MIME type — no un-archiving step is needed.
424414

425415
### Adding ingredients to a working store
426416

@@ -455,7 +445,7 @@ Specify the relationship between the ingredient and the current asset:
455445
| `componentOf` | The ingredient is a component used in this asset |
456446
| `inputTo` | The ingredient was an input to creating this asset |
457447

458-
Example with explicit relationship (builder is created with a Context as in the examples above):
448+
Example with explicit relationship:
459449

460450
```py
461451
ingredient_json = json.dumps({
@@ -591,7 +581,7 @@ By default, manifest stores are **embedded** directly into the asset file. You c
591581

592582
### Default: embedded manifest stores
593583

594-
By default, the manifest store is embedded in the output asset.
584+
By default, the manifest store is embedded in the output asset.
595585

596586
```py
597587
ctx = Context.from_dict({"builder": {"thumbnail": {"enabled": True}}, "signer": signer})
@@ -644,43 +634,9 @@ with open("source.jpg", "rb") as src, open("output.jpg", "w+b") as dst:
644634

645635
## Best practices
646636

647-
### Use Context for configuration
648-
649-
Use `Context` objects for SDK configuration:
650-
651-
```py
652-
ctx = Context.from_dict({
653-
"verify": {
654-
"verify_after_sign": True
655-
},
656-
"trust": {
657-
"user_anchors": trust_anchors_pem
658-
}
659-
})
660-
661-
builder = Builder(manifest_json, context=ctx)
662-
reader = Reader("asset.jpg", context=ctx)
663-
```
664-
665-
### Use ingredients to build provenance chains
666-
667-
Add ingredients to your manifests to maintain a provenance chain:
668-
669-
```py
670-
ctx = Context.from_dict({"builder": {"claim_generator_info": {"name": "my-app", "version": "0.1.0"}}, "signer": signer})
671-
builder = Builder(manifest_json, context=ctx)
672-
673-
ingredient_json = json.dumps({
674-
"title": "Original source",
675-
"relationship": "parentOf"
676-
})
677-
678-
with open("original.jpg", "rb") as ingredient:
679-
builder.add_ingredient(ingredient_json, "image/jpeg", ingredient)
680-
681-
with open("edited.jpg", "rb") as src, open("signed.jpg", "w+b") as dst:
682-
builder.sign("image/jpeg", src, dst)
683-
```
637+
- **Use `Context` for all configuration.** Pass a `Context` to `Builder` and `Reader` rather than using global state. See [Context and settings](context-settings.md).
638+
- **Use ingredients to build provenance chains.** Add a `parentOf` ingredient whenever editing an existing asset. See [Working with ingredients](#working-with-ingredients).
639+
- **Never hard-code private keys in production.** Use a Hardware Security Module (HSM) or Key Management Service (KMS) to access credentials.
684640

685641
## Additional resources
686642

0 commit comments

Comments
 (0)