hancock

Check-in [99cee0289a]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:model: prefer model.Authority (to string) for type safety
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 99cee0289a5e9a9e001993306e8becc410ee52d2b8e3e7a07f28c06b675d3532
User & Date: dnc 2019-11-03 11:58:18
Context
2019-11-03
11:59
model: rename manifest "Content" field (was "CID") check-in: da5f7ebb26 user: dnc tags: trunk
11:58
model: prefer model.Authority (to string) for type safety check-in: 99cee0289a user: dnc tags: trunk
2019-10-07
01:09
model: refactor testimony key introduce TestimonyKey, for store and lookup of testimony introduce Key Identifier (KID) derived from Content Identifier (CID) check-in: 5c379c0bb1 user: dnc tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to model/index.go.

15
16
17
18
19
20
21

22
23
24
25
26
27
28
..
41
42
43
44
45
46
47











48
49
50
51
52
53
54
..
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Provides a consistent naming convention for index files.  Multiple
// commands may create and inspect indexes, so we define the common
// conventions in this package.
package model

import (
	"encoding/hex"

	"fmt"
	"log"

	"golang.org/x/crypto/ssh"
)

// We use Keys to store/lookup content.  A Key is really a special
................................................................................
	Authority Authority `json:"authority"`

	// Identifies the object of testimony.
	Content CID `json:"content"`

	kid *Sha256KID // cache
}












// KID calculates an IPFS-style content identifier for a testimony key.
func (this *TestimonyKey) KID() *Sha256KID {
	if this.kid != nil {
		return this.kid
	}
	enc, err := Encode(this)
................................................................................
	this.kid = &id
	return this.kid
}

func IndexKey(source CID, authority interface{}) (key []string, err error) {
	var public ssh.PublicKey
	switch pub := authority.(type) {
	case string:
		// use hex of ssh encoding of public key
		public, _, _, _, err = ssh.ParseAuthorizedKey([]byte(pub))
		if err != nil {
			return
		}
	case ssh.PublicKey:
		public = pub







>







 







>
>
>
>
>
>
>
>
>
>
>







 







|







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
..
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
..
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Provides a consistent naming convention for index files.  Multiple
// commands may create and inspect indexes, so we define the common
// conventions in this package.
package model

import (
	"encoding/hex"
	"errors"
	"fmt"
	"log"

	"golang.org/x/crypto/ssh"
)

// We use Keys to store/lookup content.  A Key is really a special
................................................................................
	Authority Authority `json:"authority"`

	// Identifies the object of testimony.
	Content CID `json:"content"`

	kid *Sha256KID // cache
}

// Test for badly formed keys.
func (this TestimonyKey) Check() error {
	if this.Authority == "" {
		return errors.New("key missing authority field")
	}
	if this.Content.String() == "" {
		return errors.New("key missing content field")
	}
	return nil
}

// KID calculates an IPFS-style content identifier for a testimony key.
func (this *TestimonyKey) KID() *Sha256KID {
	if this.kid != nil {
		return this.kid
	}
	enc, err := Encode(this)
................................................................................
	this.kid = &id
	return this.kid
}

func IndexKey(source CID, authority interface{}) (key []string, err error) {
	var public ssh.PublicKey
	switch pub := authority.(type) {
	case Authority:
		// use hex of ssh encoding of public key
		public, _, _, _, err = ssh.ParseAuthorizedKey([]byte(pub))
		if err != nil {
			return
		}
	case ssh.PublicKey:
		public = pub