markl

package
v0.0.0-...-2e33cca Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// keep sorted
	FormatIdEd25519Pub = "ed25519_pub"
	FormatIdEd25519Sec = "ed25519_sec"
	FormatIdEd25519Sig = "ed25519_sig"

	FormatIdAgeX25519Pub = "age_x25519_pub"
	FormatIdAgeX25519Sec = "age_x25519_sec"

	FormatIdHashSha256     = "sha256"
	FormatIdHashBlake2b256 = "blake2b256"

	FormatIdNonceSec = "nonce"
)

actual formats

View Source
const (
	PurposeTypeUnknown = purposeType(iota)
	PurposeTypeBlobDigest
	PurposeTypeObjectDigest
	PurposeTypeObjectMotherSig
	PurposeTypeObjectSig
	PurposeTypePrivateKey
	PurposeTypePubKey
	PurposeTypeRepoPubKey
	PurposeTypeRequestAuth
)
View Source
const (

	// Blob Digests
	PurposeBlobDigestV1 = "dodder-blob-digest-sha256-v1"

	// Object Digests
	PurposeObjectDigestV1             = "dodder-object-digest-sha256-v1"
	PurposeObjectDigestV2             = "dodder-object-digest-v2"
	PurposeV5MetadataDigestWithoutTai = "dodder-object-metadata-digest-without_tai-v1"

	// Object Mother Sigs
	PurposeObjectMotherSigV1 = "dodder-object-mother-sig-v1"
	PurposeObjectMotherSigV2 = "dodder-object-mother-sig-v2"

	// Object Sigs
	PurposeObjectSigV0 = "dodder-repo-sig-v1"
	PurposeObjectSigV1 = "dodder-object-sig-v1"
	PurposeObjectSigV2 = "dodder-object-sig-v2"

	// Request Auth
	PurposeRequestAuthResponseV1  = "dodder-request_auth-response-v1"
	PurposeRequestRepoSigV1       = "dodder-request_auth-repo-sig-v1"
	PurposeRequestAuthChallengeV1 = "dodder-request_auth-challenge-v1"

	// PubKeys
	PurposeRepoPubKeyV1   = "dodder-repo-public_key-v1"
	PurposeMadderPubKeyV1 = "madder-public_key-v1"

	// PrivateKeys
	PurposeRepoPrivateKeyV1   = "dodder-repo-private_key-v1"
	PurposeMadderPrivateKeyV0 = "madder-private_key-v0"
	PurposeMadderPrivateKeyV1 = "madder-private_key-v1"
)

purposes currently treated as formats

Variables

View Source
var ErrEmptyType = newPkgError("type is empty")

Functions

func AgeX25519Generate

func AgeX25519Generate(_ io.Reader) (bites []byte, err error)

func AgeX25519GetIOWrapper

func AgeX25519GetIOWrapper(
	private domain_interfaces.MarklId,
) (ioWrapper interfaces.IOWrapper, err error)

func AgeX25519GetPublicKey

func AgeX25519GetPublicKey(
	private domain_interfaces.MarklId,
) (bites []byte, err error)

TODO verify if this is correct

func AssertEqual

func AssertEqual(expected, actual domain_interfaces.MarklId) (err error)

func AssertIdIsNotNull

func AssertIdIsNotNull(id domain_interfaces.MarklId) error

func AssertIdIsNotNullWithPurpose

func AssertIdIsNotNullWithPurpose(id domain_interfaces.MarklId, purpose string) error

func AssertIdIsNull

func AssertIdIsNull(id domain_interfaces.MarklId) error

func CompareToReader

func CompareToReader(
	reader io.Reader,
	expected domain_interfaces.MarklId,
) int

func CompareToReaderAt

func CompareToReaderAt(
	readerAt io.ReaderAt,
	offset int64,
	expected domain_interfaces.MarklId,
) int

func Ed25519GeneratePrivateKey

func Ed25519GeneratePrivateKey(rand io.Reader) (bites []byte, err error)

func Ed25519GetPublicKey

func Ed25519GetPublicKey(private domain_interfaces.MarklId) (bites []byte, err error)

func Ed25519Sign

func Ed25519Sign(
	sec domain_interfaces.MarklId,
	mes domain_interfaces.MarklId,
	readerRand io.Reader,
) (sigBites []byte, err error)

func Ed25519Verify

func Ed25519Verify(pub, message, sig domain_interfaces.MarklId) (err error)

func Equals

func Equals(a, b domain_interfaces.MarklId) (ok bool)

func EqualsReader

