notary

package
v0.0.0-...-abd3a35 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package notary is a proof-of-concept public notary service.

Example
package main

import (
	"fmt"

	"github.com/vsekhar/fabula/cmd/notary"
)

func main() {
	svc, _ := notary.NewService()
	data := []byte("hello world")
	n, _ := svc.Notarize(data)
	fmt.Printf("Notarize('%s') --> (%s, %.8x..., %.8x...)", data, n.Timestamp, n.Salt, n.Signature)
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateLog

func ValidateLog(l Log, d Digest) bool

ValidateLog validates a notary log and its digest.

func ValidateNotarization

func ValidateNotarization(b []byte, n Notarization) bool

ValidateNotarization returns true if sig is a valid signature generated by key using b, t, and salt.

func ValidateProof

func ValidateProof(sig []byte, p Proof)

ValidateProof returns true if p is a valid proof that sig has been incorporated into a notary log.

Types

type Digest

type Digest []byte

Digest is a hash summarizing the notary log.

type Log

type Log [][]byte

Log is a full log of all notarizations, including tree elements used in generating compact proofs.

type Notarization

type Notarization struct {
	Salt      []byte
	Timestamp time.Time
	Signature []byte
	PublicKey ed25519.PublicKey
}

Notarization contains the data returned by a notary service.

type Proof

type Proof []ProofEntry

Proof is a slice of entries that represent each of the hashes used to generate the head

type ProofEntry

type ProofEntry struct {
	// contains filtered or unexported fields
}

ProofEntry contains slices of bytes that should be pre- and post-pended to a given data element before generating its signature.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is a verifiable notary service.

func NewService

func NewService() (*Service, error)

NewService returns a new notary Service.

func (*Service) Digest

func (s *Service) Digest() Digest

Digest returns a hash summarizing the service log.

func (*Service) Key

func (s *Service) Key() []byte

Key returns the public key of the Service.

func (*Service) Log

func (s *Service) Log() Log

Log returns the full notary log and its digest.

func (*Service) Notarize

func (s *Service) Notarize(b []byte) (n Notarization, err error)

Notarize returns a notarization of b, or an error.

Notarize will work correctly if b is empty or nil. In this case, the notarization will be of only the random hash and timestamp generated by the Service. The notarization signature can be used further signed by the client to prove the client's possession of some key.

func (*Service) Prove

func (s *Service) Prove(sig []byte) *Proof

Prove returns a Proof that can be used to verify that sig has been incorporated into the service log, or nil if no such proof can be generated.

func (*Service) ProveDigest

func (s *Service) ProveDigest(a, b []byte) *Proof

ProveDigest returns a Proof that can be used to verify that digest a is a predecessor and covered by digest b, or nil if no such proof can be generated.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL