Skip to content

Commit 53e9120

Browse files
committed
Add back error handling
1 parent ed781b1 commit 53e9120

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

auth/certificates/certificate.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,17 +264,18 @@ func (c *Certificate) Verify(ctx context.Context) error {
264264
return fmt.Errorf("failed to create verifier wallet: %w", err)
265265
}
266266

267-
signature, err := ec.ParseSignature(c.Signature)
268-
if err != nil {
269-
return fmt.Errorf("failed to parse signature: %w", err)
270-
}
271-
272267
// Get the binary representation without the signature
273268
data, err := c.ToBinary(false)
274269
if err != nil {
275270
return fmt.Errorf("failed to serialize certificate: %w", err)
276271
}
277272

273+
// Parse the signature
274+
signature, err := ec.ParseSignature(c.Signature)
275+
if err != nil {
276+
return fmt.Errorf("failed to parse signature: %w", err)
277+
}
278+
278279
// Verify the signature using the certifier's public key
279280
verifyArgs := wallet.VerifySignatureArgs{
280281
EncryptionArgs: wallet.EncryptionArgs{

auth/peer.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ func (p *Peer) initiateHandshake(ctx context.Context, peerIdentityKey *ec.Public
308308

309309
// Get our identity key to include in the initial request
310310
pubKey, err := p.wallet.GetPublicKey(ctx, wallet.GetPublicKeyArgs{
311-
IdentityKey: true,
311+
IdentityKey: true,
312312
EncryptionArgs: wallet.EncryptionArgs{
313313
// No specific protocol or key ID needed for identity key
314314
},
@@ -595,6 +595,7 @@ func (p *Peer) handleCertificateRequest(ctx context.Context, message *AuthMessag
595595
return fmt.Errorf("failed to serialize certificate request data: %w", err)
596596
}
597597

598+
// Try to parse the signature
598599
signature, err := ec.ParseSignature(message.Signature)
599600
if err != nil {
600601
return fmt.Errorf("failed to parse signature: %w", err)
@@ -676,9 +677,10 @@ func (p *Peer) handleCertificateResponse(ctx context.Context, message *AuthMessa
676677
return fmt.Errorf("failed to serialize certificate data: %w", err)
677678
}
678679

680+
// Try to parse the signature
679681
signature, err := ec.ParseSignature(message.Signature)
680682
if err != nil {
681-
return nil
683+
return fmt.Errorf("failed to parse signature: %w", err)
682684
}
683685

684686
// Verify signature
@@ -772,9 +774,10 @@ func (p *Peer) handleGeneralMessage(ctx context.Context, message *AuthMessage, s
772774
session.LastUpdate = time.Now().UnixMilli()
773775
p.sessionManager.UpdateSession(session)
774776

777+
// Try to parse the signature
775778
signature, err := ec.ParseSignature(message.Signature)
776779
if err != nil {
777-
return nil
780+
return fmt.Errorf("failed to parse signature: %w", err)
778781
}
779782

780783
// Verify signature

0 commit comments

Comments
 (0)