Skip to content

meese-enterprises/pyroughtime

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyroughtime

License: GPL v3

An experimental Roughtime client and server implementation in Python 3 using the IETF draft at https://tools.ietf.org/html/draft-ietf-ntp-roughtime-07.

Dependencies

Installing on Linux

If you run into an error like "This environment is externally managed", you can create a venv and install the dependencies with:

$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt-get update
$ sudo apt-get install -y python3.11 python3.11-dev python3.11-venv
$ python3.11 -m venv "venv"
$ source venv/bin/activate
$ pip install -r requirements.txt

Currently we have to use Python 3.11 or earlier due to ed25519 not being compatible with Python 3.12.

Example

From Python

from pyroughtime import RoughtimeClient, RoughtimeServer

serv, publ = RoughtimeServer.test_server()
cl = RoughtimeClient()
local_reply = cl.query("127.0.0.1", 2002, publ, newver=True)
google_reply = cl.query("roughtime.sandbox.google.com", 2002, "etPaaIxcBMY1oUeGpwvPMCJMwlRVNxv51KK/tktoJTQ=", newver=False)
serv.stop()
print(local_reply["prettytime"])
print(google_reply["prettytime"])

From CLI

$ ./pyroughtime.py -l ecosystem.json
Caesium:                  2020-12-23 16:26:16.765275 UTC (+/- 1.000  s) (RTT:  100.5 ms)
Chainpoint-Roughtime:     2020-12-23 16:26:16.973777 UTC (+/- 1.000  s) (RTT:  288.9 ms)
Cloudflare-Roughtime:     2020-12-23 16:26:17.267000 UTC (+/- 1.000  s) (RTT:    3.7 ms)
Google-Sandbox-Roughtime: 2020-12-23 16:26:17.307968 UTC (+/- 1.000  s) (RTT:   16.1 ms)
int08h-Roughtime:         2020-12-23 16:26:17.401888 UTC (+/- 1.000  s) (RTT:  177.0 ms)
roughtime.se:             2020-12-23 16:26:17.574568 UTC (+/- 0.000 ms) (RTT:   26.1 ms)
sjwheel:                  2020-12-23 16:26:17.747868 UTC (+/- 1.000  s) (RTT:  485.6 ms)
No inconsistent replies detected.
$ ./pyroughtime.py -s roughtime.se 2002 S3AzfZJ5CjSdkJ21ZJGbxqdYP/SoE8fXKY0+aicsehI=
2020-12-23 16:26:44.499730 UTC (+/- 0.000 ms) (RTT: 25.7 ms)
TAI - UTC = 37s
Leap events:
  2017-01-01
  2015-07-01
  2012-07-01
Delegate key validity start: 2020-12-22 00:00:00.000000
Delegate key validity end:   2022-01-01 00:00:00.000000
Merkle tree path length: 0

Releasing

REF: https://packaging.python.org/en/latest/tutorials/packaging-projects/

$ python3.11 -m pip install --upgrade build cffi twine
$ python3.11 -m build
# Test
$ python3.11 -m twine upload --repository testpypi dist/*
# Release
$ python3.11 -m twine upload dist/*

License

This project is licensed under the GNU General Public License - see the LICENSE file for details.

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%