Skip to content

[Task] Implement utilities for AgentCard signing #141

@yarolegovich

Description

@yarolegovich

Implement utilities for AgentCard signatures.
Signatures are described in the spec and this Python PR can serve as a reference.

  1. Create a new package a2acrypto.
  2. Make it export a verfifier.
type KeyResolver interface {
  ResolveKey(kid, jku string) (crypto.PublicKey, error)
}

type VerifierConfig struct {
  KeyResolver KeyResolver
}

func NewVerifier(config VerifierConfig) *Verifier { ... }

func (v *Verifier) Verify(card *a2a.AgentCard, signature *a2a.AgentCardSignature) error { ... }
  1. Make it export a signer.
type SignerConfig struct {
  PrivateKey crypto.Signer
  KeyID string
  Algorithm string
  JWKSURL string
}

func NewSigner(config SignerConfig) *Signer { ... }

func (s *Signer) Sign(card *a2a.AgentCard) (*a2a.AgentCardSignature, error) { ... }
  1. Make a2aclient.Client be configurable with a2aclient.WithCardVerifier(*a2acrypto.Verifier). If set, the verifier should run when GetAgentCard() is called.
  2. Make agentcard.Resolver have an *a2acrypto.Verifier field. If set, the verifier should be used in Resolve().
  3. Use the signer to implement an a2asrv.NewSignedCardProducer for wrapping a user-provided AgentCardProducer.
type signedAgentCardProducer struct {
  wrapped AgentCardProducer
  signer  *a2asrv.Signer
}

func (p *signedAgentCardProducer) Card(ctx context.Context) (*a2a.AgentCard, error) { ... }

func NewSignedCardProducer(*a2acrypto.Signer, AgentCardProducer) AgentCardProducer { ... }

Add tests to verify the implementation. Can use Python or other SDK to generate an expected signature to compare against.

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions