pof

Proof of Freshness: collate proof of an authorship date.

Log | Files | << Repositories


tree bc55268ef1ba9f919a9eaedc04f312d15b76d885
parent 66dddbfd4ea86a3f6745fdb436d0aef6059c5294
author esote <esote.net@gmail.com> 1563404391 -0500
committer esote <esote.net@gmail.com> 1563404391 -0500
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iHUEABYIAB0WIQTXAxYDuIzimYoNSPuhTmRAjzzC8gUCXS+oagAKCRChTmRAjzzC
 8iW2AP0QD7kUdbncG3pmidua2BvUNM6gOCZVU5a6Xov4xj6ZCgD/YDKsA9RBH0CF
 7+KC5U3hXIki/Zg/3Kue0nm5BsOlbg0=
 =8Zli
 -----END PGP SIGNATURE-----

Add arXiv recently submitted preprints

 README |  75 +++++++++++++++++++++++++++--------------------
 pof.go | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++---------------
 2 files changed, 124 insertions(+), 55 deletions(-)

diff --git a/README b/README
index 13d10c0..699a73c 100644
--- a/README
+++ b/README
@@ -16,62 +16,75 @@ Current sources:
 	- NIST randomness beacon v2
 	- Bitcoin block hash, depth 10
 	- Monero block hash, depth 10
+	- arXiv recently submitted preprints
 
 Inspired by the proof of freshness used in Qubes OS's canaries.
 
 Example output:
 
-	Date: 2019-07-17 03:29 UTC
+	Date: 2019-07-17 22:57 UTC
 
