0byte 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.
@@ -0,0 +1,61 @@
1
+ Metadata-Version: 2.4
2
+ Name: 0byte
3
+ Version: 0.1.0
4
+ Summary: Python SDK for 0byte — the origin protocol for AI content
5
+ Author: 0byte
6
+ License: MIT
7
+ Project-URL: Homepage, https://www.0byte.dev
8
+ Project-URL: Source, https://github.com/0byte-lab/0byte
9
+ Keywords: ai,provenance,verification,content-authenticity,fingerprint
10
+ Requires-Python: >=3.9
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: httpx>=0.24
14
+ Requires-Dist: pydantic>=2.0
15
+ Dynamic: license-file
16
+
17
+ <p align="center">
18
+ <img src="public/assets/0byte-logo-dark.png" alt="0byte logo" width="200"/>
19
+ </p>
20
+
21
+ # 0byte Python SDK
22
+
23
+ The official Python SDK for **0byte** — the origin protocol for AI content.
24
+
25
+ ## What It Does
26
+
27
+ - Stamps AI-generated content with a cryptographic proof of origin
28
+ - Computes perceptual fingerprints that survive re-encoding and screenshots
29
+ - Stores proofs in the 0byte registry for public verification
30
+ - Verifies any content against the registry in a single call
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install 0byte
36
+ ```
37
+
38
+ ## Quickstart
39
+
40
+ ```python
41
+ import zbyte
42
+
43
+ client = zbyte.Client(api_key="0b_key_...")
44
+
45
+ # Stamp any AI-generated content
46
+ proof = client.stamp(
47
+ content=image_bytes,
48
+ content_type="image/png",
49
+ provider="stability",
50
+ model="sdxl-turbo",
51
+ )
52
+
53
+ print(proof.id) # "0b_proof_abc123"
54
+ print(proof.fingerprint) # perceptual content hash
55
+ print(proof.verify_url) # "https://verify.0byte.dev/0b_proof_abc123"
56
+
57
+ # Verify any content
58
+ result = client.verify(content=some_image_bytes)
59
+ print(result.matched) # True / False
60
+ print(result.confidence) # fingerprint similarity score
61
+ ```
@@ -0,0 +1,13 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ 0byte.egg-info/PKG-INFO
5
+ 0byte.egg-info/SOURCES.txt
6
+ 0byte.egg-info/dependency_links.txt
7
+ 0byte.egg-info/requires.txt
8
+ 0byte.egg-info/top_level.txt
9
+ zbyte/__init__.py
10
+ zbyte/client.py
11
+ zbyte/config.py
12
+ zbyte/exceptions.py
13
+ zbyte/utils.py
@@ -0,0 +1,2 @@
1
+ httpx>=0.24
2
+ pydantic>=2.0
@@ -0,0 +1 @@
1
+ zbyte
0byte-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 0byte
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
0byte-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,61 @@
1
+ Metadata-Version: 2.4
2
+ Name: 0byte
3
+ Version: 0.1.0
4
+ Summary: Python SDK for 0byte — the origin protocol for AI content
5
+ Author: 0byte
6
+ License: MIT
7
+ Project-URL: Homepage, https://www.0byte.dev
8
+ Project-URL: Source, https://github.com/0byte-lab/0byte
9
+ Keywords: ai,provenance,verification,content-authenticity,fingerprint
10
+ Requires-Python: >=3.9
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: httpx>=0.24
14
+ Requires-Dist: pydantic>=2.0
15
+ Dynamic: license-file
16
+
17
+ <p align="center">
18
+ <img src="public/assets/0byte-logo-dark.png" alt="0byte logo" width="200"/>
19
+ </p>
20
+
21
+ # 0byte Python SDK
22
+
23
+ The official Python SDK for **0byte** — the origin protocol for AI content.
24
+
25
+ ## What It Does
26
+
27
+ - Stamps AI-generated content with a cryptographic proof of origin
28
+ - Computes perceptual fingerprints that survive re-encoding and screenshots
29
+ - Stores proofs in the 0byte registry for public verification
30
+ - Verifies any content against the registry in a single call
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install 0byte
36
+ ```
37
+
38
+ ## Quickstart
39
+
40
+ ```python
41
+ import zbyte
42
+
43
+ client = zbyte.Client(api_key="0b_key_...")
44
+
45
+ # Stamp any AI-generated content
46
+ proof = client.stamp(
47
+ content=image_bytes,
48
+ content_type="image/png",
49
+ provider="stability",
50
+ model="sdxl-turbo",
51
+ )
52
+
53
+ print(proof.id) # "0b_proof_abc123"
54
+ print(proof.fingerprint) # perceptual content hash
55
+ print(proof.verify_url) # "https://verify.0byte.dev/0b_proof_abc123"
56
+
57
+ # Verify any content
58
+ result = client.verify(content=some_image_bytes)
59
+ print(result.matched) # True / False
60
+ print(result.confidence) # fingerprint similarity score
61
+ ```
0byte-0.1.0/README.md ADDED
@@ -0,0 +1,45 @@
1
+ <p align="center">
2
+ <img src="public/assets/0byte-logo-dark.png" alt="0byte logo" width="200"/>
3
+ </p>
4
+
5
+ # 0byte Python SDK
6
+
7
+ The official Python SDK for **0byte** — the origin protocol for AI content.
8
+
9
+ ## What It Does
10
+
11
+ - Stamps AI-generated content with a cryptographic proof of origin
12
+ - Computes perceptual fingerprints that survive re-encoding and screenshots
13
+ - Stores proofs in the 0byte registry for public verification
14
+ - Verifies any content against the registry in a single call
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ pip install 0byte
20
+ ```
21
+
22
+ ## Quickstart
23
+
24
+ ```python
25
+ import zbyte
26
+
27
+ client = zbyte.Client(api_key="0b_key_...")
28
+
29
+ # Stamp any AI-generated content
30
+ proof = client.stamp(
31
+ content=image_bytes,
32
+ content_type="image/png",
33
+ provider="stability",
34
+ model="sdxl-turbo",
35
+ )
36
+
37
+ print(proof.id) # "0b_proof_abc123"
38
+ print(proof.fingerprint) # perceptual content hash
39
+ print(proof.verify_url) # "https://verify.0byte.dev/0b_proof_abc123"
40
+
41
+ # Verify any content
42
+ result = client.verify(content=some_image_bytes)
43
+ print(result.matched) # True / False
44
+ print(result.confidence) # fingerprint similarity score
45
+ ```
@@ -0,0 +1,29 @@
1
+ [build-system]
2
+ requires = ["setuptools>=42", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "0byte"
7
+ version = "0.1.0"
8
+ description = "Python SDK for 0byte — the origin protocol for AI content"
9
+ authors = [{name="0byte"}]
10
+ readme = "README.md"
11
+ license = {text = "MIT"}
12
+ requires-python = ">=3.9"
13
+ keywords = ["ai", "provenance", "verification", "content-authenticity", "fingerprint"]
14
+
15
+ dependencies = [
16
+ "httpx>=0.24",
17
+ "pydantic>=2.0",
18
+ ]
19
+
20
+ [project.urls]
21
+ "Homepage" = "https://www.0byte.dev"
22
+ "Source" = "https://github.com/0byte-lab/0byte"
23
+
24
+ [tool.setuptools.packages.find]
25
+ include = ["zbyte*"]
26
+ # Note: PyPI package is "0byte" but the import remains "zbyte"
27
+ # since Python module names cannot start with a digit.
28
+ # Usage: pip install 0byte → import zbyte
29
+ exclude = ["public*", "tests*"]
0byte-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,5 @@
1
+ from .client import Client, Proof, VerificationResult
2
+ from .config import Config
3
+ from .exceptions import SDKError, ProofError, VerificationError, AuthenticationError
4
+
5
+ __version__ = "0.1.0"
@@ -0,0 +1,129 @@
1
+ import base64
2
+ import httpx
3
+ from .config import Config
4
+ from .exceptions import AuthenticationError, ProofError, VerificationError
5
+ from .utils import logger
6
+
7
+
8
+ class Proof:
9
+ """A cryptographic proof of AI content origin."""
10
+
11
+ def __init__(self, data: dict):
12
+ self.id = data["id"]
13
+ self.fingerprint = data["fingerprint"]
14
+ self.provider = data["provider"]
15
+ self.model = data["model"]
16
+ self.content_type = data["content_type"]
17
+ self.timestamp = data["timestamp"]
18
+ self.signature = data["signature"]
19
+ self.verify_url = data["verify_url"]
20
+ self.metadata = data.get("metadata")
21
+
22
+ def __repr__(self):
23
+ return f"Proof(id={self.id!r}, provider={self.provider!r}, model={self.model!r})"
24
+
25
+
26
+ class VerificationResult:
27
+ """Result of verifying content against the 0byte registry."""
28
+
29
+ def __init__(self, data: dict):
30
+ self.matched = data["matched"]
31
+ self.confidence = data["confidence"]
32
+ self.proof = Proof(data["proof"]) if data.get("proof") else None
33
+
34
+ def __repr__(self):
35
+ if self.matched:
36
+ return f"VerificationResult(matched=True, confidence={self.confidence:.3f}, proof={self.proof.id!r})"
37
+ return "VerificationResult(matched=False)"
38
+
39
+
40
+ class Client:
41
+ """0byte API client for stamping and verifying AI content."""
42
+
43
+ def __init__(self, api_key: str = None, endpoint: str = "https://api.0byte.dev", timeout: float = 30.0):
44
+ self.api_key = api_key
45
+ self.endpoint = endpoint.rstrip("/")
46
+ self._http = httpx.Client(timeout=timeout)
47
+
48
+ def stamp(
49
+ self,
50
+ content: bytes,
51
+ content_type: str,
52
+ provider: str,
53
+ model: str,
54
+ metadata: dict = None,
55
+ ) -> Proof:
56
+ """Create a cryptographic proof of origin for AI-generated content."""
57
+ if not self.api_key:
58
+ raise AuthenticationError("API key required for stamping. Pass api_key to Client().")
59
+
60
+ payload = {
61
+ "content": base64.b64encode(content).decode(),
62
+ "content_type": content_type,
63
+ "provider": provider,
64
+ "model": model,
65
+ }
66
+ if metadata:
67
+ payload["metadata"] = metadata
68
+
69
+ logger.info("Stamping content (provider=%s, model=%s)", provider, model)
70
+
71
+ response = self._http.post(
72
+ f"{self.endpoint}/v1/stamp",
73
+ json=payload,
74
+ headers={"Authorization": f"Bearer {self.api_key}"},
75
+ )
76
+
77
+ if response.status_code == 401:
78
+ raise AuthenticationError("Invalid API key")
79
+ if response.status_code != 200:
80
+ raise ProofError(f"Stamp failed ({response.status_code}): {response.text}")
81
+
82
+ data = response.json()
83
+ logger.info("Proof created: %s", data["id"])
84
+ return Proof(data)
85
+
86
+ def verify(self, content: bytes, content_type: str = "image/png") -> VerificationResult:
87
+ """Verify content against the 0byte registry."""
88
+ payload = {
89
+ "content": base64.b64encode(content).decode(),
90
+ "content_type": content_type,
91
+ }
92
+
93
+ logger.info("Verifying content against registry")
94
+
95
+ response = self._http.post(
96
+ f"{self.endpoint}/v1/verify",
97
+ json=payload,
98
+ )
99
+
100
+ if response.status_code != 200:
101
+ raise VerificationError(f"Verification failed ({response.status_code}): {response.text}")
102
+
103
+ data = response.json()
104
+ result = VerificationResult(data)
105
+ if result.matched:
106
+ logger.info("Match found: %s (confidence=%.3f)", result.proof.id, result.confidence)
107
+ else:
108
+ logger.info("No match found in registry")
109
+ return result
110
+
111
+ def get_proof(self, proof_id: str) -> Proof:
112
+ """Look up a proof by ID."""
113
+ response = self._http.get(f"{self.endpoint}/v1/proofs/{proof_id}")
114
+
115
+ if response.status_code == 404:
116
+ raise ProofError(f"Proof not found: {proof_id}")
117
+ if response.status_code != 200:
118
+ raise ProofError(f"Lookup failed ({response.status_code}): {response.text}")
119
+
120
+ return Proof(response.json())
121
+
122
+ def close(self):
123
+ self._http.close()
124
+
125
+ def __enter__(self):
126
+ return self
127
+
128
+ def __exit__(self, *args):
129
+ self.close()
@@ -0,0 +1,6 @@
1
+ from pydantic import BaseModel, Field
2
+
3
+ class Config(BaseModel):
4
+ api_key: str = Field(..., description="0byte API key")
5
+ endpoint: str = Field(default="https://api.0byte.dev", description="0byte API endpoint")
6
+ timeout: float = Field(default=30.0, description="Request timeout in seconds")
@@ -0,0 +1,11 @@
1
+ class SDKError(Exception):
2
+ """Base exception for 0byte SDK"""
3
+
4
+ class ProofError(SDKError):
5
+ """Raised when proof creation fails"""
6
+
7
+ class VerificationError(SDKError):
8
+ """Raised when content verification fails"""
9
+
10
+ class AuthenticationError(SDKError):
11
+ """Raised when API authentication fails"""
@@ -0,0 +1,11 @@
1
+ import logging
2
+
3
+ logger = logging.getLogger(__name__)
4
+ logger.setLevel(logging.INFO)
5
+
6
+ formatter = logging.Formatter(
7
+ "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
8
+ )
9
+ handler = logging.StreamHandler()
10
+ handler.setFormatter(formatter)
11
+ logger.addHandler(handler)