~edwargix/tallyard

7030fa2f — David Florness 3 years ago
Fix panic when our device doesn't have election private keys

In cases where the user joins an election on another computer, we need to make
sure we don't panic merely because our device doesn't have the private keys to
fully verify sum+evals messages.  This change simply marks the verification
process of the election as failed.

In the future we can use something like SSSS to share keys between tallyard
devices.
19e636e7 — David Florness 3 years ago
Fix race condition in processing logic

This fixes the following nil pointer panic that happens when a message is being
processed but also requested in event.go.  I have no idea what I was thinking
with the `goto process` code in getAndHandleEvent ...

    waiting for evals...
    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x190 pc=0x9eb25b]

    goroutine 1 [running]:
    tallyard.xyz/election.(*ElectionsMap).SetupEventHooks.func1.1(0x0, 0xc0010589c0)
	    /home/matrix/src/election/msg.go:153 +0x5b
    tallyard.xyz/election.(*EventStore).getAndHandleEvent(0xc000112340, 0xc000130030, 0x21, 0xc001a63b30, 0x2c, 0xc0b2f8, 0x12, 0x1, 0xc0014481e0, 0x0, ...)
	    /home/matrix/src/election/event.go:222 +0x176
    tallyard.xyz/election.(*EventStore).GetEvalsEvent(0xc000112340, 0xc000130030, 0x21, 0xc001a63b30, 0x2c, 0xc00025a030)
	    /home/matrix/src/election/event.go:163 +0x98
    tallyard.xyz/election.(*Election).SendSum(0xc001a80a00, 0xc000022620, 0xc000112340, 0x1, 0x1)
	    /home/matrix/src/election/voter.go:457 +0x4e4
    main.main()
	    /home/matrix/src/cmd/tallyard/main.go:181 +0xb46
e1e45f12 — David Florness 3 years ago
Enable extra mautrix-go logging and bump mautrix-go for new logging

The bump is done to take advantage of the useful logging added in
https://github.com/mautrix/go/commit/3b28f2d
6d60abc6 — David Florness 3 years ago
Log sync exits
1e94d712 — David Florness 3 years ago
Log sync errors

and decrease the sleep duration from 10 seconds [0] to 5 seconds.

[0]: https://github.com/mautrix/go/blob/v0.10.8/sync.go#L228
b47f8d81 — David Florness 3 years ago
README: "libolm ... library" is redundant
f6e9801c — David Florness 3 years ago
README: mention need for libolm in source instructions
51b5e5af — David Florness 3 years ago v0.4.0
Bump version in README
b4f7f63c — David Florness 3 years ago
README: update mautrix-go URL
6913ef19 — David Florness 3 years ago
site: "dev mailing list" -> "mailing list"
ed6d68b0 — David Florness 3 years ago
site: put links on separate line from image and center those
764d886e — David Florness 3 years ago v0.4.0-rc1
Use fork of mautrix-go with bugfix

