katzenmint

package module
v0.0.0-...-36462e1 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2022 License: Apache-2.0 Imports: 26 Imported by: 1

README

katzenmint-pki

Go

A BFT PKI for the Katzenpost Authority PKI System using Tendermint

Overview

High-level overview of the architecture

Develop

There is setup.sh to help you out setting the develop environment, you can run make setup or sh setup.sh to start.

Or you can follow these steps:

  1. Install tendermint v0.34.6
$ git clone https://github.com/tendermint/tendermint.git
$ cd tendermint
$ git checkout v0.34.6
$ make install
  1. TMHOME=pwd/chain tendermint init
  2. make build
  3. ./katzenmint -config ./chain/config/config.toml
  4. curl -s 'localhost:26657/broadcast_tx_commit?tx="tendermint=rocks"'
  5. curl -s 'localhost:26657/abci_query?data="tendermint"'

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Transaction Common Errors
	ErrTxIsNotValidJSON     = KatzenmintError{Code: 0x01, Msg: "transaction is not valid json string"}
	ErrTxWrongPublicKeySize = KatzenmintError{Code: 0x02, Msg: "wrong public key size in transaction"}
	ErrTxWrongSignatureSize = KatzenmintError{Code: 0x03, Msg: "wrong signature size in transaction"}
	ErrTxWrongSignature     = KatzenmintError{Code: 0x04, Msg: "wrong signature in transaction"}

	// Transaction Specific Errors
	ErrTxDescInvalidVerifier    = KatzenmintError{Code: 0x11, Msg: "cannot get descriptor verifier"}
	ErrTxDescFalseVerification  = KatzenmintError{Code: 0x12, Msg: "cannot verify and parse descriptor"}
	ErrTxDescNotAuthorized      = KatzenmintError{Code: 0x13, Msg: "authority is not authorized"}
	ErrTxDocFalseVerification   = KatzenmintError{Code: 0x14, Msg: "cannot verify and parse document"}
	ErrTxDocEpochNotEqual       = KatzenmintError{Code: 0x15, Msg: "document epoch inconsistent with transaction epoch"}
	ErrTxDocNotAuthorized       = KatzenmintError{Code: 0x16, Msg: "document is not authorized"}
	ErrTxAuthorityParse         = KatzenmintError{Code: 0x17, Msg: "cannot parse authority"}
	ErrTxAuthorityNotAuthorized = KatzenmintError{Code: 0x18, Msg: "descriptor is not authorized"}
	ErrTxCommandNotFound        = KatzenmintError{Code: 0x19, Msg: "transaction command not found"}

	// Transaction Execution Errors
	ErrTxWrongEpoch = KatzenmintError{Code: 0x21, Msg: "expect transaction epoch within +-1 to current epoch"}
	ErrTxUpdateDesc = KatzenmintError{Code: 0x22, Msg: "error updating descriptor"}
	ErrTxUpdateDoc  = KatzenmintError{Code: 0x23, Msg: "error updating document"}
	ErrTxUpdateAuth = KatzenmintError{Code: 0x24, Msg: "error updating authority"}

	// Query Errors
	ErrQueryInvalidFormat    = KatzenmintError{Code: 0x31, Msg: "error query format"}
	ErrQueryUnsupported      = KatzenmintError{Code: 0x32, Msg: "unsupported query"}
	ErrQueryEpochFailed      = KatzenmintError{Code: 0x33, Msg: "cannot obtain epoch for the current height"}
	ErrQueryNoDocument       = KatzenmintError{Code: 0x34, Msg: "requested epoch has passed and will never get a document"}
	ErrQueryDocumentNotReady = KatzenmintError{Code: 0x35, Msg: "document for requested epoch is not ready yet"}
	ErrQueryDocumentUnknown  = KatzenmintError{Code: 0x36, Msg: "unknown failure for document query"}
)

Functions

func DecodeHex

func DecodeHex(src string) (out []byte)

DecodeHex return byte of the given hex string return nil if the src is not valid hex string

func DecodeJson

func DecodeJson(data []byte, v interface{}) error

func EncodeHex

func EncodeHex(src []byte) (out string)

EncodeHex return encoded hex string of the given bytes

func EncodeJson

func EncodeJson(v interface{}) (data []byte, err error)

func FormTransaction

func FormTransaction(command Command, epoch uint64, payload string, privKey *eddsa.PrivateKey) ([]byte, error)

FormTransaction returns the crafted transaction that can be posted

Types

type Authority

