Documentation
¶
Index ¶
- Constants
- Variables
- func AddPublicKeys(key1Bytes, key2Bytes []byte) ([]byte, error)
- func HashToField(hash, hashLen int, dst, message []byte, count int) error
- func IsCryptoError(err error) bool
- func IsKeyError(err error) bool
- func IsValidationError(err error) bool
- func MapDeriveKeyError(code CErrorCode) error
- func MapECPError(code CErrorCode) error
- func MapHashToFieldError(code CErrorCode) error
- func MapSecretKeyError(code CErrorCode) error
- func ValidateBufferSize(buffer []byte, requiredSize int, bufferName string) error
- func ValidateInputSize(data []byte, maxSize int, dataName string) error
- func ValidateKeyLength(keyBytes []byte, expectedLength int, keyName string) error
- func ValidateNonEmpty(data []byte, dataName string) error
- func WrapError(err error, context string) error
- type CErrorCode
- type KeyMaterial
Constants ¶
const ( // KeySize NIST P-256 key size in bytes KeySize = 32 // UncompressedPublicKeySize (1 byte prefix + 32 bytes X + 32 bytes Y) UncompressedPublicKeySize = 65 )
Variables ¶
var ( // General errors ErrInvalidParameters = errors.New("invalid parameters provided") ErrInternalError = errors.New("internal library error") ErrMemoryAllocation = errors.New("memory allocation failed") // Key generation errors ErrKeyGeneration = errors.New("failed to generate cryptographic key") ErrInsufficientEntropy = errors.New("insufficient entropy for key generation") ErrKeyMaterialExtraction = errors.New("failed to extract key material") // Key validation errors ErrInvalidKey = errors.New("invalid cryptographic key") ErrInvalidKeyLength = errors.New("invalid key length") ErrInvalidKeyFormat = errors.New("invalid key format") ErrKeyNotOnCurve = errors.New("public key point is not on the curve") ErrKeyAtInfinity = errors.New("key point is at infinity (invalid)") ErrZeroScalar = errors.New("private key scalar is zero (invalid)") ErrKeyOutOfRange = errors.New("private key is not in valid range") // Cryptographic operation errors ErrPointAddition = errors.New("elliptic curve point addition failed") ErrScalarAddition = errors.New("scalar addition failed") ErrResultConversion = errors.New("failed to convert operation result") ErrInsufficientBuffer = errors.New("result buffer is too small") // Hash-to-field errors ErrHashToField = errors.New("hash-to-field operation failed") ErrExpandMessage = errors.New("message expansion failed") ErrExpansionTooLarge = errors.New("expansion length exceeds buffer limits") // Key derivation errors ErrKeyDerivation = errors.New("key derivation failed") ErrInputTooLarge = errors.New("input data too large") ErrContextTooLarge = errors.New("context data too large") ErrDSTTooLarge = errors.New("domain separation tag too large") // JWK and encoding errors ErrJWKCreation = errors.New("failed to create JWK") ErrJWKExtraction = errors.New("failed to extract key from JWK") ErrKeyTypeUnsupported = errors.New("unsupported key type") ErrCurveUnsupported = errors.New("unsupported elliptic curve") // Workflow errors (F0, F1 functions) ErrEmptyEmailMap = errors.New("email map cannot be empty") ErrEmptyEmail = errors.New("email cannot be empty") ErrEmptyUUID = errors.New("uuid cannot be empty") ErrUserNotFound = errors.New("user data not found") ErrMasterKeyNotSet = errors.New("master key not available") ErrSaltGeneration = errors.New("failed to generate salt") ErrPayloadModification = errors.New("failed to modify VC payload") )
Base error types for different categories of operations
Functions ¶
func AddPublicKeys ¶
AddPublicKeys adds two NIST P-256 public keys using elliptic curve point addition
func HashToField ¶
HashToField performs hash-to-field operation for the given input
func IsCryptoError ¶
IsCryptoError checks if an error is related to cryptographic operations
func IsKeyError ¶
IsKeyError checks if an error is related to key operations
func IsValidationError ¶
IsValidationError checks if an error is related to input validation
func MapDeriveKeyError ¶
func MapDeriveKeyError(code CErrorCode) error
MapDeriveKeyError maps C key derivation error codes to Go errors
func MapECPError ¶
func MapECPError(code CErrorCode) error
MapECPError maps C ECP (elliptic curve point) operation error codes to Go errors
func MapHashToFieldError ¶
func MapHashToFieldError(code CErrorCode) error
MapHashToFieldError maps C hash-to-field operation error codes to Go errors
func MapSecretKeyError ¶
func MapSecretKeyError(code CErrorCode) error
MapSecretKeyError maps C secret key addition error codes to Go errors
func ValidateBufferSize ¶
ValidateBufferSize validates that a buffer has sufficient capacity
func ValidateInputSize ¶
ValidateInputSize validates input size against maximum allowed
func ValidateKeyLength ¶
ValidateKeyLength validates that a key byte slice has the expected length
func ValidateNonEmpty ¶
ValidateNonEmpty validates that data is not empty
Types ¶
type KeyMaterial ¶
type KeyMaterial struct {
PrivateKeyBytes [KeySize]byte
PublicKeyXBytes [KeySize]byte
PublicKeyYBytes [KeySize]byte
}
KeyMaterial represents extracted cryptographic key material
func AddSecretKeys ¶
func AddSecretKeys(key1Bytes, key2Bytes []byte) (KeyMaterial, error)
AddSecretKeys adds two NIST P-256 private keys using scalar addition modulo curve order
func DeriveSecretKey ¶
func DeriveSecretKey(masterKeyBytes, context, dst []byte) (KeyMaterial, error)
DeriveSecretKey derives a secret key from master key material using hash-to-field
func GenerateSecretKey ¶
func GenerateSecretKey(seed []byte) (KeyMaterial, error)
GenerateSecretKey generates an NIST P-256 private key using cryptographically secure random data
func (KeyMaterial) GetKeyMaterialBytes ¶
func (km KeyMaterial) GetKeyMaterialBytes() (privateKey, publicKeyX, publicKeyY []byte)
GetKeyMaterialBytes returns the key material as separate byte slices
func (KeyMaterial) IsValid ¶
func (km KeyMaterial) IsValid() bool
IsValid checks if the key material appears to be valid