Skip to content

Commit

Permalink
add basic validation
Browse files Browse the repository at this point in the history
  • Loading branch information
shrimalmadhur committed Jan 14, 2025
1 parent 929f01f commit 9fb3b76
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion internal/services/signing/signing.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ func (s *Service) SignG1(
pubKeyHex := common.Trim0x(req.GetPublicKeyG1())
password := req.GetPassword()

if pubKeyHex == "" {
return nil, status.Error(codes.InvalidArgument, "public key is required")
}

g1Bytes := req.GetData()
if len(g1Bytes) == 0 {
return nil, status.Error(codes.InvalidArgument, "data must be > 0 bytes")
}

if _, ok := s.keyCache[pubKeyHex]; !ok {
s.logger.Info(fmt.Sprintf("In memory cache miss. Retrieving key for %s", pubKeyHex))
blsKey, err := s.store.RetrieveKey(ctx, pubKeyHex, password)
Expand All @@ -94,7 +103,6 @@ func (s *Service) SignG1(
}
blsKey := s.keyCache[pubKeyHex]

g1Bytes := req.GetData()
g1Point := new(crypto.G1Point)
g1Point = g1Point.Deserialize(g1Bytes)

Expand Down

0 comments on commit 9fb3b76

Please sign in to comment.