type Authority struct {
	// Auth is the prefix of the authority.
	Auth string

	// PubKey is the validator's public key.
	PubKey []byte

	// KeyType is the validator's key type.
	KeyType string

	// Power is the voting power of the authority.
	Power int64
}

Authority represents authority in katzenmint.

func VerifyAndParseAuthority

func VerifyAndParseAuthority(payload []byte) (*Authority, error)

type Command

type Command uint8
var (
	PublishMixDescriptor Command = 1
	AddConsensusDocument Command = 2 // Deprecated
	AddNewAuthority      Command = 3
	GetConsensus         Command = 4
	GetEpoch             Command = 5
)

type KatzenmintApplication

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

func NewKatzenmintApplication

func NewKatzenmintApplication(kConfig *config.Config, db dbm.DB, logger log.Logger) *KatzenmintApplication

func (*KatzenmintApplication) ApplySnapshotChunk

func (*KatzenmintApplication) BeginBlock

Track the block hash and header information

func (*KatzenmintApplication) CheckTx

TODO: gas formula

func (*KatzenmintApplication) Commit

TODO: should update the validators map after commit

func (*KatzenmintApplication) DeliverTx

func (*KatzenmintApplication) EndBlock

Update validators

func (*KatzenmintApplication) Info

func (*KatzenmintApplication) InitChain

func (*KatzenmintApplication) ListSnapshots

TODO: state sync connection

func (*KatzenmintApplication) LoadSnapshotChunk

func (*KatzenmintApplication) OfferSnapshot

func (*KatzenmintApplication) Query

func (app *KatzenmintApplication) Query(rquery abcitypes.RequestQuery) (resQuery abcitypes.ResponseQuery)

func (*KatzenmintApplication) SetOption

type KatzenmintError

type KatzenmintError struct {
	Code uint32
	Msg  string
	// contains filtered or unexported fields
}

func (KatzenmintError) Error

func (err KatzenmintError) Error() string

type KatzenmintState

type KatzenmintState struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewKatzenmintState

func NewKatzenmintState(kConfig *config.Config, db dbm.DB) *KatzenmintState

func (*KatzenmintState) BeginBlock

func (state *KatzenmintState) BeginBlock()

func (*KatzenmintState) Commit

func (state *KatzenmintState) Commit() ([]byte, error)

func (*KatzenmintState) Delete

func (state *KatzenmintState) Delete(key []byte) error

func (*KatzenmintState) Get

func (state *KatzenmintState) Get(key []byte) ([]byte, error)

func (*KatzenmintState) GetAuthorized

func (state *KatzenmintState) GetAuthorized(addr string) (pc.PublicKey, bool)

func (*KatzenmintState) Set

func (state *KatzenmintState) Set(key []byte, value []byte) error

type Query

type Query struct {
	// version
	Version string

	// Epoch
	Epoch uint64

	// command
	Command Command

	// payload
	Payload string
}

Query represents the Query request

type Transaction

type Transaction struct {
	// version
	Version string

	// Epoch
	Epoch uint64

	// command
	Command Command

	// hex encoded ed25519 public key (should not be 0x prefxied)
	PublicKey string

	// hex encoded ed25519 signature (should not be 0x prefixed)
	Signature string

	// json encoded payload (eg. mix descriptor/authority)
	Payload string
}

TODO: find a better way to represent the Transaction maybe add nonce? switch to rlp encoding? Transaction represents a transaction used to make state change, eg: publish mix descriptor or add new authority

func (*Transaction) Address

func (tx *Transaction) Address() string

Address returns public address of the given transaction

func (*Transaction) IsVerified

func (tx *Transaction) IsVerified() (isVerified bool)

IsVerified returns whether transaction was signed by the public key

func (*Transaction) PublicKeyByteArray

func (tx *Transaction) PublicKeyByteArray() (pk [eddsa.PublicKeySize]byte)

PublicKeyByteArray returns public key bytes of the given transaction

func (*Transaction) PublicKeyBytes

func (tx *Transaction) PublicKeyBytes() (pk []byte)

PublicKeyBytes returns public key bytes of the given transaction

func (*Transaction) SerializeHash

func (tx *Transaction) SerializeHash() (txHash [32]byte)

SerializeHash returns the serialize hash that user signed of the given transaction

Directories

Path Synopsis
cmd
Package s11n implements serialization routines for the various PKI data structures.
Package s11n implements serialization routines for the various PKI data structures.

Jump to

Keyboard shortcuts

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