Agent Mesh
Go a2aa2a-protocolagent-meshagentic-aiinferencemcpmeshmesh-networknetwork-securitynetworking-aip2p-network
optimize biscuit processing
Antonio Ojeadb25a53034fe
diff --git a/cmd/sam-node/node.go b/cmd/sam-node/node.goindex a95c4051..4b480e89 100644--- a/cmd/sam-node/node.go+++ b/cmd/sam-node/node.go@@ -575,6 +575,11 @@ func (n *SamNode) HandleAuthHandshake(s network.Stream) {}func (n *SamNode) verifyBiscuit(biscuitData []byte, remotePeer peer.ID) (*biscuit.Biscuit, error) {+ b, err := biscuit.Unmarshal(biscuitData)+ if err != nil {+ return nil, fmt.Errorf("malformed biscuit: %w", err)+ }+tokenHash := sha256.Sum256(biscuitData)hashStr := hex.EncodeToString(tokenHash[:]) + ":" + remotePeer.String()@@ -585,20 +590,11 @@ func (n *SamNode) verifyBiscuit(biscuitData []byte, remotePeer peer.ID) (*biscuifor _, tk := range keys {if hex.EncodeToString(tk.Key) == pubKeyStr {- b, err := biscuit.Unmarshal(biscuitData)- if err != nil {- return nil, fmt.Errorf("malformed biscuit on cache hit: %w", err)- }return b, nil}}}- b, err := biscuit.Unmarshal(biscuitData)- if err != nil {- return nil, fmt.Errorf("malformed biscuit: %w", err)- }-n.keysMu.RLock()keys := n.trustedKeysn.keysMu.RUnlock()