zeus-time 0.1.3 → 0.2.2

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.
package/LICENSE CHANGED
@@ -2,22 +2,6 @@
2
2
  Version 2.0, January 2004
3
3
  http://www.apache.org/licenses/
4
4
 
5
- Copyright 2025 Drew Gardiner aka o0CroMag0o - TIMESync38
6
-
7
- Licensed under the Apache License, Version 2.0 (the "License");
8
- you may not use this file except in compliance with the License.
9
- You may obtain a copy of the License at
10
-
11
- http://www.apache.org/licenses/LICENSE-2.0
12
-
13
- Unless required by applicable law or agreed to in writing, software
14
- distributed under the License is distributed on an "AS IS" BASIS,
15
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- See the License for the specific language governing permissions and
17
- limitations under the License.
18
-
19
-
20
-
21
5
  TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
22
6
 
23
7
  1. Definitions.
@@ -191,3 +175,27 @@
191
175
 
192
176
  END OF TERMS AND CONDITIONS
193
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.
package/README.md CHANGED
@@ -1,155 +1,201 @@
1
- # ZEUS: The Future of Timekeeping 🚀
1
+ # ZEUS-Time
2
2
 
3
- **UNIX is dead. ZEUS lives.** This package introduces a deterministic, cryptographically verifiable time system designed to replace traditional UNIX timestamps. With ZEUS, developers can generate and validate time hashes, ensuring synchronization across systems without relying on sequential UNIX time.
3
+ **Deterministic. Verifiable. Calm.**
4
4
 
5
- ---
5
+ ZEUS-Time is a verifiable time primitive for distributed systems. It
6
+ does not replace clocks. It does not guess truth. It produces
7
+ deterministic, cryptographically verifiable receipts of time.
6
8
 
7
- ## 🌟 Features
9
+ Unix time is treated as input material, not authority.
8
10
 
9
- 👉 **Deterministic Timestamps** – Generate a unique, cryptographic hash from any timestamp.
10
- 👉 **Epoch-Based Execution** – Set an epoch based on a ZEUS hash for synchronized execution.
11
- 👉 **Decentralized & Immutable** – No single point of failure; timestamp verification is trustless.
12
- 👉 **Backward-Compatible with UNIX** – Convert traditional UNIX time into ZEUS easily.
13
- 👉 **Supports Legacy Systems** – SHA-256 fallback for older systems that can't run Blake3.
14
- 👉 **Ideal for Web3, Smart Contracts, IoT, and Security Applications**
11
+ ------------------------------------------------------------------------
15
12
 
16
- ---
13
+ ## What ZEUS Is (and Is Not)
17
14
 
18
- ## 🛢️ Installation
15
+ ZEUS provides verifiable ordering and integrity of time-based events.
19
16
 
20
- ```sh
21
- # Using Yarn
22
- yarn add zeus-time
17
+ - It proves when something happened relative to other events
18
+ - It does not claim civil time accuracy
19
+ - It does not reverse hashes
20
+ - It does not depend on blockchains or consensus
21
+
22
+ Think of ZEUS as a time receipt, not a clock.
23
+
24
+ ------------------------------------------------------------------------
25
+
26
+ ## Features
27
+
28
+ - Deterministic time hashing using BLAKE3
29
+ - Stable, reproducible outputs across platforms
30
+ - Local-first, no network dependency
31
+ - Expo and React Native compatible
32
+ - Legacy helpers for smooth migration from 0.1.x
33
+ - Optional base64url or hex encoding
34
+ - Explicit separation between time representation and hashing
23
35
 
24
- # Using NPM
36
+ ------------------------------------------------------------------------
37
+
38
+ ## Installation
39
+
40
+ ``` sh
25
41
  npm install zeus-time
26
42
  ```
27
43
 
28
- ---
44
+ or
45
+
46
+ ``` sh
47
+ yarn add zeus-time
48
+ ```
49
+
50
+ ------------------------------------------------------------------------
51
+
52
+ ## Basic Usage
29
53
 
30
- ## ❤️ Usage
54
+ ### Generate a ZEUS hash from a timestamp
31
55
 
32
- ### 🔹 Generate a ZEUS Timestamp
33
- ```typescript
34
- import { generateZeusHash } from "zeus-time";
56
+ ``` ts
57
+ import { zeusHash } from "zeus-time";
35
58
 
36
- async function generateTimeHash() {
37
- const timestamp = new Date().toISOString();
38
- const hash = await generateZeusHash(timestamp);
39
- console.log(`ZEUS Time Hash: ${hash}`);
40
- }
59
+ const iso = new Date().toISOString();
60
+ const hash = zeusHash(iso);
41
61
 
42
- generateTimeHash();
62
+ console.log(hash);
43
63
  ```
