Files
CHORUS/vendor/github.com/libp2p/go-libp2p-record/pubkey.go
anthonyrawlins 9bdcbe0447 Integrate BACKBEAT SDK and resolve KACHING license validation
Major integrations and fixes:
- Added BACKBEAT SDK integration for P2P operation timing
- Implemented beat-aware status tracking for distributed operations
- Added Docker secrets support for secure license management
- Resolved KACHING license validation via HTTPS/TLS
- Updated docker-compose configuration for clean stack deployment
- Disabled rollback policies to prevent deployment failures
- Added license credential storage (CHORUS-DEV-MULTI-001)

Technical improvements:
- BACKBEAT P2P operation tracking with phase management
- Enhanced configuration system with file-based secrets
- Improved error handling for license validation
- Clean separation of KACHING and CHORUS deployment stacks

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-06 07:56:26 +10:00

56 lines
1.3 KiB
Go

package record
import (
"bytes"
"errors"
"fmt"
"github.com/libp2p/go-libp2p/core/crypto"
"github.com/libp2p/go-libp2p/core/peer"
mh "github.com/multiformats/go-multihash"
)
// PublicKeyValidator is a Validator that validates public keys.
type PublicKeyValidator struct{}
// Validate conforms to the Validator interface.
//
// It verifies that the passed in record value is the PublicKey that matches the
// passed in key.
func (pkv PublicKeyValidator) Validate(key string, value []byte) error {
ns, key, err := SplitKey(key)
if err != nil {
return err
}
if ns != "pk" {
return errors.New("namespace not 'pk'")
}
keyhash := []byte(key)
if _, err := mh.Cast(keyhash); err != nil {
return fmt.Errorf("key did not contain valid multihash: %s", err)
}
pk, err := crypto.UnmarshalPublicKey(value)
if err != nil {
return err
}
id, err := peer.IDFromPublicKey(pk)
if err != nil {
return err
}
if !bytes.Equal(keyhash, []byte(id)) {
return errors.New("public key does not match storage key")
}
return nil
}
// Select conforms to the Validator interface.
//
// It always returns 0 as all public keys are equivalently valid.
func (pkv PublicKeyValidator) Select(k string, vals [][]byte) (int, error) {
return 0, nil
}
var _ Validator = PublicKeyValidator{}