carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package release
2
3import (
4 "context"
5 "encoding/hex"
6 "os"
7)
8
9func PublishHistoryReconstruction(ctx context.Context, store Store, signer Signer, g HistoryReconstruction) error {
10 if !ValidAccount(g.Account) || !ValidApp(g.App) || len(g.Identity) != 64 || g.Revision == 0 {
11 return os.ErrPermission
12 }
13 if _, err := hex.DecodeString(g.Identity); err != nil {
14 return os.ErrPermission
15 }
16 wire, err := SignRootEnvelope(signer, g)
17 if err != nil {
18 return err
19 }
20 _, err = store.Put(ctx, HistoryReconstructionKey(g.Account, g.App, g.Identity, g.Revision), wire, "")
21 return err
22}
23
24func PublishHistoryRecoveryRetirement(ctx context.Context, store Store, signer Signer, g HistoryRecoveryRetirement) error {
25 if !validHistoryRetirement(g) {
26 return os.ErrPermission
27 }
28 for _, digest := range []string{g.Identity, g.OutcomeDigest, g.VerifiedDigest} {
29 if _, err := hex.DecodeString(digest); err != nil {
30 return os.ErrPermission
31 }
32 }
33 wire, err := SignRootEnvelope(signer, g)
34 if err != nil {
35 return err
36 }
37 _, err = store.Put(ctx, HistoryRecoveryRetirementKey(g.Binding, g.Identity, g.OutcomeDigest), wire, "")
38 return err
39}
40