44
64
 
45
- ### 🔹 Convert UNIX Time to ZEUS Time
46
- ```typescript
47
- import { unixToZeus } from "zeus-time";
65
+ This hash is deterministic. The same input always produces the same
66
+ output.
48
67
 
49
- const unixTime = Math.floor(Date.now() / 1000);
50
- unixToZeus(unixTime).then(hash => {
51
- console.log(`Converted ZEUS Epoch: ${hash}`);
52
- });
68
+ ------------------------------------------------------------------------
69
+
70
+ ### Stamp unix time deterministically (sync)
71
+
72
+ ``` ts
73
+ import { unixToZeusSync } from "zeus-time";
74
+
75
+ const unixSeconds = Math.floor(Date.now() / 1000);
76
+ const hash = unixToZeusSync(unixSeconds);
53
77
  ```
54
78
 
55
- ### 🔹 Convert ZEUS Back to UNIX Time
56
- ```typescript
57
- import { zeusToUnix } from "zeus-time";
79
+ This is the preferred hot path for applications.
80
+
81
+ ------------------------------------------------------------------------
58
82
 
59
- const zeusHash = "your_zeus_hash_here";
60
- const unixTime = zeusToUnix(zeusHash);
61
- console.log(`Converted UNIX Time: ${unixTime}`);
83
+ ### Async compatibility helper (legacy friendly)
84
+
85
+ ``` ts
86
+ import { unixToZeus } from "zeus-time";
87
+
88
+ const hash = await unixToZeus(1704067200);
62
89
  ```
90
+
91
+ This exists for continuity with earlier versions.
92
+
93
+ ------------------------------------------------------------------------
94
+
95
+ ## Verification
96
+
97
+ ### Verify a timestamp against a hash
98
+
99
+ ``` ts
100
+ import { verifyZeusHash } from "zeus-time";
101
+
102
+ const ok = verifyZeusHash(iso, hash);
63
103
  ```
64
- 💡 **Note:** `zeusToUnix()` is the primary function for ZEUS time handling. For legacy support, use `legacyZeusToUnix()`.
104
+
105
+ Returns true if the hash matches the normalized timestamp.
106
+
107
+ ------------------------------------------------------------------------
108
+
109
+ ### Safe validation helper
110
+
111
+ ``` ts
112
+ import { validateZeusTimestamp } from "zeus-time";
113
+
114
+ const isValid = await validateZeusTimestamp(iso, hash);
65
115
  ```
66
116
 
67
- ### 🔹 Execute Based on a ZEUS Epoch
68
- ```typescript
117
+ This helper never throws. It returns false on invalid input.
118
+
119
+ ------------------------------------------------------------------------
120
+
121
+ ## Epoch-Based Execution
122
+
123
+ ``` ts
69
124
  import { executeAtZeusEpoch } from "zeus-time";
70
125
 
71
126
  executeAtZeusEpoch(1735689600, () => {
72
- console.log("Executing synchronized action at ZEUS Epoch!");
127
+ console.log("ZEUS epoch reached");
73
128
  });
