Skip to content

Conversation

@alienx5499
Copy link
Contributor

Summary

Adds a metadata mode to tle:

  • tle -m prints drand network metadata (chain hash, current round, public key, scheme) in YAML.
  • tle -m [INPUT] prints ciphertext metadata by parsing the tlock stanza (round, chain hash) and estimating the corresponding time via round-to-time inversion.

Changes

  • CLI
    • Update usage to document --metadata/-m and examples.
    • When -m is used with an input file, parse armored age header to extract the tlock stanza.
  • Implementation
    • New commands/metadata.go that:
      • Parses armored header and decodes base64 lines to find -> tlock <round> <chainhash>.
      • Estimates the timestamp for the round using a bounded binary search over network.RoundNumber.
    • Wire cmd/tle/tle.go to call network metadata or ciphertext metadata depending on presence of INPUT.

Usage

# Network metadata
tle -m

# Ciphertext metadata (armored .age/.tle)
tle -m path/to/encrypted.age

Notes

  • Ciphertext metadata currently supports armored age files.
  • Time is an estimate computed from the network period/genesis via RoundNumber inversion.

Motivation

Addresses Add a -m flag to tle to see metadata and Closes #30.

Closes #30

@alienx5499
Copy link
Contributor Author

Hey @AnomalRoil
could you please review this PR, when you get a chance?

@alienx5499 alienx5499 force-pushed the feature/tle-metadata-flag branch from e66269c to 968302d Compare November 16, 2025 08:04
@alienx5499
Copy link
Contributor Author

Hi @AnomalRoil,

I've addressed your feedback. Removed all manual armor handling (base64 decoding, BEGIN/END lines, Peek check) and now use armor.NewReader directly. The code is simpler and fully relies on the armor reader as you suggested. All tests pass. Please review when you have a chance. Thanks!

@alienx5499
Copy link
Contributor Author

Hi @AnomalRoil,
Added a test for the Metadata function using the testdata file lorem-tle-testnet-quicknet-t-2024-01-17-15-28.tle as requested. The test verifies metadata extraction (round, chain_hash, time) from armored age files. All tests pass.
Ready for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a -m flag to tle to see metadata

2 participants