vectors

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package vectors provides test vectors for DIDComm interoperability testing. This file contains official test vectors from the DIDComm v2.1 specification. See: https://identity.foundation/didcomm-messaging/spec/v2.1/

Package vectors provides test vector loading and validation for DIDComm interoperability tests.

Index

Constants

View Source
const SpecPlaintext = `` /* 322-byte string literal not displayed */

SpecPlaintext is the standard plaintext message from DIDComm spec test vectors.

Variables

This section is empty.

Functions

func AliceDIDDocument

func AliceDIDDocument() string

AliceDIDDocument returns Alice's DID document from the spec.

func BobDIDDocument

func BobDIDDocument() string

BobDIDDocument returns Bob's DID document from the spec.

func ParseSpecPlaintext

func ParseSpecPlaintext() (map[string]any, error)

ParseSpecPlaintext parses the spec plaintext into a map.

func ValidateTestVector

func ValidateTestVector(v *TestVector) error

ValidateTestVector validates that a test vector is well-formed.

Types

type AliceSpecKeys

type AliceSpecKeys struct {
	// Signing keys
	Ed25519Key1   string // key-1: Ed25519 signing key
	P256Key2      string // key-2: P-256 signing key
	Secp256k1Key3 string // key-3: secp256k1 signing key

	// Key agreement keys
	X25519Key1 string // key-x25519-1
	P256Key1   string // key-p256-1 for key agreement
	P521Key1   string // key-p521-1
}

AliceSpecKeys contains Alice's keys from the DIDComm v2.1 spec.

type BobSpecKeys

type BobSpecKeys struct {
	// X25519 keys
	X25519Key1 string // key-x25519-1
	X25519Key2 string // key-x25519-2
	X25519Key3 string // key-x25519-3

	// P-256 keys
	P256Key1 string // key-p256-1
	P256Key2 string // key-p256-2

	// P-384 keys
	P384Key1 string // key-p384-1
	P384Key2 string // key-p384-2

	// P-521 keys
	P521Key1 string // key-p521-1
	P521Key2 string // key-p521-2
}

BobSpecKeys contains Bob's keys from the DIDComm v2.1 spec.

type SpecKeyMaterial

type SpecKeyMaterial struct {
	AliceKeys *AliceSpecKeys
	BobKeys   *BobSpecKeys
}

SpecKeyMaterial contains the official DIDComm v2.1 spec key material. These are from Appendix A of the specification.

func GetSpecKeyMaterial

func GetSpecKeyMaterial() *SpecKeyMaterial

GetSpecKeyMaterial returns the official key material from DIDComm v2.1 spec Appendix A.

type SpecTestVector

type SpecTestVector struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	// Plaintext is the original message that was encrypted/signed
	Plaintext string `json:"plaintext"`
	// EncryptedMessage is the encrypted JWE (for encryption vectors)
	EncryptedMessage string `json:"encrypted_message,omitempty"`
	// SignedMessage is the signed JWS (for signing vectors)
	SignedMessage string `json:"signed_message,omitempty"`
	// Algorithm information
	KeyAgreementAlgorithm string `json:"key_agreement_algorithm,omitempty"`
	ContentEncryption     string `json:"content_encryption,omitempty"`
	SigningAlgorithm      string `json:"signing_algorithm,omitempty"`
	// Key identifiers
	SenderKeyID    string `json:"sender_key_id,omitempty"`
	RecipientKeyID string `json:"recipient_key_id,omitempty"`
	// Whether this is authcrypt (authenticated) or anoncrypt (anonymous)
	IsAuthcrypt bool `json:"is_authcrypt"`
}

SpecTestVector represents an official test vector from the DIDComm v2.1 specification.

func GetSpecEncryptedVectors

func GetSpecEncryptedVectors() []SpecTestVector

GetSpecEncryptedVectors returns the official encrypted message test vectors from DIDComm v2.1 spec Appendix C.3.

func GetSpecSignedVectors

func GetSpecSignedVectors() []SpecTestVector

GetSpecSignedVectors returns the official signed message test vectors from DIDComm v2.1 spec Appendix C.2.

type TestVector

type TestVector struct {
	// Metadata
	Name        string `json:"name"`
	Description string `json:"description"`
	Category    string `json:"category"` // "encryption", "signing", "message", "protocol"

	// Input
	Plaintext      json.RawMessage `json:"plaintext,omitempty"`
	PlaintextData  []byte          `json:"-"` // Parsed plaintext
	SenderDID      string          `json:"sender_did,omitempty"`
	RecipientDID   string          `json:"recipient_did,omitempty"`
	RecipientKeyID string          `json:"recipient_key_id,omitempty"`
	SenderKeyID    string          `json:"sender_key_id,omitempty"`

	// Expected output (for validation)
	ExpectedJWE     string          `json:"expected_jwe,omitempty"`
	ExpectedJWS     string          `json:"expected_jws,omitempty"`
	ExpectedMessage json.RawMessage `json:"expected_message,omitempty"`

	// Cryptographic parameters
	Algorithm   string `json:"algorithm,omitempty"`   // e.g., "ECDH-ES+A256KW"
	Encryption  string `json:"encryption,omitempty"`  // e.g., "A256GCM"
	KeyCurve    string `json:"key_curve,omitempty"`   // e.g., "X25519", "P-256"
	SigningAlg  string `json:"signing_alg,omitempty"` // e.g., "EdDSA", "ES256"
	ContentType string `json:"content_type,omitempty"`

	// Flags
	IsAnoncrypt    bool   `json:"is_anoncrypt,omitempty"`
	IsAuthcrypt    bool   `json:"is_authcrypt,omitempty"`
	IsSigned       bool   `json:"is_signed,omitempty"`
	ExpectError    bool   `json:"expect_error,omitempty"`
	ExpectedErrMsg string `json:"expected_error,omitempty"`
}

TestVector represents a single DIDComm test vector.

func GetTestVector

func GetTestVector(name string) (*TestVector, error)

GetTestVector finds a test vector by name across all suites.

func GetTestVectorsByCategory

func GetTestVectorsByCategory(category string) []*TestVector

GetTestVectorsByCategory returns all test vectors in a category.

type TestVectorSuite

type TestVectorSuite struct {
	Name        string        `json:"name"`
	Description string        `json:"description"`
	Vectors     []*TestVector `json:"vectors"`
}

TestVectorSuite is a collection of related test vectors.

func AllTestVectors

func AllTestVectors() []*TestVectorSuite

AllTestVectors returns all test vector suites.

func EncryptionTestVectors

func EncryptionTestVectors() *TestVectorSuite

EncryptionTestVectors returns test vectors for encryption operations.

func ErrorTestVectors

func ErrorTestVectors() *TestVectorSuite

ErrorTestVectors returns test vectors that should produce errors.

func MessageTestVectors

func MessageTestVectors() *TestVectorSuite

MessageTestVectors returns test vectors for message format validation.

func RoundTripTestVectors

func RoundTripTestVectors() *TestVectorSuite

RoundTripTestVectors returns test vectors for encrypt/decrypt and sign/verify round trips.

func SigningTestVectors

func SigningTestVectors() *TestVectorSuite

SigningTestVectors returns test vectors for signing operations.

Jump to

Keyboard shortcuts

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