func EqualsReader(
	expectedBlobId domain_interfaces.MarklId,
	bufferedReader *bufio.Reader,
) (ok bool, err error)

func FormatBytesAsHex

func FormatBytesAsHex(merkleId domain_interfaces.MarklId) string

Creates a human-readable string representation of a digest. TODO add type information

func FormatOrEmptyOnNull

func FormatOrEmptyOnNull(merkleId domain_interfaces.MarklId) string

func GetDigestTypeForSigType

func GetDigestTypeForSigType(sigId string) string

func GetFormatOrError

func GetFormatOrError(formatId string) (domain_interfaces.MarklFormat, error)

func GetMotherSigTypeForSigType

func GetMotherSigTypeForSigType(sigId string) string

func IsErrNull

func IsErrNull(target error) bool

func IsNull

func IsNull(id domain_interfaces.MarklId) (ok bool)

func LockEquals

func LockEquals[
	KEY interfaces.Value,
	KEY_PTR interfaces.ValuePtr[KEY],
](left, right domain_interfaces.Lock[KEY, KEY_PTR]) bool

func MakeErrEmptyType

func MakeErrEmptyType(id domain_interfaces.MarklId) error

func MakeErrLength

func MakeErrLength[INTEGER constraints.Integer](
	expected, actual INTEGER,
) error

TODO add another "wrong hasher" error type

func MakeErrNotEqualBytes

func MakeErrNotEqualBytes(expected, actual []byte) (err error)

func MakeErrWrongType

func MakeErrWrongType(expected, actual string) error

func MakeIdCoderDoddish

func MakeIdCoderDoddish(id *Id) *idCoderDoddish

func MakeLockCoder

func MakeLockCoder[
	KEY interfaces.Value,
	KEY_PTR interfaces.ValuePtr[KEY],
](
	lock domain_interfaces.Lock[KEY, KEY_PTR],
	requireValue bool,
) lockBinaryMarshaler[KEY, KEY_PTR]

func MakeLockCoderValueNotRequired

func MakeLockCoderValueNotRequired[
	KEY interfaces.Value,
	KEY_PTR interfaces.ValuePtr[KEY],
](
	lock domain_interfaces.Lock[KEY, KEY_PTR],
) lockBinaryMarshaler[KEY, KEY_PTR]

func MakeMutableLockCoder

func MakeMutableLockCoder[
	KEY interfaces.Value,
	KEY_PTR interfaces.ValuePtr[KEY],
](
	lock domain_interfaces.LockMutable[KEY, KEY_PTR],
	requireValue bool,
) mutableLockBinaryMarshaler[KEY, KEY_PTR]

func MakeMutableLockCoderValueNotRequired

func MakeMutableLockCoderValueNotRequired[
	KEY interfaces.Value,
	KEY_PTR interfaces.ValuePtr[KEY],
](
	lock domain_interfaces.LockMutable[KEY, KEY_PTR],
) mutableLockBinaryMarshaler[KEY, KEY_PTR]

func MakeMutableLockCoderValueRequired

func MakeMutableLockCoderValueRequired[
	KEY interfaces.Value,
	KEY_PTR interfaces.ValuePtr[KEY],
](
	lock domain_interfaces.LockMutable[KEY, KEY_PTR],
) mutableLockBinaryMarshaler[KEY, KEY_PTR]

func NonceGenerate

func NonceGenerate(rand io.Reader, size int) (bites []byte, err error)

func NonceGenerate32

func NonceGenerate32(rand io.Reader) (bites []byte, err error)

func ReadFrom

func ReadFrom(
	reader io.Reader,
	id *Id,
	formatHash FormatHash,
) (n int, err error)

func SetDigester

func SetFromPath

func SetFromPath(id domain_interfaces.MarklIdMutable, path string) (err error)

func SetHexBytes

func SetHexBytes(
	formatId string,
	dst domain_interfaces.MarklIdMutable,
	bites []byte,
) (err error)

func SetHexStringFromAbsolutePath

func SetHexStringFromAbsolutePath(
	id domain_interfaces.MarklIdMutable,
	absOrRelPath string,
	base string,
) (err error)

func SetHexStringFromRelPath

func SetHexStringFromRelPath(
	id domain_interfaces.MarklIdMutable,
	relPath string,
) (err error)

func SetMarklIdWithFormatBlech32

func SetMarklIdWithFormatBlech32(
	id domain_interfaces.MarklIdMutable,
	purposeId string,
	blechValue string,
) (err error)

func SetMaybeSha256

func SetMaybeSha256(id domain_interfaces.MarklIdMutable, value string) (err error)