74
129
  ```
75
130
 
76
- ---
131
+ ------------------------------------------------------------------------
77
132
 
78
- ## 🚀 Benchmark Performance
79
- Zeus-Time is **blazing fast!** Recent tests show it can **hash timestamps at record-breaking speeds!** 💥
133
+ ## Legacy Compatibility
80
134
 
81
- ```bash
82
- Performance Test: Hashed 1000 timestamps in **12ms** ⚡
83
- Performance Test: Hashed 5000 timestamps in **51ms** ⚡
84
- Performance Test: Hashed 10,000 timestamps in **98ms** ⚡
85
- Performance Test: Hashed 50,000 timestamps in **434ms** ⚡
86
- ```
135
+ ZEUS 0.2.x keeps compatibility helpers while preserving one-way
136
+ integrity.
87
137
 
88
- ### **Why Use Zeus-Time?**
89
- 👉 **Ultra-Fast** - Outperforms traditional UNIX-based hashing.
90
- 👉 **Cryptographically Secure** - Uses BLAKE3 hashing for reliability.
91
- 👉 **Future-Proof** - Designed for next-gen blockchain & AI applications.
138
+ ### Legacy hashing helpers
92
139
 
93
- ---
140
+ ``` ts
141
+ import { legacyUnixToZeus, legacyZeusHash } from "zeus-time";
142
+ ```
94
143
 
95
- ## 🎯 Use Cases
144
+ ### Legacy unix conversion
96
145
 
97
- 👉 **Smart Contracts** – Ensure execution only happens at a predetermined time.
98
- 👉 **Decentralized Networks** Nodes validate time-sensitive actions without a global clock.
99
- 👉 **Gaming & AI** – Sync in-game events or AI processes based on immutable time hashes.
100
- 👉 **Supply Chain & IoT** – Devices validate time-based triggers securely.
101
- 👉 **File Integrity & Authentication** – Timestamped events are cryptographically secured.
146
+ ``` ts
147
+ import { legacyZeusToUnix } from "zeus-time";
148
+ ```
102
149
 
103
- ---
150
+ - If the input looks like an ISO timestamp, it is parsed
151
+ - If the input looks like a hash, it throws
152
+ - Hashes remain one-way by design
104
153
 
105
- ## 🔄 Legacy System Support
154
+ ------------------------------------------------------------------------
106
155
 
107
- ZEUS is designed for modern timekeeping but also supports **legacy systems** with SHA-256 hashing. If Blake3 is unavailable, ZEUS will fall back to SHA-256, ensuring compatibility across older infrastructures.
156
+ ## Performance
108
157
 
109
- 🏢 **Legacy Function Naming:**
110
- - `legacyUnixToZeus()` → Converts UNIX to ZEUS hash using SHA-256.
111
- - `legacyZeusToUnix()` → Attempts UNIX conversion but is not cryptographically reversible.
158
+ ZEUS is fast enough to be boring.
112
159
 
113
- ---
160
+ Example benchmarks on a standard desktop:
114
161
 
115
- ## 🤡 Test Results
162
+ 1,000 hashes \~12 ms 5,000 hashes \~51 ms 10,000 hashes \~98 ms 50,000
163
+ hashes \~430 ms
116
164
 
117
- ZEUS has passed all unit tests for functionality, security, and legacy compatibility.
165
+ ------------------------------------------------------------------------
118
166
 
119
- 👉 10/10 Tests Passed
120
- 👉 Validates timestamps correctly (Ensures input is formatted and normalized properly)
121
- 👉 Ensures deterministic hashing (Same input always produces the same secure hash)
122
- 👉 Supports legacy SHA-256 fallback (Ensures compatibility with older systems if BLAKE3 is unavailable)
123
- 👉 Prevents invalid time manipulation (Rejects malformed, tampered, or unrealistic timestamps)
124
- 👉 Ensures consistent hash output across formats (Tests Date objects, ISO strings, and UNIX timestamps)
125
- 👉 Handles extreme dates correctly (Validates UNIX epoch and future dates like 2999-12-31)
126
- 👉 Rejects invalid inputs (Throws errors for undefined, null, and malformed timestamps)
127
- 👉 Performance benchmark confirmed (**1000 hashes computed in 12ms**)
167
+ ## Use Cases
128
168
 
129
- Run tests yourself:
169
+ - Audit receipts and compliance logs
170
+ - Distributed systems needing ordering guarantees
171
+ - Event integrity verification
172
+ - Local-first applications
173
+ - Smart contract preparation and off-chain proofs
174
+ - Time-bound unlocks and delayed execution
130
175
 
131
- ```sh
132
- yarn test
133
- ```
176
+ ZEUS provides proof of time, not surveillance.
134
177
 
135
- ---
178
+ ------------------------------------------------------------------------
136
179
 
137
- ## 🔒 Security & Trust
180
+ ## Versioning Strategy
138
181
 
139
- ZEUS ensures **time integrity** without requiring a centralized authority. Hashes are **tamper-proof** and **deterministically generated**, making it impossible to predict or manipulate timestamps in advance.
182
+ - 0.1.x is the stable legacy line
183
+ - 0.2.x clarifies semantics and adds Expo compatibility
184
+ - latest remains conservative
185
+ - New behavior is opt-in
140
186
 
141
- ---
187
+ ------------------------------------------------------------------------
142
188
 
143
- ## 💚 License
189
+ ## License
144
190
 
145
- Licensed under **Apache 2.0**, ensuring open-source innovation while protecting integrity.
191
+ Apache 2.0 Open, boring, and dependable.
146
192
 
147
- ---
193
+ ------------------------------------------------------------------------
148
194
 
149
- ## 🚀 Join the Revolution
195
+ ## A Small Amount of Fire
150
196
 
151
- **UNIX is outdated. ZEUS is the future.**
152
- Get started today and be part of the next evolution in timekeeping!
197
+ Unix time still works. But it was never designed to be verifiable.
153
198
 
154
- LFCROOOOOOO!!!! 🔥⚡
199
+ ZEUS does not replace the clock. It replaces the argument.
155
200
 
201
+ BAM!