python-ztidentity 0.0.1__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,24 @@
1
+ BSD 2-Clause License
2
+
3
+ Copyright (c) 2026, blitztide
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,29 @@
1
+ Metadata-Version: 2.4
2
+ Name: python-ztidentity
3
+ Version: 0.0.1
4
+ Summary: Pythonic Implementation of the ZeroTier Identity Cryptography
5
+ Author-email: David Elliott <david.elliott3040@gmail.com>
6
+ License-Expression: BSD-2-Clause
7
+ Project-URL: Homepage, https://github.com/blitztide/python-ztidentity
8
+ Project-URL: Issues, https://github.com/blitztide/python-ztidentity/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: PyCryptodome
15
+ Provides-Extra: test
16
+ Requires-Dist: pytest; extra == "test"
17
+ Requires-Dist: build; extra == "test"
18
+ Requires-Dist: twine; extra == "test"
19
+ Dynamic: license-file
20
+
21
+ # python-ztidentity
22
+ Pythonic implementation of the ZeroTier Identity Keys
23
+
24
+ This is very slow and will not be useful for large scale key generation
25
+
26
+ ## Help needed
27
+
28
+ This version uses a python based Salsa20 encryption algorithm to closely match the go code
29
+ Waiting on better library support or compiled extensions, this code is EXTREMELY slow but matches expected output
@@ -0,0 +1,9 @@
1
+ # python-ztidentity
2
+ Pythonic implementation of the ZeroTier Identity Keys
3
+
4
+ This is very slow and will not be useful for large scale key generation
5
+
6
+ ## Help needed
7
+
8
+ This version uses a python based Salsa20 encryption algorithm to closely match the go code
9
+ Waiting on better library support or compiled extensions, this code is EXTREMELY slow but matches expected output
@@ -0,0 +1,31 @@
1
+ [project]
2
+ name = "python-ztidentity"
3
+ version = "0.0.1"
4
+ authors = [
5
+ { name="David Elliott", email="david.elliott3040@gmail.com" },
6
+ ]
7
+ description = "Pythonic Implementation of the ZeroTier Identity Cryptography"
8
+ dependencies = [
9
+ "PyCryptodome"
10
+ ]
11
+ readme = "README.md"
12
+ requires-python = ">=3.9"
13
+ classifiers = [
14
+ "Programming Language :: Python :: 3",
15
+ "Operating System :: OS Independent",
16
+ ]
17
+ license = "BSD-2-Clause"
18
+ license-files = ["LICEN[CS]E*"]
19
+ [project.optional-dependencies]
20
+ test = [
21
+ "pytest",
22
+ "build",
23
+ "twine"]
24
+ [project.urls]
25
+ Homepage = "https://github.com/blitztide/python-ztidentity"
26
+ Issues = "https://github.com/blitztide/python-ztidentity/issues"
27
+ [build-system]
28
+ requires = ["setuptools >= 77.0.3"]
29
+ build-backend = "setuptools.build_meta"
30
+ [tool.setuptools]
31
+ py-modules = ["ztidentity"]
@@ -0,0 +1,29 @@
1
+ Metadata-Version: 2.4
2
+ Name: python-ztidentity
3
+ Version: 0.0.1
4
+ Summary: Pythonic Implementation of the ZeroTier Identity Cryptography
5
+ Author-email: David Elliott <david.elliott3040@gmail.com>
6
+ License-Expression: BSD-2-Clause
7
+ Project-URL: Homepage, https://github.com/blitztide/python-ztidentity
8
+ Project-URL: Issues, https://github.com/blitztide/python-ztidentity/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: PyCryptodome
15
+ Provides-Extra: test
16
+ Requires-Dist: pytest; extra == "test"
17
+ Requires-Dist: build; extra == "test"
18
+ Requires-Dist: twine; extra == "test"
19
+ Dynamic: license-file
20
+
21
+ # python-ztidentity
22
+ Pythonic implementation of the ZeroTier Identity Keys
23
+
24
+ This is very slow and will not be useful for large scale key generation
25
+
26
+ ## Help needed
27
+
28
+ This version uses a python based Salsa20 encryption algorithm to closely match the go code
29
+ Waiting on better library support or compiled extensions, this code is EXTREMELY slow but matches expected output
@@ -0,0 +1,9 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ python_ztidentity.egg-info/PKG-INFO
5
+ python_ztidentity.egg-info/SOURCES.txt
6
+ python_ztidentity.egg-info/dependency_links.txt
7
+ python_ztidentity.egg-info/requires.txt
8
+ python_ztidentity.egg-info/top_level.txt
9
+ tests/test_ztidentity.py
@@ -0,0 +1,6 @@
1
+ PyCryptodome
2
+
3
+ [test]
4
+ pytest
5
+ build
6
+ twine
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,99 @@
1
+ import pytest
2
+ import ztidentity
3
+ from unittest.mock import patch
4
+
5
+
6
+ class TestZTIdentity():
7
+ # These are all generated manually using zerotier-idtool generate
8
+ valid_identities = [
9
+ "1c41190849:0:b511c983f3e51d47f2367398930038a19b2c81037fbfe151713ef42e6600717f5593da8ef7067b803f2f621c1c45b3f048681ca2877b92b632c911bde394c37c:dcbf724b1209e0869e9118d20efe8d67e10865569aaf302867bd9dfbf22ed6f52b2eb1f027f061273bdf3be3000dad5cdb0d0bf347cc18028666f2157eeefdf4",
10
+ "d228986ed9:0:2b1e61d2ca8db30e86665b278fe501752a39dc2dacd367de13ee49c5c047d21a05d0b619faa5f1d15dd8c9f89d331002e27ee771586577214c1e4b46f2a67a1d:22752b6bbddc40ef9e0f5de5eaebce1a49d3359397eef411dd8eabc8d0db1b9626b9b29172a2509a9e991593b00e28094d51410893c4e2361c59b484ce395d23",
11
+ "468fbc3bb8:0:fb2dfd593a8a5b47d7cfba3e5c7e5f64c271358e2810b4791925fb6094927c74b7e5ef10b57e8d1d7174ff5463ffe70cec84c6719c8bd07dec1f34f6a03b068f:6f7f7411685ec1d4ab9859d8a3782ee7599088e6ece4d2aa28527d3c8da429f62165489be070f470830e518d0759a4e98a3fa0419f30417b3c6232e4bc80eb28"
12
+ ]
13
+
14
+ valid_addresses = [
15
+ "a029f6e763:0b43b6553058f1db20f43362e190b4e8e193ed16d5c476d76d9ed6220f85def36a98b874c272f552b6448d186386e8c498e675ee2371308d0e20fca029f6e763",
16
+ "6d44774a4d:01c0a9a0d9c7019b84c42fda8e943546f939f87e26dfee77978f02d018e468e36241f47f600b3a78da8b761855b90d7f72bbf2e78e25c8220bbb7f6d44774a4d",
17
+ "b30647bdb2:0c4ede8a2cab510d971a7d5da56dafb8dddbb598f62b8eaa7589a5cb5705441fcbc05b84322f7d47e4821b5b67367dffa5c0e3598f92061548c057b30647bdb2"
18
+ ]
19
+
20
+ # These values have been calculated manually and verified
21
+ valid_digests = [
22
+ "deaa5a188fe46650477c7893893836ee7ca0ec34dfd9d6a191b32a334aface5e9786ab8be3fc562b568f4a9b98801f692c622f85ed01b8d175932dd9ec367666:04fffedf16a9fc9bf7bbebebc72d70e10912debb9992dcdfb9fa96a100fac5ef495b7bd3e5f0dc8b2067784c6eb74ef2a3e91e7d61c506d5aee06efd3986528d",
23
+ "4e884cc4b7ab15349e1122521a0743e7f23812240ab7f2897f4cb7c7d91683642e39e2be5ce7f2e4d0f7455ca6dab811ed908c840f2982624bc17ed369b71bae:05338c36da2f8484e43a9835b1343036e10b2c4d130f4e26e0888fa0b0eb54ebf7d04ee62efd3d48b92eb99861e2569187eb23cfdffe51e99de894cca93fa65a",
24
+ "9b62bd067840cfeef1c16eb714d6339cda6b763d648af0ff7c86826a7006e41eb2d4cdee2de4ebe3d9a0a39cd9abc595e93c7de03928aa37220d52fc30757bfb:03d0e47cbeb4ac4c5f3a80f2dfaa1234221504de1a31b016d6c25d27ea9fbf6a97f02ef9a01ae819924dfcdb06ec20cdd63ff427baae79a34f514267de07ef49"
25
+ ]
26
+
27
+ @pytest.fixture
28
+ def random(self):
29
+ """
30
+ Patch randomness to produce deterministic results
31
+ """
32
+ with patch("ztidentity.get_random_bytes") as gr:
33
+ gr.return_value = b'h1\x806\x80\x1c\xb4\xf8\xc1\xaf\x01\xa8\xe3\xc4\x0c\x10\xd6\xe1\x96\x1aY\xe0c\xd5\xf6\xc7HF\x9b?\xf0\xa1'
34
+ yield gr
35
+
36
+ def test_genkeys(self):
37
+ (public_key, private_key) = ztidentity.GenerateKeys()
38
+
39
+ # ensure key lengths are correct
40
+ assert len(public_key) == 64
41
+ assert len(private_key) == 64
42
+
43
+ # Ensure types
44
+ assert isinstance(public_key, bytes)
45
+ assert isinstance(private_key, bytes)
46
+
47
+ def test_init(self, random):
48
+ # Ensure this doesn't raise Exceptions
49
+ x = ztidentity.ZeroTierIdentity()
50
+
51
+ # Check values returned
52
+ assert isinstance(x.ID(), bytes)
53
+ assert len(x.ID()) == 5
54
+
55
+ assert isinstance(x.PrivateKey(), bytes)
56
+ assert len(x.PrivateKey()) == 64
57
+
58
+ assert isinstance(x.PublicKey(), bytes)
59
+ assert len(x.PublicKey()) == 64
60
+
61
+ assert isinstance(x.IDString(), str)
62
+ assert len(x.IDString()) == 10
63
+
64
+ assert isinstance(x.PublicKeyString(), str)
65
+ assert len(x.PublicKeyString()) == 141
66
+
67
+ assert isinstance(x.PrivateKeyString(), str)
68
+ assert len(x.PrivateKeyString()) == 270
69
+
70
+ def test_get_address(self):
71
+ # Set digests and expected addresses
72
+ for identity in self.valid_addresses:
73
+ address, digest = identity.split(":")
74
+ assert ztidentity.get_address(
75
+ bytes.fromhex(digest)) == bytes.fromhex(address)
76
+
77
+ # Ensure length check
78
+ with pytest.raises(ValueError):
79
+ ztidentity.get_address(b"00"*50)
80
+
81
+ def test_compute_hash(self):
82
+ for identity in self.valid_digests:
83
+ pub_key, digest = identity.split(":")
84
+ test_digest = ztidentity.ComputeHash(bytes.fromhex(pub_key))
85
+ assert test_digest == bytes.fromhex(digest)
86
+
87
+ def test_check_hash(self):
88
+ # Test empty hash
89
+ test_hash = b""
90
+ assert not ztidentity.check_hash(test_hash)
91
+
92
+ # Check less than 17
93
+ test_hash = b"\x03" * 64
94
+ assert ztidentity.check_hash(test_hash)
95
+
96
+ # Check reserved address
97
+ test_hash = b"\x03"*59 + b"\xFF" + b"\x03" * 4
98
+ assert test_hash[59] == 0xff
99
+ assert not ztidentity.check_hash(test_hash)