TODO remove

Types

type ErrFormatOperationNotSupported

type ErrFormatOperationNotSupported struct {
	Format        domain_interfaces.MarklFormat
	FormatId      string
	OperationName string
}

func (ErrFormatOperationNotSupported) Error

func (ErrFormatOperationNotSupported) GetErrorType

func (err ErrFormatOperationNotSupported) GetErrorType() pkgErrDisamb

func (ErrFormatOperationNotSupported) Is

func (err ErrFormatOperationNotSupported) Is(target error) bool

type ErrIsNull

type ErrIsNull struct {
	Purpose string
}

func (ErrIsNull) Error

func (err ErrIsNull) Error() string

func (ErrIsNull) GetErrorType

func (err ErrIsNull) GetErrorType() pkgErrDisamb

func (ErrIsNull) Is

func (err ErrIsNull) Is(target error) bool

type ErrNotEqual

type ErrNotEqual struct {
	Expected, Actual domain_interfaces.MarklId
}

func (ErrNotEqual) Error

func (err ErrNotEqual) Error() string

func (ErrNotEqual) GetErrorType

func (err ErrNotEqual) GetErrorType() pkgErrDisamb

func (ErrNotEqual) Is

func (err ErrNotEqual) Is(target error) bool

func (ErrNotEqual) IsDifferentHashTypes

func (err ErrNotEqual) IsDifferentHashTypes() bool

type ErrNotEqualBytes

type ErrNotEqualBytes struct {
	Expected, Actual []byte
}

func (ErrNotEqualBytes) Error

func (err ErrNotEqualBytes) Error() string

func (ErrNotEqualBytes) GetErrorType

func (err ErrNotEqualBytes) GetErrorType() pkgErrDisamb

func (ErrNotEqualBytes) Is

func (err ErrNotEqualBytes) Is(target error) bool

type Format

type Format struct {
	Id   string
	Size int
}

func (Format) GetMarklFormatId

func (format Format) GetMarklFormatId() string

func (Format) GetSize

func (format Format) GetSize() int

type FormatHash

type FormatHash struct {
	// contains filtered or unexported fields
}
var (

	// TODO remove unnecessary references
	FormatHashSha256     FormatHash
	FormatHashBlake2b256 FormatHash
)

func GetFormatHashOrError

func GetFormatHashOrError(
	formatHashId string,
) (formatHash FormatHash, err error)

func (FormatHash) FromStringContent

func (formatHash FormatHash) FromStringContent(
	input string,
) domain_interfaces.MarklId

func (*FormatHash) Get

func (formatHash *FormatHash) Get() (*Hash, interfaces.FuncRepool)

func (FormatHash) GetBlobId

func (FormatHash) GetBlobIdForHexString

func (formatHash FormatHash) GetBlobIdForHexString(
	input string,
) (domain_interfaces.MarklId, interfaces.FuncRepool)

func (FormatHash) GetHash

func (formatHash FormatHash) GetHash() (domain_interfaces.Hash, interfaces.FuncRepool)

func (FormatHash) GetMarklFormatId

func (formatHash FormatHash) GetMarklFormatId() string

func (FormatHash) GetMarklIdForMarklId

func (formatHash FormatHash) GetMarklIdForMarklId(
	input domain_interfaces.MarklId,
) (domain_interfaces.MarklId, interfaces.FuncRepool)

func (FormatHash) GetMarklIdForString

func (formatHash FormatHash) GetMarklIdForString(
	input string,
) (domain_interfaces.MarklId, interfaces.FuncRepool)

func (FormatHash) GetMarklIdFromStringFormat

func (formatHash FormatHash) GetMarklIdFromStringFormat(
	format string,
	args ...any,
) (domain_interfaces.MarklId, interfaces.FuncRepool)

func (FormatHash) GetSize

func (formatHash FormatHash) GetSize() int

type FormatId

type FormatId string

func (FormatId) GetMarklFormat

func (formatId FormatId) GetMarklFormat() domain_interfaces.MarklFormat

type FormatPub

type FormatPub struct {
	Id   string
	Size int

	Verify FuncFormatPubVerify
}

func (FormatPub) GetMarklFormatId

func (format FormatPub) GetMarklFormatId() string

func (FormatPub) GetSize

func (format FormatPub) GetSize() int

type FormatSec

type FormatSec struct {
	Id   string
	Size int

	Generate FuncFormatSecGenerate

	PubFormatId  string
	GetPublicKey FuncFormatSecGetPublicKey

	GetIOWrapper FuncFormatSecGetIOWrapper

	SigFormatId string
	Sign        FuncFormatSecSign
}

