From 13cdb055c379def638dd54711486b030af505e9f Mon Sep 17 00:00:00 2001 From: mleku Date: Mon, 9 Dec 2024 10:23:50 +0000 Subject: [PATCH] oops, forgot the id hash part --- event/canonical.go | 12 +++++++++++- realy/version | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/event/canonical.go b/event/canonical.go index a21516b..81e15d3 100644 --- a/event/canonical.go +++ b/event/canonical.go @@ -1,8 +1,10 @@ package event import ( + "io" "reflect" + "realy.lol/ec/schnorr" "realy.lol/hex" "realy.lol/json" "realy.lol/kind" @@ -46,11 +48,19 @@ func NewCanonical() (a *json.Array) { return } +// this is an absolute minimum length canonical encoded event +var minimal = len(`[0,"0123456789abcdef0123456789abcdef",1733739427,0,[],""]`) + // FromCanonical reverses the process of creating the canonical encoding, note that the signature is missing in this // form. Allocate an event.T before calling this. func (ev *T) FromCanonical(b by) (rem by, err er) { rem = b - id := Hash(rem) + end := len(rem) - schnorr.SignatureSize + if end < minimal { + err = io.EOF + return + } + id := Hash(rem[:end]) c := NewCanonical() if rem, err = c.Unmarshal(rem); chk.E(err) { return diff --git a/realy/version b/realy/version index 8a4bd6c..23c38c2 100644 --- a/realy/version +++ b/realy/version @@ -1 +1 @@ -v1.2.41 \ No newline at end of file +v1.3.1 \ No newline at end of file