katzenmint

package
v0.0.0-...-c15aa5a Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: GPL-3.0, Apache-2.0 Imports: 28 Imported by: 1

README

katzenmint-pki

Katzenmint

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. Initialize the identity credential identity TMHOME=pwd/chain tendermint init
  2. Build katzenmint make build
  3. Execute ./katzenmint -config ./chain/config/config.toml

Documentation

Index

Constants

View Source
const (
	GenesisEpoch  uint64        = 1
	EpochInterval int64         = 10
	HeightPeriod  time.Duration = 1 * time.Second
	LifeCycle     uint64        = 3
)

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: "descriptor 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"}
	ErrTxAuthorityExists        = KatzenmintError{Code: 0x18, Msg: "authority already existed"}
	ErrTxAuthorityNotAuthorized = KatzenmintError{Code: 0x19, Msg: "authority is not authorized"}
	ErrTxCommandNotFound        = KatzenmintError{Code: 0x1A, 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"}
	ErrQueryAppClosed        = KatzenmintError{Code: 0x37, Msg: "application has been closed"}

	// Authority Errors
	ErrAuthorityKeyTypeNotSupported = KatzenmintError{Code: 0x41, Msg: "authority key type is not supported"}
)

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

func SinceEpochStart

func SinceEpochStart(ellapsedHeight int64) time.Duration

func TillEpochFinish

func TillEpochFinish(ellapsedHeight int64) time.Duration

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

	// Credential is the credential for becoming an authority
	Credential string
}

Authority represents authority in katzenmint.

type AuthorityChecked

type AuthorityChecked struct {
	Auth       string
	Val        *abcitypes.ValidatorUpdate
	Credential string
}

AuthorityChecked represents checked authority.

func VerifyAndParseAuthority

func VerifyAndParseAuthority(payload []byte) (*AuthorityChecked, 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, dbCacheSize int, 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) Close

func (app *KatzenmintApplication) Close()

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
}

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, dbCacheSize int) *KatzenmintState

func (*KatzenmintState) BeginBlock

func (state *KatzenmintState) BeginBlock()

func (*KatzenmintState) Close

func (state *KatzenmintState) Close()

func (*KatzenmintState) Commit

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

func (*KatzenmintState) GetAuthority

func (state *KatzenmintState) GetAuthority(addr string) (*pc.PublicKey, error)

func (*KatzenmintState) GetDocument

func (state *KatzenmintState) GetDocument(epoch uint64, height int64) ([]byte, *ics23.CommitmentProof, error)

func (*KatzenmintState) GetEpoch

func (state *KatzenmintState) GetEpoch(height int64) ([]byte, *ics23.CommitmentProof, 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
Package cert provides a cryptographic certicate library.
Package cert provides a cryptographic certicate library.
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