func GetFormatSecOrError

func GetFormatSecOrError(
	formatIdGetter domain_interfaces.MarklFormatGetter,
) (formatSec FormatSec, err error)

move to Id

func (FormatSec) GetMarklFormatId

func (format FormatSec) GetMarklFormatId() string

func (FormatSec) GetSize

func (format FormatSec) GetSize() int

type FuncFormatPubVerify

type FuncFormatPubVerify func(pubkey, message, sig domain_interfaces.MarklId) error

type FuncFormatSecGenerate

type FuncFormatSecGenerate func(io.Reader) ([]byte, error)

TODO switch to accepting bytes?

type FuncFormatSecGetIOWrapper

type FuncFormatSecGetIOWrapper func(private domain_interfaces.MarklId) (interfaces.IOWrapper, error)

type FuncFormatSecGetPublicKey

type FuncFormatSecGetPublicKey func(private domain_interfaces.MarklId) ([]byte, error)

type FuncFormatSecSign

type FuncFormatSecSign func(sec, mes domain_interfaces.MarklId, readerRand io.Reader) ([]byte, error)

type Hash

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

func (*Hash) BlockSize

func (hash *Hash) BlockSize() int

func (*Hash) GetBlobIdForReader

func (hash *Hash) GetBlobIdForReader(
	reader io.Reader,
) (domain_interfaces.MarklId, interfaces.FuncRepool)

func (*Hash) GetBlobIdForReaderAt

func (hash *Hash) GetBlobIdForReaderAt(
	reader io.ReaderAt,
	off int64,
) (domain_interfaces.MarklId, interfaces.FuncRepool)

func (*Hash) GetMarklFormat

func (hash *Hash) GetMarklFormat() domain_interfaces.MarklFormat

func (*Hash) GetMarklId

func (*Hash) Reset

func (hash *Hash) Reset()

func (*Hash) Size

func (hash *Hash) Size() int

func (*Hash) Sum

func (hash *Hash) Sum(bites []byte) []byte

func (*Hash) Write

func (hash *Hash) Write(bites []byte) (written int, err error)

type Id

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

func (*Id) GeneratePrivateKey

func (id *Id) GeneratePrivateKey(
	readerRand io.Reader,
	formatId string,
	purpose string,
) (err error)

func (*Id) GetBlobId

func (id *Id) GetBlobId() domain_interfaces.MarklId

func (Id) GetBytes

func (id Id) GetBytes() []byte

func (Id) GetIOWrapper

func (id Id) GetIOWrapper() (ioWrapper interfaces.IOWrapper, err error)

func (Id) GetMarklFormat

func (id Id) GetMarklFormat() domain_interfaces.MarklFormat

func (Id) GetPublicKey

func (id Id) GetPublicKey(
	purpose string,
) (public Id, err error)

func (Id) GetPurposeId

func (id Id) GetPurposeId() string

func (Id) GetSize

func (id Id) GetSize() int

func (Id) IsEmpty

func (id Id) IsEmpty() bool

func (Id) IsNull

func (id Id) IsNull() bool

func (Id) MarshalBinary

func (id Id) MarshalBinary() (bytes []byte, err error)

structure (in bytes): <256: type 1: empty byte <256: id

func (Id) MarshalText

func (id Id) MarshalText() (bites []byte, err error)

func (*Id) Reset

func (id *Id) Reset()

func (*Id) ResetWith

func (id *Id) ResetWith(src Id)

func (*Id) ResetWithMarklId

func (id *Id) ResetWithMarklId(src domain_interfaces.MarklId)

func (*Id) ResetWithOrDefaultPurpose

func (id *Id) ResetWithOrDefaultPurpose(src Id, purpose string)

func (*Id) ResetWithPurpose

func (id *Id) ResetWithPurpose(purpose string)

func (*Id) Set

func (id *Id) Set(value string) (err error)

func (*Id) SetDigest

func (id *Id) SetDigest(digest domain_interfaces.MarklId) (err error)

func (*Id) SetMarklId

func (id *Id) SetMarklId(formatId string, bites []byte) (err error)

func (*Id) SetPurposeId

func (id *Id) SetPurposeId(value string) error

func (Id) Sign

func (id Id) Sign(
	mes domain_interfaces.MarklId,
	sigDst domain_interfaces.MarklIdMutable,
	sigPurpose string,
) (err error)

func (Id) String

func (id Id) String() string

func (Id) StringWithFormat

func (id Id) StringWithFormat() string

