From @nusenu on github. See https://github.com/torproject/torspec/pull/129
(I have not reviewed this yet; I will review and merge once I'm back from vacation, unless somebody else can do it first.)
I have skimmed this and put it in torspec.
merged