We're occasionally hitting the following error:

    panic: runtime error: slice bounds out of range [:208] with capacity 90 [recovered]
	    panic: runtime error: slice bounds out of range [:208] with capacity 90 [recovered]
	    panic: (*logrus.Entry) (0xbef2e0,0xc0000d2070)

    goroutine 1 [running]:
    github.com/sirupsen/logrus.(*Entry).log(0xc0001b62a0, 0x0, 0xc000464000, 0xf8f)
	    /home/matrix/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/entry.go:259 +0x2e2
    github.com/sirupsen/logrus.(*Entry).Log(0xc0001b62a0, 0x0, 0xc0004383f0, 0x1, 0x1)
	    /home/matrix/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/entry.go:293 +0x86
    github.com/sirupsen/logrus.(*Entry).Logf(0xc0001b62a0, 0xc000000000, 0xc0d38a, 0x1d, 0xc0004384a8, 0x2, 0x2)
	    /home/matrix/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/entry.go:338 +0xe2
    github.com/sirupsen/logrus.(*Logger).Logf(0xc0000d2e00, 0x0, 0xc0d38a, 0x1d, 0xc0004384a8, 0x2, 0x2)
	    /home/matrix/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/logger.go:151 +0x94
    github.com/sirupsen/logrus.(*Logger).Panicf(...)
	    /home/matrix/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/logger.go:192
    github.com/sirupsen/logrus.Panicf(...)
	    /home/matrix/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/exported.go:219
    tallyard.xyz/ui.RoomTUI.func1(0xc000308130)
	    /home/matrix/src/ui/tui.go:189 +0xe5
    panic(0xba8da0, 0xc00033e980)
	    /usr/lib/go/src/runtime/panic.go:679 +0x1b2
    github.com/rivo/tview.(*Application).Run.func1(0xc000358000)
	    /home/matrix/go/pkg/mod/github.com/rivo/tview@v0.0.0-20211202162923-2a6de950f73b/application.go:243 +0x82
    panic(0xba8da0, 0xc00033e980)
	    /usr/lib/go/src/runtime/panic.go:679 +0x1b2
    maunium.net/go/mautrix/crypto/canonicaljson.RawJSONFromResult(...)
	    /home/matrix/go/pkg/mod/maunium.net/go/mautrix@v0.10.8/crypto/canonicaljson/json.go:274
    maunium.net/go/mautrix/crypto/canonicaljson.sortJSONObject.func1(0x3, 0xc0003652c7, 0x9, 0xc0003652c8, 0x7, 0x0, 0xc7, 0x0, 0x0, 0x0, ...)
	    /home/matrix/go/pkg/mod/maunium.net/go/mautrix@v0.10.8/crypto/canonicaljson/json.go:113 +0x2b5
    github.com/tidwall/gjson.Result.ForEach(0x5, 0xc0003652c6, 0x55, 0x0, 0x0, 0x0, 0xc6, 0x0, 0x0, 0x0, ...)
	    /home/matrix/go/pkg/mod/github.com/tidwall/gjson@v1.12.1/gjson.go:293 +0x33d
    maunium.net/go/mautrix/crypto/canonicaljson.sortJSONObject(0x5, 0xc0003652c6, 0x55, 0x0, 0x0, 0x0, 0xc6, 0x0, 0x0, 0x0, ...)
	    /home/matrix/go/pkg/mod/maunium.net/go/mautrix@v0.10.8/crypto/canonicaljson/json.go:110 +0xe4
    maunium.net/go/mautrix/crypto/canonicaljson.sortJSONValue(0x5, 0xc0003652c6, 0x55, 0x0, 0x0, 0x0, 0xc6, 0x0, 0x0, 0x0, ...)
	    /home/matrix/go/pkg/mod/maunium.net/go/mautrix@v0.10.8/crypto/canonicaljson/json.go:62 +0x23b
    maunium.net/go/mautrix/crypto/canonicaljson.sortJSONObject(0x5, 0xc000365200, 0x11c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	    /home/matrix/go/pkg/mod/maunium.net/go/mautrix@v0.10.8/crypto/canonicaljson/json.go:136 +0x39d
    maunium.net/go/mautrix/crypto/canonicaljson.sortJSONValue(0x5, 0xc000365200, 0x11c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	    /home/matrix/go/pkg/mod/maunium.net/go/mautrix@v0.10.8/crypto/canonicaljson/json.go:62 +0x23b
    maunium.net/go/mautrix/crypto/canonicaljson.SortJSON(0xc000364fc0, 0x11c, 0x11c, 0xc0003650e0, 0x0, 0x11c, 0xc000364fc0, 0x11c, 0x11c)
	    /home/matrix/go/pkg/mod/maunium.net/go/mautrix@v0.10.8/crypto/canonicaljson/json.go:51 +0x1b1
    maunium.net/go/mautrix/crypto/canonicaljson.CanonicalJSONAssumeValid(0xc000364fc0, 0x11c, 0x11c, 0x120, 0xc000364ea0, 0x11c)
	    /home/matrix/go/pkg/mod/maunium.net/go/mautrix@v0.10.8/crypto/canonicaljson/json.go:42 +0xe0
    maunium.net/go/mautrix/crypto/canonicaljson.CanonicalJSON(0xc000364d80, 0x11c, 0x120, 0x11c, 0x120, 0x0, 0x0, 0x382a611eb390c)
	    /home/matrix/go/pkg/mod/maunium.net/go/mautrix@v0.10.8/crypto/canonicaljson/json.go:35 +0x8e
    tallyard.xyz/election.CalculateCommitment(0xc0004396e8, 0x1, 0x1, 0x20, 0x20, 0x20, 0x20)
	    /home/matrix/src/election/utils.go:42 +0x153
    tallyard.xyz/election.(*Election).JoinElection(0xc0000a6f00, 0xc0000e4460, 0xc000064140, 0x0, 0x0)
	    /home/matrix/src/election/voter.go:101 +0x24d
    tallyard.xyz/ui.RoomTUI.func4(0x0, 0xc05072, 0xf, 0xc10084, 0x21, 0xc000000000)
	    /home/matrix/src/ui/tui.go:268 +0x32f
    github.com/rivo/tview.(*List).InputHandler.func1(0xc00027a180, 0xc0003081b0)
	    /home/matrix/go/pkg/mod/github.com/rivo/tview@v0.0.0-20211202162923-2a6de950f73b/list.go:591 +0x278
    github.com/rivo/tview.(*Box).WrapInputHandler.func1(0xc00027a180, 0xc0003081b0)
	    /home/matrix/go/pkg/mod/github.com/rivo/tview@v0.0.0-20211202162923-2a6de950f73b/box.go:167 +0x5d
    github.com/rivo/tview.(*Application).Run(0xc000358000, 0x0, 0x0)
	    /home/matrix/go/pkg/mod/github.com/rivo/tview@v0.0.0-20211202162923-2a6de950f73b/application.go:335 +0x7db
    tallyard.xyz/ui.(*tallyardApplication).Run(...)
	    /home/matrix/src/ui/tui.go:594
    tallyard.xyz/ui.RoomTUI(0xc0002fe060, 0xc0000e4460, 0xc00025c010, 0xc0002fe000, 0xd02740, 0xc0000a0820, 0xc00025c010, 0x0, 0x0)
	    /home/matrix/src/ui/tui.go:285 +0x479
    main.main()
	    /home/matrix/src/cmd/tallyard/main.go:110 +0x7fb

My fork of mautrix-go at git.hnitbjorg.xyz has a patch that forgoes a gjson
optimization to prevent this issue.

See https://git.hnitbjorg.xyz/~edwargix/mautrix-go/commit/f4965a653a70 and
https://github.com/mautrix/go/issues/52 for further details.
ecc4da03 — David Florness 3 years ago
Upgrade dependencies

go get -v -u -t ./...
go mod tidy
348f16f4 — David Florness 3 years ago
Upgrade gnark
0d0324f0 — David Florness 3 years ago
Add hash commitments to messages to ensure integrity

This ensures that the content of events in an election are consistent between
senders and receivers.  This protects against malicious homeserver admins who
attempt to secretly edit events before they reach voters.

This also prevents exploitation of a bug in synapse where users can edit events
and thereby change their content while keeping the IDs the same; see
https://github.com/matrix-org/synapse/issues/10310 for details.
5c11b7e1 — David Florness 3 years ago
TUI: don't display user ID more than once if user rejoins
d2281896 — David Florness 3 years ago
Don't panic in event handlers on nil event

This is causing panics in (*EventStore).getAndHandleEvent
f3c3f657 — David Florness 3 years ago
Send human-readable event on election creation
47dc769a — David Florness 3 years ago
TUI: properly handle panics inside goroutine
Next