Documentation ¶
Overview ¶
Package derivation provides the derivation logic for KERI
Derivaitons are data blobs that have been hashed or encrypted using a pre-defined set of algorithms. These data blobs are used to as the foundation of a variety functionality (for example prefixes) within KERI. Derivaitons are typically represented as Base64 encoded strings with a specific 1, 2 or 4 character prefix, making them self describing. This packages provides an accessible way to encode/decode the data bytes to a given KERI defined derivaiton.
Index ¶
- Variables
- func Base64ToIndex(index string) (uint16, error)
- func IndexToBase64(index uint16) (string, error)
- func ParseSignatureCount(count string) (uint16, error)
- func VerifyWithAttachedSignature(key, signature *Derivation, msg []byte) error
- type Code
- func (c Code) AttachedSignature() bool
- func (c Code) Basic() bool
- func (c Code) DataLength() int
- func (c Code) Default() string
- func (c Code) Length() int
- func (c Code) Name() string
- func (c Code) PrefixBase64Length() int
- func (c Code) PrefixDataLength() int
- func (c Code) SelfAddressing() bool
- func (c Code) SelfSigning() bool
- func (c Code) String() string
- type CountCode
- type CountOpt
- type Counter
- type Derivation
- type DerivationOption
- type Ordinal
- type Signer
Constants ¶
This section is empty.
Variables ¶
var ( CountCodes = map[string]CountCode{ "-A": ControllerSigCountCode, "-B": WitnessSigCountCode, "-C": NonTransferableRctCountCode, "-D": TransferableRctCountCode, "-E": FirstSeenReplayCountCode, "-U": MessageDataGroupCountCode, "-V": AttachedMaterialCountCode, "-W": MessageDataMaterialCountCode, "-X": CombinedMaterialCountCode, "-Y": MaterialGroupCountCode, "-Z": MaterialCountCode, } )
Functions ¶
func Base64ToIndex ¶
Base64ToIndex converts a 2 character base64 index string into an int Currently it only supports index strings up to 2 characters long
func IndexToBase64 ¶
IndexToBase64 takes the provided index int and converts it to the correct 2 character base64 representation Currently the index has to be less than 4095, which is the max encdoed value for a two character base64 representation
func ParseSignatureCount ¶
ParseSignatureCount takes a well formated 4 character signature derivation code and returns the decoded count
func VerifyWithAttachedSignature ¶
func VerifyWithAttachedSignature(key, signature *Derivation, msg []byte) error
VerifyWithAttachedSignature takes the key and signature derivations and verifies the provided message bytes using the correct sig alg.
Types ¶
type Code ¶
type Code int
const ( Ed25519Seed Code = iota Ed25519NT X25519 Ed25519 Blake3256 Blake2b256 Blake2s256 SHA3256 SHA2256 RandomSeed128 Ed25519Sig EcDSASig Blake3512 SHA3512 Blake2b512 SHA2512 Ed25519Attached EcDSAAttached )
Code constants represent the available hashing and encryptions algorithms for the derivations.
func (Code) Default ¶
Default derivation data: used for calculating total data length in some KERI functions
func (Code) PrefixBase64Length ¶
PrefixBase64Lenghth of the derived data after it has been bsae64 encoded and the appropriate code has be prepended
func (Code) PrefixDataLength ¶
PrefixDataLength of the data with the code prepended
type CountCode ¶
type CountCode int
const ( ControllerSigCountCode CountCode = iota WitnessSigCountCode NonTransferableRctCountCode TransferableRctCountCode FirstSeenReplayCountCode MessageDataGroupCountCode AttachedMaterialCountCode MessageDataMaterialCountCode CombinedMaterialCountCode MaterialGroupCountCode MaterialCountCode SigCountLen = 2 )
type Derivation ¶
type Derivation struct { Code Code // The code for this derivation Raw []byte // The Raw derived data KeyIndex uint16 // For Attached Signature Derivation - the index of the key for the signature // contains filtered or unexported fields }
Derivation
func FromAttachedSignature ¶
func FromAttachedSignature(sig string) (*Derivation, error)
FromAttachedSignature parses an attached signature and returns the appropriate type. These derivation codes are similar to prefix derivation codes (i.e. they start with similar letters) but are handled differently in the context of an attached signature (namely they are two letter derivation codes but do not start with a "0" like the prefix derivation codes do)
func FromPrefix ¶
func FromPrefix(data string) (*Derivation, error)
FromPrefix takes a prefix as input and returns the appropriate drivation and raw (base64 unencoded) data represented by the prefix.
func New ¶
func New(options ...DerivationOption) (*Derivation, error)
New returns a derivation of the provided Code
func ParseAttachedSignatures ¶
func ParseAttachedSignatures(buf io.Reader) ([]Derivation, error)
ParseAttachedSignatures takes an attached signatures string and parses into individual derivations. This will return any unused bytes that remain after parsing the the number of signatures indicated in the sig count. It will error if there are not enough bytes for the number of signatures, or if any individual signature is not sucessfully parsed.
func ParsePrefix ¶
func ParsePrefix(buf io.Reader) (*Derivation, error)
ParsePrefix takes a prefix as input and returns the appropriate drivation and raw (base64 unencoded) data represented by the prefix.
func (*Derivation) AsPrefix ¶
func (d *Derivation) AsPrefix() string
AsPrefix returns the derivation's raw data as a base 64 encoded string with the correct derivation code prepended
type DerivationOption ¶
type DerivationOption func(*Derivation) error
DerivationOption is a genric configuration function for derivations
func WithCode ¶
func WithCode(code Code) DerivationOption
WithCode allows you to provide a derviation code for the derivation
func WithRaw ¶
func WithRaw(data []byte) DerivationOption
WithRaw allows you to provide raw derivation data
func WithSigner ¶
func WithSigner(signer Signer) DerivationOption
WithSigner uses the provided signing function to do the derivation
type Signer ¶
Signer function for signing self-signing derivations KERI does not want to access any private key data directly. This function can take the provided input bytes, sign it using the appropriate key and return the signed data. The Signer function has the same signature as, and will be used in place of, the deriver