-	Src: SPIEGEL ONLINE - International (https://www.spiegel.de/international/index.rss)
+	Src: News: SPIEGEL ONLINE - International (https://www.spiegel.de/international/index.rss)
 	 ---
+	The New European Commission President: Von Der Leyen's Election Is a Big Moment for Europe
 	'Euro Orphans': The Romanian Children Growing up Without Their Parents
 	Far-Right AfD: Germany's Populist Party Embraces Its Extremist Wing
 	A Question of Trust: Ursula Von Der Leyen Recruits Team to Win Over Brussels
 	Feeding People With Science: Plant Researchers Brace for Population Explosion
-	A Heroine and a Figure of Hate: Carola Rackete and Europe's Troubling Refugee Policies
 
-	Src: NYT > World News (https://rss.nytimes.com/services/xml/rss/nyt/World.xml)
+	Src: News: NYT > World News (https://rss.nytimes.com/services/xml/rss/nyt/World.xml)
 	 ---
+	Ebola Outbreak in Congo Is Declared a Global Health Emergency
 	A Prosperous China Says  Men Preferred,  and Women Lose
-	Epstein s Ties to Former Israeli Leader Shake Up Election Campaign
-	A Runaway Train Explosion Killed 47, but Deadly Cargo Still Rides the Rails
-	Iran s Top Leader Strikes Defiant Tone as Trump Says  We re Not Looking for Regime Change
-	Turkey s Erdogan Goes His Own Way as Distrust With U.S. Grows
+	Iran Says It Aided Oil Tanker, Amid Reports of Missing U.A.E. Ship
+	As Iran vs. West Tensions Rise, So Does Uncertainty Over Prisoners
+	What Kind of Peace Talks Are These : On the Front Lines of a 17-Year War
 
-	Src: BBC News - World (https://feeds.bbci.co.uk/news/world/rss.xml)
+	Src: News: BBC News - World (https://feeds.bbci.co.uk/news/world/rss.xml)
 	 ---
-	US House condemns Trump's attacks on four congresswomen
-	Von der Leyen elected EU Commission head after MEPs vote
-	Johnny Clegg, South African musician and activist, dies aged 66
-	Norway's spy Town: 'They took him and they have broken him'
-	Facebook's Libra cryptocurrency attacked at Senate hearing
+	El Chapo trial: Mexican drug lord Joaqu n Guzm n gets life in prison
+	DR Congo Ebola outbreak declared global health emergency
+	Opioid crisis: US drug overdose deaths drop by 5.1%
+	Dolphin megapod spotted off California coast swimming alongside boat
+	Battle of Waterloo: Excavation unearths amputated limbs
 
-	Src: Reuters: World News (http://feeds.reuters.com/reuters/worldnews)
+	Src: News: Reuters: World News (http://feeds.reuters.com/reuters/worldnews)
 	 ---
-	Gun megastore plan in New Zealand's Christchurch sparks backlash: media
-	Puerto Rico governor vows to remain in office after violent protests
-	ACLU files suit to block Trump rule to stop asylum-seekers
-	Germany's Von der Leyen secures powerful EU executive top job
-	German Conservative boss to succeed von der Leyen as minister
+	U.S. removing Turkey from F-35 program after its Russian missile defense purchase
+	Croatia PM reshuffles cabinet, proposes six new ministers
+	UK's Johnson declines to comment on plan to facilitate a no-deal Brexit
+	UK ministers could resign in battle over suspending parliament: BBC reporter
+	Criticizing populism, Britain's May has Brexit advice for successor
 
-	Src: Latest Updates (https://www.economist.com/latest/rss.xml)
+	Src: News: Latest Updates (https://www.economist.com/latest/rss.xml)
 	 ---
-	Ursula von der Leyen is elected European Commission president
-	How slow can you grow?
-	Novak Djokovic wins the most thrilling men s tennis match ever
-	 The Farewell  is a poignant study of family, tradition and identity
-	What is a tiebreak?
+	The next giant leap for mankind
+	Can Rory McIlroy win on his home turf?
+	Donald Trump s border wall reaches the Supreme Court
+	Unreliable evidence a forensic look at identification
+	The industry and poetry of David Smith
 
 	Src: NIST Beacon v2 (https://beacon.nist.gov/beacon/2.0/pulse/last)
 	 ---
-	0CC14EA51480B1A72D20DBF4099676C9CE80535AECD6213BA8AB70F696FEF4D7415BECB951C9A0243AAF5511D4C8F335062E8F33273AB5FF61692407A99D2D67
+	019BB7134A0B15126A4677E81598EDFA8780AAD3B92B4950026EFB742BCE4EFE94BC6738772DB21D1E560CCBEC8648E01A4BE533EE03B8B4E92C774DCB53549F
 
-	Src: Blockchain.Info [block depth 10] (https://blockchain.info/block-height/585763?format=json)
+	Src: Blockchain.Info [block depth 10] (https://blockchain.info/block-height/585860?format=json)
 	 ---
-	00000000000000000000f55723baa1e873632afb1c8fc27a496c9e44caab47d9
+	00000000000000000004cdf0df4abd8b7a4d93d80d00b8349c2307d8903187ed
 
-	Src: Moneroblocks.Info [block depth 10] (https://moneroblocks.info/api/get_block_header/1880172)
+	Src: Moneroblocks.Info [block depth 10] (https://moneroblocks.info/api/get_block_header/1880753)
 	 ---
-	976170416a969c8e3a2cca3069a3c592e9e80ba81707ae75393bed3404b3f8f3
+	e19dd23ad944ba4dc467a9cadb0e8db3c207e52c67349cc285302359c8eb6f0a
 
+	Src: arXiv recently submitted (https://export.arxiv.org/api/query?search_query=all&sortBy=submittedDate&sortOrder=descending&max_results=10)
+	 ---
+	On Higher Dimensional Generalized Kuramoto Oscillator Systems (Max Lipton, et al., 2019-07-16T17:19:55Z)
+	Higher genus relative Gromov--Witten theory and DR-cycles (Honglu Fan, et al., 2019-07-16T17:03:16Z)
+	Measuring I2P Censorship at a Global Scale (Nguyen Phong Hoang, et al., 2019-07-16T16:57:22Z)
+	On the smallest singular value of multivariate Vandermonde matrices with cluster... (Stefan Kunis, et al., 2019-07-16T16:55:13Z)
+	Primarily Undergraduate Institutions and the Astronomy Community (Joseph Ribaudo, et al., 2019-07-16T16:53:41Z)
+	Measurement of the jet mass in high transverse momentum $Z(\rightarrow b\overlin... (ATLAS Collaboration, 2019-07-16T16:03:43Z)
+	On The Termination of a Flooding Process (Walter Hussak, et al., 2019-07-16T15:45:12Z)
+	Equilibrium Microcanonical Annealing for First-Order Phase Transitions (Nathan Rose, et al., 2019-07-16T15:25:52Z)
+	Minimisation of Event Structures (Paolo Baldan, et al., 2019-07-16T14:48:54Z)
+	Serre's Property (FA) for automorphism groups of free products (Naomi Andrew, 2019-07-16T14:14:11Z)
diff --git a/pof.go b/pof.go
index 60193ad..d2d7836 100644
--- a/pof.go
+++ b/pof.go
@@ -24,6 +24,7 @@ func main() {
 		nist,
 		btc,
 		monero,
+		arxiv,
 	}
 
 	for _, source := range sources {
@@ -33,16 +34,10 @@ func main() {
 	}
 }
 
-// Structure of an RSS feed, exposing only the fields useful to print news().
-type Rss struct {
-	Name   string   `xml:"channel>title"`
-	Titles []string `xml:"channel>item>title"`
-}
+var re = regexp.MustCompile(`[^[:ascii:]]+`)
 
 // International news feeds.
 func news() error {
-	re := regexp.MustCompile(`[^[:ascii:]]+`)
-
 	urls := [...]string{
 		"https://www.spiegel.de/international/index.rss",
 		"https://rss.nytimes.com/services/xml/rss/nyt/World.xml",
@@ -54,17 +49,27 @@ func news() error {
 	const count = 5
 
 	for _, url := range urls {
-		rss, err := parseRss(url)
+		data, err := getRead(url)
 
 		if err != nil {
 			return err
 		}
 
+		// Structure of an RSS feed, exposing only the useful fields
+		var rss struct {
+			Name   string   `xml:"channel>title"`
+			Titles []string `xml:"channel>item>title"`
+		}
+
+		if err = xml.Unmarshal(data, &rss); err != nil {
+			return err
+		}
+
 		if len(rss.Titles) < count {
 			return fmt.Errorf("couldn't find %d articles", count)
 		}
 
-		fmt.Printf("Src: %s (%s)\n ---\n",
+		fmt.Printf("Src: News: %s (%s)\n ---\n",
 			strings.TrimSpace(re.ReplaceAllString(rss.Name, " ")),
 			url)
 
@@ -78,21 +83,6 @@ func news() error {
 	return nil
 }
 
-// GET and unmarshal RSS URL.
-func parseRss(url string) (*Rss, error) {
-	data, err := getRead(url)
-
-	if err != nil {
-		return nil, err
-	}
-
-	var rss Rss
-
-	err = xml.Unmarshal(data, &rss)
-
-	return &rss, err
-}
-
 // NIST randomness beacon v2.
 func nist() error {
 	const v2url = "https://beacon.nist.gov/beacon/2.0/pulse/last"
@@ -216,6 +206,72 @@ func monero() error {
 	return nil
 }
 
+// arXiv recently published preprints.
+func arxiv() error {
+	const (
+		queryUrl = "https://export.arxiv.org/api/query?" +
+			"search_query=all&sortBy=submittedDate&" +
+			"sortOrder=descending&max_results=%d"
+		count  = 10
+		maxlen = 80
+	)
+
+	data, err := getRead(fmt.Sprintf(queryUrl, count))
+
+	if err != nil {
+		return err
+	}
+
+	var arxiv struct {
+		Entries []struct {
+			Published string   `xml:"published"`
+			Title     string   `xml:"title"`
+			Authors   []string `xml:"author>name"`
+		} `xml:"entry"`
+	}
+
+	if err := xml.Unmarshal(data, &arxiv); err != nil {
+		return err
+	}
+
+	if len(arxiv.Entries) != count {
+		return fmt.Errorf("response length mismatched %d", count)
+	}
+
+	fmt.Printf("Src: arXiv recently submitted (%s)\n ---\n",
+		fmt.Sprintf(queryUrl, count))
+
+	for _, entry := range arxiv.Entries {
+		entry.Title = re.ReplaceAllString(entry.Title, " ")
+		entry.Title = strings.ReplaceAll(entry.Title, "\n ", "")
+
+		if len(entry.Title) > maxlen {
+			entry.Title = entry.Title[:maxlen] + "..."
+		}
+
+		entry.Title = strings.TrimSpace(entry.Title)
+
+		var author string
+
+		if len(entry.Authors) > 0 {
+			author = entry.Authors[0]
+		}
+
+		if len(entry.Authors) > 1 {
+			author += ", et al."
+		}
+
+		author = strings.TrimSpace(re.ReplaceAllString(author, " "))
+
+		fmt.Printf("%s (%s, %s)\n", entry.Title, author,
+			entry.Published)
+	}
+
+	fmt.Println()
+
+	return nil
+}
+
 // Make GET request and read body, reducing duplicate ioutil.ReadAll and error
 // checking code.
 func getRead(url string) ([]byte, error) {