eif-sdk 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
eif_sdk-0.1.0/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
eif_sdk-0.1.0/NOTICE ADDED
@@ -0,0 +1,12 @@
1
+ Evidence Integrity Framework (EIF)
2
+ Copyright 2026 NeuralWeaves Technology Private Limited and the EIF contributors
3
+
4
+ This product includes software developed by NeuralWeaves Technology Private
5
+ Limited and contributors to the eif-format project.
6
+
7
+ The EIF Format Specification and this reference implementation are published
8
+ under the Apache License, Version 2.0, which includes an express grant of
9
+ patent rights from contributors to users. See LICENSE for the full terms.
10
+
11
+ Portions of the Merkle tree construction follow the approach described in
12
+ RFC 6962 (Certificate Transparency), IETF, 2013.
eif_sdk-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,199 @@
1
+ Metadata-Version: 2.4
2
+ Name: eif-sdk
3
+ Version: 0.1.0
4
+ Summary: Reference implementation of the Evidence Integrity Framework (EIF) image provenance format
5
+ License-Expression: Apache-2.0
6
+ Project-URL: Homepage, https://eif-format.org
7
+ Project-URL: Specification, https://github.com/eif-format/specification
8
+ Project-URL: Source, https://github.com/eif-format/eif-sdk
9
+ Project-URL: Issues, https://github.com/eif-format/eif-sdk/issues
10
+ Keywords: provenance,authenticity,forensics,image,cryptography,c2pa
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Legal Industry
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Multimedia :: Graphics
16
+ Classifier: Topic :: Security :: Cryptography
17
+ Requires-Python: >=3.9
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ License-File: NOTICE
21
+ Requires-Dist: cryptography>=41.0
22
+ Requires-Dist: Pillow>=10.0
23
+ Provides-Extra: dev
24
+ Requires-Dist: pytest>=7.4; extra == "dev"
25
+ Requires-Dist: pytest-cov>=4.1; extra == "dev"
26
+ Requires-Dist: ruff==0.14.4; extra == "dev"
27
+ Dynamic: license-file
28
+
29
+ # EIF SDK
30
+
31
+ **Reference implementation of the Evidence Integrity Framework — an open file format that binds a photograph to cryptographic proof of how it was captured.**
32
+
33
+ [![CI](https://github.com/eif-format/eif-sdk/actions/workflows/ci.yml/badge.svg)](https://github.com/eif-format/eif-sdk/actions/workflows/ci.yml)
34
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/eif-format/eif-sdk/blob/main/LICENSE)
35
+ [![Spec](https://img.shields.io/badge/spec-v1.0-informational)](https://github.com/eif-format/specification)
36
+
37
+ ---
38
+
39
+ ## The problem
40
+
41
+ A claims adjuster receives a photograph of a damaged bumper. A lender receives a photograph of equipment they are financing. A court receives a photograph of a scene. In each case a decision worth money follows from pixels, and in 2026 pixels can be fabricated by anyone with a phone in under two minutes.
42
+
43
+ The instinctive response is detection: build a classifier that spots fakes. We tried that first and published the result. Across 150+ images and four physics-based forensic probes, the best classifier we could build reached 74% accuracy under leave-one-out cross-validation. That is not a number you can deny a claim with, and it gets worse every time a generative model improves. Detection is a race against an adversary who is improving faster than the defence.
44
+
45
+ EIF takes the other route. Rather than asking "is this image fake?", it makes it possible to ask "can this image prove where it came from?" — a question with a cryptographic answer instead of a statistical one.
46
+
47
+ ## What EIF does
48
+
49
+ An `.eif` file contains five blocks:
50
+
51
+ | Block | Purpose |
52
+ |---|---|
53
+ | **Capture Attestation Block** | When, what device, what software, what location, and against what server-issued challenge |
54
+ | **Structural Integrity Layer** | A Merkle tree over a grid of image tiles |
55
+ | **Cryptographic Seal** | One ECDSA P-256 signature binding the CAB, the tree root, and the image data together |
56
+ | **Provenance Chain** | Append-only, hash-linked record of every hand the file passed through |
57
+ | **Image Data** | The pixels |
58
+
59
+ Three properties follow from that structure.
60
+
61
+ **The proof cannot be stripped.** It is not metadata sitting beside the image; it is the container. Remove it and you no longer have an EIF file — you have an ordinary image with no claim to make.
62
+
63
+ **Tampering is localised, not just detected.** Because the signature covers a per-tile Merkle tree rather than a single whole-image hash, a verifier can recompute the tree and report exactly which tiles changed. "This file is invalid" is not useful to a claims handler. "Tiles 34, 35, 44 and 45 changed — the region around the left headlight" is.
64
+
65
+ **Verification works offline.** Four of the five verification levels complete with no network access, no trust service, and no vendor. Evidence has to be checkable in a courtroom, in an adjuster's car, and in ten years' time, none of which guarantee a working connection to somebody's server.
66
+
67
+ ## Install
68
+
69
+ ```bash
70
+ pip install eif-sdk
71
+ ```
72
+
73
+ From source:
74
+
75
+ ```bash
76
+ git clone https://github.com/eif-format/eif-sdk.git
77
+ cd eif-sdk
78
+ pip install -e ".[dev]"
79
+ pytest
80
+ ```
81
+
82
+ ## Use it in sixty seconds
83
+
84
+ ```bash
85
+ eif keygen --out signing-key.pem
86
+ eif capture damage.png --key signing-key.pem --challenge "srv-nonce-7f3a"
87
+ eif verify damage.eif --key signing-key.pub.pem
88
+ ```
89
+
90
+ Then prove the localisation claim to yourself:
91
+
92
+ ```bash
93
+ eif tamper-test damage.eif --x 300 --y 200 --width 80 --height 60
94
+ ```
95
+
96
+ ```
97
+ Verification result: NOT VALID
98
+ L1 Format pass
99
+ L2 Cryptographic FAIL
100
+ - seal signature does not verify over this CAB, structural integrity layer and image data
101
+ - recomputed tile tree does not match the sealed root
102
+ L3 Temporal pass
103
+ L4 Provenance pass
104
+ L5 Device not evaluated
105
+
106
+ Tamper localisation: 4 of 80 tiles altered
107
+ tile 34 (col 4, row 3) pixels [256,192]-[320,256]
108
+ tile 35 (col 5, row 3) pixels [320,192]-[384,256]
109
+ tile 44 (col 4, row 4) pixels [256,256]-[320,320]
110
+ tile 45 (col 5, row 4) pixels [320,256]-[384,320]
111
+ ```
112
+
113
+ ## Use it from Python
114
+
115
+ ```python
116
+ from eif import CaptureAttestation, Device, EIFFile, KeyPair, Location, imaging
117
+
118
+ keypair = KeyPair.generate()
119
+
120
+ attestation = CaptureAttestation(
121
+ device=Device(
122
+ make="Acme", model="Field-1", os="Android 15",
123
+ app_id="com.example.claims", app_version="2.3.0",
124
+ ),
125
+ location=Location(latitude="12.9716", longitude="77.5946", accuracy_m=8),
126
+ challenge="srv-nonce-7f3a", # issued by your server, seconds before capture
127
+ session_id="claim-2026-0041",
128
+ )
129
+
130
+ sealed = EIFFile.capture(imaging.encode_png("damage.jpg"), attestation, keypair)
131
+ sealed.save("damage.eif")
132
+ ```
133
+
134
+ Verifying, with the signing key pinned:
135
+
136
+ ```python
137
+ report = EIFFile.load("damage.eif").verify(expected_public_key=keypair.public_key)
138
+
139
+ if not report["valid"]:
140
+ for tile in report["L2_cryptographic"]["altered_tiles"]:
141
+ print(f"altered region: {tile['bounds']}")
142
+ ```
143
+
144
+ ## The verification protocol
145
+
146
+ | Level | Question | Network |
147
+ |---|---|---|
148
+ | **L1 Format** | Is this a well-formed EIF file? | offline |
149
+ | **L2 Cryptographic** | Does the seal verify over this CAB, tree and image? If not, which tiles changed? | offline |
150
+ | **L3 Temporal** | Are the timestamps internally coherent and plausible? | offline |
151
+ | **L4 Provenance** | Is the chain of custody unbroken? | offline |
152
+ | **L5 Device** | Is the signing key attested to real hardware? | online |
153
+
154
+ Verification never raises on an invalid file; it returns a structured report. Each level is reported independently because the levels fail for different reasons and a relying party needs to make different decisions about each.
155
+
156
+ ## The challenge, and the attack it addresses
157
+
158
+ Provenance systems that only record "a real camera took this photograph" are defeated by an attack that costs nothing: generate a fake image, display it on a screen, photograph the screen with a genuine camera. The capture is real, the signature is honest, and the content is fabricated.
159
+
160
+ EIF's answer is the `challenge` field. Your server issues a nonce immediately before capture; the capture pipeline binds it into the Capture Attestation Block before signing. An image produced any other way cannot carry a fresh, unused, server-recognised nonce for a session you opened. This does not make recapture impossible — nothing in software does — but it moves the attack from "free and instant" to "requires real-time control of a device inside your session," which is a different economic proposition for a fraudster.
161
+
162
+ Captures with no challenge are permitted and are honestly weaker. Treat them as a lower assurance tier.
163
+
164
+ ## Where this fits alongside C2PA and JPEG Trust
165
+
166
+ EIF is not a competitor to [C2PA Content Credentials](https://c2pa.org) or [JPEG Trust (ISO/IEC 21617)](https://jpeg.org/jpegtrust/), and positioning it as one would be dishonest. Those efforts have the ecosystem — camera manufacturers, platforms, an ISO process — and they solve the problem they set out to solve: recording and travelling with a content history across a general-purpose media supply chain.
167
+
168
+ EIF addresses a narrower case those systems do not target: **high-assurance evidence capture**, where the relying party controls the capture pipeline, the stakes justify a stricter model, and two specific requirements apply that general provenance does not meet — knowing *where* in the frame an image changed, and binding a capture to a session the relying party opened.
169
+
170
+ An EIF file can carry a C2PA manifest as an annotation, and an EIF verifier can treat a valid Content Credential as one input among several. Interoperability notes are in the [specification repository](https://github.com/eif-format/specification/blob/main/spec/Interop.md).
171
+
172
+ ## Honest limitations
173
+
174
+ Read these before you build anything on this.
175
+
176
+ - **v1.0 handles losslessly-decodable images only (PNG).** JPEG decoding is not bit-exact across libraries, so tile hashes computed at capture would not reliably recompute on a verifier's machine. Rather than ship a structural integrity layer that produces false tamper reports, lossy profiles are deferred. This is the largest practical limitation and the first thing v1.1 must address.
177
+ - **A signature proves who signed, not that the content is true.** EIF can tell you an image was sealed by a specific key at a specific time and has not changed since. It cannot tell you the adjuster photographed the right car.
178
+ - **Software keys are only as good as the device.** The security of the whole scheme rests on the private key. This SDK generates software keys, which are appropriate for development. Production capture should sign inside a TEE, Secure Enclave, or StrongBox-backed keystore, and L5 exists to let a verifier check that.
179
+ - **The provenance chain records what was recorded.** It detects alteration of the sequence. It cannot detect a handler who simply never appended an entry.
180
+ - **No mobile SDK yet.** Android and iOS are the platforms this format actually needs. They are not built.
181
+ - **The specification is v1.0 and has not been through independent security review.** If you find a flaw, please tell us — see [SECURITY.md](https://github.com/eif-format/eif-sdk/blob/main/SECURITY.md).
182
+
183
+ ## Repositories
184
+
185
+ | Repository | Contents |
186
+ |---|---|
187
+ | [`specification`](https://github.com/eif-format/specification) | The format specification, JSON schemas, and shared test vectors |
188
+ | [`eif-sdk`](https://github.com/eif-format/eif-sdk) | This reference implementation |
189
+ | [`research`](https://github.com/eif-format/research) | Papers, datasets and methodology |
190
+
191
+ ## Contributing
192
+
193
+ Independent implementations in other languages are the single most valuable contribution. A format with one implementation is a product; a format with several is a standard. See [CONTRIBUTING.md](https://github.com/eif-format/eif-sdk/blob/main/CONTRIBUTING.md).
194
+
195
+ ## Licence
196
+
197
+ Apache License 2.0. See [LICENSE](https://github.com/eif-format/eif-sdk/blob/main/LICENSE) and [NOTICE](https://github.com/eif-format/eif-sdk/blob/main/NOTICE).
198
+
199
+ The Apache 2.0 licence includes an express patent grant covering this implementation. Patent applications relating to the format have been filed in India; the licence grant applies to the contributed code as described in Section 3 of the licence.
@@ -0,0 +1,171 @@
1
+ # EIF SDK
2
+
3
+ **Reference implementation of the Evidence Integrity Framework — an open file format that binds a photograph to cryptographic proof of how it was captured.**
4
+
5
+ [![CI](https://github.com/eif-format/eif-sdk/actions/workflows/ci.yml/badge.svg)](https://github.com/eif-format/eif-sdk/actions/workflows/ci.yml)
6
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/eif-format/eif-sdk/blob/main/LICENSE)
7
+ [![Spec](https://img.shields.io/badge/spec-v1.0-informational)](https://github.com/eif-format/specification)
8
+
9
+ ---
10
+
11
+ ## The problem
12
+
13
+ A claims adjuster receives a photograph of a damaged bumper. A lender receives a photograph of equipment they are financing. A court receives a photograph of a scene. In each case a decision worth money follows from pixels, and in 2026 pixels can be fabricated by anyone with a phone in under two minutes.
14
+
15
+ The instinctive response is detection: build a classifier that spots fakes. We tried that first and published the result. Across 150+ images and four physics-based forensic probes, the best classifier we could build reached 74% accuracy under leave-one-out cross-validation. That is not a number you can deny a claim with, and it gets worse every time a generative model improves. Detection is a race against an adversary who is improving faster than the defence.
16
+
17
+ EIF takes the other route. Rather than asking "is this image fake?", it makes it possible to ask "can this image prove where it came from?" — a question with a cryptographic answer instead of a statistical one.
18
+
19
+ ## What EIF does
20
+
21
+ An `.eif` file contains five blocks:
22
+
23
+ | Block | Purpose |
24
+ |---|---|
25
+ | **Capture Attestation Block** | When, what device, what software, what location, and against what server-issued challenge |
26
+ | **Structural Integrity Layer** | A Merkle tree over a grid of image tiles |
27
+ | **Cryptographic Seal** | One ECDSA P-256 signature binding the CAB, the tree root, and the image data together |
28
+ | **Provenance Chain** | Append-only, hash-linked record of every hand the file passed through |
29
+ | **Image Data** | The pixels |
30
+
31
+ Three properties follow from that structure.
32
+
33
+ **The proof cannot be stripped.** It is not metadata sitting beside the image; it is the container. Remove it and you no longer have an EIF file — you have an ordinary image with no claim to make.
34
+
35
+ **Tampering is localised, not just detected.** Because the signature covers a per-tile Merkle tree rather than a single whole-image hash, a verifier can recompute the tree and report exactly which tiles changed. "This file is invalid" is not useful to a claims handler. "Tiles 34, 35, 44 and 45 changed — the region around the left headlight" is.
36
+
37
+ **Verification works offline.** Four of the five verification levels complete with no network access, no trust service, and no vendor. Evidence has to be checkable in a courtroom, in an adjuster's car, and in ten years' time, none of which guarantee a working connection to somebody's server.
38
+
39
+ ## Install
40
+
41
+ ```bash
42
+ pip install eif-sdk
43
+ ```
44
+
45
+ From source:
46
+
47
+ ```bash
48
+ git clone https://github.com/eif-format/eif-sdk.git
49
+ cd eif-sdk
50
+ pip install -e ".[dev]"
51
+ pytest
52
+ ```
53
+
54
+ ## Use it in sixty seconds
55
+
56
+ ```bash
57
+ eif keygen --out signing-key.pem
58
+ eif capture damage.png --key signing-key.pem --challenge "srv-nonce-7f3a"
59
+ eif verify damage.eif --key signing-key.pub.pem
60
+ ```
61
+
62
+ Then prove the localisation claim to yourself:
63
+
64
+ ```bash
65
+ eif tamper-test damage.eif --x 300 --y 200 --width 80 --height 60
66
+ ```
67
+
68
+ ```
69
+ Verification result: NOT VALID
70
+ L1 Format pass
71
+ L2 Cryptographic FAIL
72
+ - seal signature does not verify over this CAB, structural integrity layer and image data
73
+ - recomputed tile tree does not match the sealed root
74
+ L3 Temporal pass
75
+ L4 Provenance pass
76
+ L5 Device not evaluated
77
+
78
+ Tamper localisation: 4 of 80 tiles altered
79
+ tile 34 (col 4, row 3) pixels [256,192]-[320,256]
80
+ tile 35 (col 5, row 3) pixels [320,192]-[384,256]
81
+ tile 44 (col 4, row 4) pixels [256,256]-[320,320]
82
+ tile 45 (col 5, row 4) pixels [320,256]-[384,320]
83
+ ```
84
+
85
+ ## Use it from Python
86
+
87
+ ```python
88
+ from eif import CaptureAttestation, Device, EIFFile, KeyPair, Location, imaging
89
+
90
+ keypair = KeyPair.generate()
91
+
92
+ attestation = CaptureAttestation(
93
+ device=Device(
94
+ make="Acme", model="Field-1", os="Android 15",
95
+ app_id="com.example.claims", app_version="2.3.0",
96
+ ),
97
+ location=Location(latitude="12.9716", longitude="77.5946", accuracy_m=8),
98
+ challenge="srv-nonce-7f3a", # issued by your server, seconds before capture
99
+ session_id="claim-2026-0041",
100
+ )
101
+
102
+ sealed = EIFFile.capture(imaging.encode_png("damage.jpg"), attestation, keypair)
103
+ sealed.save("damage.eif")
104
+ ```
105
+
106
+ Verifying, with the signing key pinned:
107
+
108
+ ```python
109
+ report = EIFFile.load("damage.eif").verify(expected_public_key=keypair.public_key)
110
+
111
+ if not report["valid"]:
112
+ for tile in report["L2_cryptographic"]["altered_tiles"]:
113
+ print(f"altered region: {tile['bounds']}")
114
+ ```
115
+
116
+ ## The verification protocol
117
+
118
+ | Level | Question | Network |
119
+ |---|---|---|
120
+ | **L1 Format** | Is this a well-formed EIF file? | offline |
121
+ | **L2 Cryptographic** | Does the seal verify over this CAB, tree and image? If not, which tiles changed? | offline |
122
+ | **L3 Temporal** | Are the timestamps internally coherent and plausible? | offline |
123
+ | **L4 Provenance** | Is the chain of custody unbroken? | offline |
124
+ | **L5 Device** | Is the signing key attested to real hardware? | online |
125
+
126
+ Verification never raises on an invalid file; it returns a structured report. Each level is reported independently because the levels fail for different reasons and a relying party needs to make different decisions about each.
127
+
128
+ ## The challenge, and the attack it addresses
129
+
130
+ Provenance systems that only record "a real camera took this photograph" are defeated by an attack that costs nothing: generate a fake image, display it on a screen, photograph the screen with a genuine camera. The capture is real, the signature is honest, and the content is fabricated.
131
+
132
+ EIF's answer is the `challenge` field. Your server issues a nonce immediately before capture; the capture pipeline binds it into the Capture Attestation Block before signing. An image produced any other way cannot carry a fresh, unused, server-recognised nonce for a session you opened. This does not make recapture impossible — nothing in software does — but it moves the attack from "free and instant" to "requires real-time control of a device inside your session," which is a different economic proposition for a fraudster.
133
+
134
+ Captures with no challenge are permitted and are honestly weaker. Treat them as a lower assurance tier.
135
+
136
+ ## Where this fits alongside C2PA and JPEG Trust
137
+
138
+ EIF is not a competitor to [C2PA Content Credentials](https://c2pa.org) or [JPEG Trust (ISO/IEC 21617)](https://jpeg.org/jpegtrust/), and positioning it as one would be dishonest. Those efforts have the ecosystem — camera manufacturers, platforms, an ISO process — and they solve the problem they set out to solve: recording and travelling with a content history across a general-purpose media supply chain.
139
+
140
+ EIF addresses a narrower case those systems do not target: **high-assurance evidence capture**, where the relying party controls the capture pipeline, the stakes justify a stricter model, and two specific requirements apply that general provenance does not meet — knowing *where* in the frame an image changed, and binding a capture to a session the relying party opened.
141
+
142
+ An EIF file can carry a C2PA manifest as an annotation, and an EIF verifier can treat a valid Content Credential as one input among several. Interoperability notes are in the [specification repository](https://github.com/eif-format/specification/blob/main/spec/Interop.md).
143
+
144
+ ## Honest limitations
145
+
146
+ Read these before you build anything on this.
147
+
148
+ - **v1.0 handles losslessly-decodable images only (PNG).** JPEG decoding is not bit-exact across libraries, so tile hashes computed at capture would not reliably recompute on a verifier's machine. Rather than ship a structural integrity layer that produces false tamper reports, lossy profiles are deferred. This is the largest practical limitation and the first thing v1.1 must address.
149
+ - **A signature proves who signed, not that the content is true.** EIF can tell you an image was sealed by a specific key at a specific time and has not changed since. It cannot tell you the adjuster photographed the right car.
150
+ - **Software keys are only as good as the device.** The security of the whole scheme rests on the private key. This SDK generates software keys, which are appropriate for development. Production capture should sign inside a TEE, Secure Enclave, or StrongBox-backed keystore, and L5 exists to let a verifier check that.
151
+ - **The provenance chain records what was recorded.** It detects alteration of the sequence. It cannot detect a handler who simply never appended an entry.
152
+ - **No mobile SDK yet.** Android and iOS are the platforms this format actually needs. They are not built.
153
+ - **The specification is v1.0 and has not been through independent security review.** If you find a flaw, please tell us — see [SECURITY.md](https://github.com/eif-format/eif-sdk/blob/main/SECURITY.md).
154
+
155
+ ## Repositories
156
+
157
+ | Repository | Contents |
158
+ |---|---|
159
+ | [`specification`](https://github.com/eif-format/specification) | The format specification, JSON schemas, and shared test vectors |
160
+ | [`eif-sdk`](https://github.com/eif-format/eif-sdk) | This reference implementation |
161
+ | [`research`](https://github.com/eif-format/research) | Papers, datasets and methodology |
162
+
163
+ ## Contributing
164
+
165
+ Independent implementations in other languages are the single most valuable contribution. A format with one implementation is a product; a format with several is a standard. See [CONTRIBUTING.md](https://github.com/eif-format/eif-sdk/blob/main/CONTRIBUTING.md).
166
+
167
+ ## Licence
168
+
169
+ Apache License 2.0. See [LICENSE](https://github.com/eif-format/eif-sdk/blob/main/LICENSE) and [NOTICE](https://github.com/eif-format/eif-sdk/blob/main/NOTICE).
170
+
171
+ The Apache 2.0 licence includes an express patent grant covering this implementation. Patent applications relating to the format have been filed in India; the licence grant applies to the contributed code as described in Section 3 of the licence.
@@ -0,0 +1,68 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "eif-sdk"
7
+ version = "0.1.0"
8
+ description = "Reference implementation of the Evidence Integrity Framework (EIF) image provenance format"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = "Apache-2.0"
12
+ license-files = ["LICENSE", "NOTICE"]
13
+ keywords = ["provenance", "authenticity", "forensics", "image", "cryptography", "c2pa"]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Intended Audience :: Developers",
17
+ "Intended Audience :: Legal Industry",
18
+ "Programming Language :: Python :: 3",
19
+ "Topic :: Multimedia :: Graphics",
20
+ "Topic :: Security :: Cryptography",
21
+ ]
22
+ dependencies = [
23
+ "cryptography>=41.0",
24
+ "Pillow>=10.0",
25
+ ]
26
+
27
+ [project.optional-dependencies]
28
+ dev = ["pytest>=7.4", "pytest-cov>=4.1", "ruff==0.14.4"]
29
+
30
+ [project.urls]
31
+ Homepage = "https://eif-format.org"
32
+ Specification = "https://github.com/eif-format/specification"
33
+ Source = "https://github.com/eif-format/eif-sdk"
34
+ Issues = "https://github.com/eif-format/eif-sdk/issues"
35
+
36
+ [project.scripts]
37
+ eif = "eif.cli:main"
38
+
39
+ [tool.setuptools.packages.find]
40
+ where = ["src"]
41
+
42
+ [tool.pytest.ini_options]
43
+ testpaths = ["tests"]
44
+ addopts = "-q"
45
+
46
+ [tool.ruff]
47
+ line-length = 100
48
+ target-version = "py39"
49
+
50
+ # Rules are selected explicitly rather than left to ruff's defaults. Defaults
51
+ # change between ruff releases, which would mean an upstream release could fail
52
+ # CI with no change to this repository. The version is pinned in the dev extra
53
+ # for the same reason.
54
+ [tool.ruff.lint]
55
+ select = [
56
+ "E", # pycodestyle errors
57
+ "F", # pyflakes
58
+ "I", # import sorting
59
+ "UP", # pyupgrade
60
+ "B", # bugbear
61
+ "BLE", # blind except
62
+ "C4", # comprehensions
63
+ "RUF", # ruff-specific
64
+ ]
65
+
66
+ [tool.ruff.lint.per-file-ignores]
67
+ # Tests deliberately construct malformed input and assert on failure paths.
68
+ "tests/*" = ["B011"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+