// FingerprintTriple generates a SHA-1 hash of the triple. func FingerprintTriple(t *protocol.Triple) ([]byte, error) { data, err := t.Marshal() if err != nil { return nil, err } sum := sha1.Sum(data) return sum[:], nil }
// FingerprintTriple generates a SHA-1 hash of the triple. func FingerprintTriple(t *protocol.Triple) ([]byte, error) { h := sha1.New() data, err := t.Marshal() if err != nil { return nil, err } if _, err := h.Write(data); err != nil { return nil, err } return h.Sum(nil), nil }
func (key *PrivateKey) SignTriple(t *protocol.Triple) error { var err error t.Author, err = key.AuthorID() if err != nil { return err } fingerprint, err := FingerprintTriple(t) if err != nil { return err } r, s, err := ecdsa.Sign(rand.Reader, (*ecdsa.PrivateKey)(key), fingerprint) if err != nil { return err } t.Sig = string(r.Bytes()) + string(s.Bytes()) return nil }