Documentation
¶
Overview ¶
Package harness provides shared test infrastructure for DIDComm interoperability testing.
Index ¶
- Constants
- func ExtractDIDFromKeyID(keyID string) string
- type KeyPair
- type MockDIDDocument
- type MockKeyStore
- type MockResolver
- func (r *MockResolver) AddDocument(doc *MockDIDDocument)
- func (r *MockResolver) AddKey(keyID string, key jwk.Key)
- func (r *MockResolver) GetAuthenticationKeys(ctx context.Context, did string) ([]jwk.Key, error)
- func (r *MockResolver) GetKeyAgreementKeys(ctx context.Context, did string) ([]jwk.Key, error)
- func (r *MockResolver) GetServiceEndpoint(ctx context.Context, did string) (string, error)
- func (r *MockResolver) Resolve(ctx context.Context, did string) (*MockDIDDocument, error)
- func (r *MockResolver) ResolveKey(ctx context.Context, keyID string) (jwk.Key, error)
- type MockService
- type MockVerificationMethod
- type TestKeys
- type WellKnownTestVectorKeys
Constants ¶
const ( AliceDID = "did:example:alice" BobDID = "did:example:bob" )
TestDIDs are the DIDs used in interop tests.
Variables ¶
This section is empty.
Functions ¶
func ExtractDIDFromKeyID ¶
ExtractDIDFromKeyID extracts the DID from a key ID (DID URL).
Types ¶
type KeyPair ¶
type KeyPair struct {
KID string
PrivateJWK jwk.Key
PublicJWK jwk.Key
PrivateRaw any
PublicRaw any
}
KeyPair holds a private/public key pair in JWK format.
type MockDIDDocument ¶
type MockDIDDocument struct {
ID string
KeyAgreement []MockVerificationMethod
Authentication []MockVerificationMethod
AssertionMethod []MockVerificationMethod
VerificationMethod []MockVerificationMethod
Service []MockService
}
MockDIDDocument represents a simplified DID Document for testing.
type MockKeyStore ¶
type MockKeyStore struct {
// contains filtered or unexported fields
}
MockKeyStore provides private key storage for tests.
func NewMockKeyStore ¶
func NewMockKeyStore() *MockKeyStore
NewMockKeyStore creates a new mock key store.
func NewMockKeyStoreFromTestKeys ¶
func NewMockKeyStoreFromTestKeys(keys *TestKeys, forDID string) *MockKeyStore
NewMockKeyStoreFromTestKeys creates a key store populated with test keys.
func NewMockKeyStoreFromWellKnownKeys ¶
func NewMockKeyStoreFromWellKnownKeys(forDID string) (*MockKeyStore, error)
NewMockKeyStoreFromWellKnownKeys creates a key store from the DIDComm spec keys.
func (*MockKeyStore) AddPrivateKey ¶
func (ks *MockKeyStore) AddPrivateKey(keyID string, key jwk.Key)
AddPrivateKey adds a private key to the store.
func (*MockKeyStore) GetPrivateKey ¶
func (ks *MockKeyStore) GetPrivateKey(keyID string) (jwk.Key, error)
GetPrivateKey retrieves a private key by ID.
func (*MockKeyStore) ListKeyIDs ¶
func (ks *MockKeyStore) ListKeyIDs() []string
ListKeyIDs returns all key IDs in the store.
type MockResolver ¶
type MockResolver struct {
// contains filtered or unexported fields
}
MockResolver provides DID resolution for interoperability tests. It holds pre-configured DID Documents with verification methods and key agreement keys.
func NewMockResolver ¶
func NewMockResolver(testKeys *TestKeys) (*MockResolver, error)
NewMockResolver creates a new mock resolver with the given test keys.
func NewMockResolverWithWellKnownKeys ¶
func NewMockResolverWithWellKnownKeys() (*MockResolver, error)
NewMockResolverWithWellKnownKeys creates a resolver using the DIDComm spec test vector keys.
func (*MockResolver) AddDocument ¶
func (r *MockResolver) AddDocument(doc *MockDIDDocument)
AddDocument adds a DID Document to the resolver.
func (*MockResolver) AddKey ¶
func (r *MockResolver) AddKey(keyID string, key jwk.Key)
AddKey adds a key to the resolver by key ID.
func (*MockResolver) GetAuthenticationKeys ¶
GetAuthenticationKeys returns all authentication keys for a DID.
func (*MockResolver) GetKeyAgreementKeys ¶
GetKeyAgreementKeys returns all key agreement keys for a DID.
func (*MockResolver) GetServiceEndpoint ¶
GetServiceEndpoint returns the DIDComm messaging service endpoint for a DID.
func (*MockResolver) Resolve ¶
func (r *MockResolver) Resolve(ctx context.Context, did string) (*MockDIDDocument, error)
Resolve resolves a DID to its DID Document.
func (*MockResolver) ResolveKey ¶
ResolveKey resolves a key ID (DID URL) to a JWK.
type MockService ¶
MockService represents a service endpoint in a DID Document.
type MockVerificationMethod ¶
MockVerificationMethod represents a verification method in a DID Document.
type TestKeys ¶
type TestKeys struct {
// Ed25519 signing keys
AliceEdSign *KeyPair
BobEdSign *KeyPair
// X25519 key agreement keys
AliceX25519 *KeyPair
BobX25519 *KeyPair
// P-256 keys (signing and key agreement)
AliceP256 *KeyPair
BobP256 *KeyPair
// P-384 keys (signing and key agreement)
AliceP384 *KeyPair
BobP384 *KeyPair
}
TestKeys holds all cryptographic key pairs for testing. These keys are deterministically generated from seed for reproducibility.
func NewTestKeys ¶
NewTestKeys generates a complete set of test keys for interoperability testing.
type WellKnownTestVectorKeys ¶
type WellKnownTestVectorKeys struct {
// Alice's keys from the spec
AliceKeyAgreementX25519 jwk.Key
AliceKeyAgreementP256 jwk.Key
AliceKeyAgreementP384 jwk.Key
AliceKeyAgreementP521 jwk.Key
AliceAuthKeyEd25519 jwk.Key
// Bob's keys from the spec
BobKeyAgreementX25519 jwk.Key
BobKeyAgreementP256 jwk.Key
BobKeyAgreementP384 jwk.Key
BobKeyAgreementP521 jwk.Key
}
WellKnownTestVectorKeys contains the DIDComm spec test vector keys. These are from Appendix C of the DIDComm v2.1 specification.
func LoadWellKnownKeys ¶
func LoadWellKnownKeys() (*WellKnownTestVectorKeys, error)
LoadWellKnownKeys loads the DIDComm spec test vector keys. These keys are from the official DIDComm test vectors.