func (*Id) UnmarshalBinary

func (id *Id) UnmarshalBinary(
	bites []byte,
) (err error)

func (*Id) UnmarshalText

func (id *Id) UnmarshalText(bites []byte) (err error)

func (Id) Verify

func (id Id) Verify(
	mes, sig domain_interfaces.MarklId,
) (err error)

type IdBinaryDecodingFormatTypeData

type IdBinaryDecodingFormatTypeData struct {
	domain_interfaces.MarklIdMutable
}

type IdBinaryDecodingTypeData

type IdBinaryDecodingTypeData struct {
	domain_interfaces.MarklIdMutable
}

func (IdBinaryDecodingTypeData) UnmarshalBinary

func (id IdBinaryDecodingTypeData) UnmarshalBinary(
	bites []byte,
) (err error)

type IdBinaryEncodingFormatTypeData

type IdBinaryEncodingFormatTypeData struct {
	domain_interfaces.MarklId
}

type IdBinaryEncodingTypeData

type IdBinaryEncodingTypeData struct {
	domain_interfaces.MarklId
}

func (IdBinaryEncodingTypeData) MarshalBinary

func (id IdBinaryEncodingTypeData) MarshalBinary() (bytes []byte, err error)

structure (in bytes): <256: type 1: empty byte <256: id

type IdBroken

type IdBroken Id

func (IdBroken) MarshalText

func (id IdBroken) MarshalText() (bites []byte, err error)

func (*IdBroken) UnmarshalText

func (id *IdBroken) UnmarshalText(bites []byte) (err error)

type Lock

type Lock[
	KEY interfaces.Value,
	KEY_PTR interfaces.ValuePtr[KEY],
] struct {
	Key   KEY
	Value Id
}

func MakeLock

func MakeLock[
	KEY interfaces.Value,
	KEY_PTR interfaces.ValuePtr[KEY],
]() Lock[KEY, KEY_PTR]

func MakeLockWith

func MakeLockWith[
	KEY interfaces.Value,
	KEY_PTR interfaces.ValuePtr[KEY],
](key KEY, value domain_interfaces.MarklId) Lock[KEY, KEY_PTR]

func (Lock[KEY, KEY_PTR]) Equals

func (tuple Lock[KEY, KEY_PTR]) Equals(
	other Lock[KEY, KEY_PTR],
) bool

func (Lock[KEY, KEY_PTR]) GetKey

func (tuple Lock[KEY, KEY_PTR]) GetKey() KEY

func (*Lock[KEY, KEY_PTR]) GetKeyMutable

func (tuple *Lock[KEY, KEY_PTR]) GetKeyMutable() KEY_PTR

func (Lock[KEY, KEY_PTR]) GetValue

func (tuple Lock[KEY, KEY_PTR]) GetValue() domain_interfaces.MarklId

func (*Lock[KEY, KEY_PTR]) GetValueMutable

func (tuple *Lock[KEY, KEY_PTR]) GetValueMutable() domain_interfaces.MarklIdMutable

func (Lock[KEY, KEY_PTR]) IsEmpty

func (tuple Lock[KEY, KEY_PTR]) IsEmpty() bool

func (*Lock[KEY, KEY_PTR]) Reset

func (tuple *Lock[KEY, KEY_PTR]) Reset()

func (*Lock[KEY, KEY_PTR]) ResetWith

func (tuple *Lock[KEY, KEY_PTR]) ResetWith(
	other Lock[KEY, KEY_PTR],
)

type Purpose

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

func GetPurpose

func GetPurpose(purposeId string) Purpose

func (Purpose) GetPurposeType

func (purpose Purpose) GetPurposeType() PurposeType

type PurposeType

type PurposeType interface {
	// contains filtered or unexported methods
}

type Slice

type Slice []Id

func (*Slice) ReadFrom

func (slice *Slice) ReadFrom(reader io.Reader) (n int64, err error)

Source Files

  • errors.go
  • format.go
  • format_family_agex25519.go
  • format_family_ed25519.go
  • format_family_nonce.go
  • format_hash.go
  • format_pub.go
  • format_sec.go
  • hash.go
  • id.go
  • id_blech_coding.go
  • id_coding_binary.go
  • id_coding_doddish.go
  • id_coding_seq.go
  • id_coding_text.go
  • id_coding_text_broken.go
  • id_crypto_pub.go
  • id_crypto_sec.go
  • lock.go
  • lock_marshaling.go
  • main.go
  • purpose_type.go
  • purposes.go
  • slice.go
  • util.go

Jump to

Keyboard shortcuts

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