From 9d2382cf5f10f06245d5f0cc7b8b250e6e19d06e Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sun, 23 Mar 2025 18:53:35 +0800 Subject: Add MathML notation --- flags.go | 1 + global.go | 7 ++++--- main.go | 4 +++- tmpl.go | 1 + 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/flags.go b/flags.go index 8dba141..8e3fcba 100644 --- a/flags.go +++ b/flags.go @@ -18,4 +18,5 @@ func init() { flag.StringVar(&destHost, "upstream", "http://127.0.0.1:8080", "destination url base to proxy to") flag.BoolVar(&secondary, "secondary", false, "trust X-Forwarded-For headers") flag.Parse() + global.NeedBitsReverse = 256 - global.NeedBits } diff --git a/global.go b/global.go index b5afaa8..772dce5 100644 --- a/global.go +++ b/global.go @@ -4,7 +4,8 @@ package main var global = struct { - NeedBits uint - SourceURL string - Version string + NeedBits uint + NeedBitsReverse uint + SourceURL string + Version string }{} diff --git a/main.go b/main.go index 342138e..77f1456 100644 --- a/main.go +++ b/main.go @@ -39,11 +39,13 @@ func main() { } authPage := func(message string) { - _ = tmpl.Execute(writer, tparams{ + err := tmpl.Execute(writer, tparams{ Identifier: base64.StdEncoding.EncodeToString(identifier), Message: message, Global: global, }) + if err != nil { + } } if request.ParseForm() != nil { diff --git a/tmpl.go b/tmpl.go index ca21b96..b6fb9e0 100644 --- a/tmpl.go +++ b/tmpl.go @@ -195,6 +195,7 @@ func init() {

Select a nonce no longer than 32 bytes, such that when it is appended to the decoded form of the challenge identifier, and the entire result is hashed with SHA-256, the first {{ .Global.NeedBits }} bits of the SHA-256 hash are all zeros. Within one octet, higher bits are considered to come before lower bits.

+

In other words, find an nonce NN with |N|32B\lvert N\rvert \le 32\,\mathrm{B}, such that SHA256(BN)<2{{ .Global.NeedBitsReverse }}\mathrm{SHA256}(B \,\|\, N) < 2^{{{ .Global.NeedBitsReverse }}} in big endian.

-- cgit v1.2.3