Skip to content

Commit

Permalink
oops, forgot the id hash part
Browse files Browse the repository at this point in the history
  • Loading branch information
mleku committed Dec 9, 2024
1 parent 4d8c834 commit 13cdb05
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion event/canonical.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package event

import (
"io"
"reflect"

"realy.lol/ec/schnorr"
"realy.lol/hex"
"realy.lol/json"
"realy.lol/kind"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion realy/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.2.41
v1.3.1

0 comments on commit 13cdb05

Please sign in to comment.