Skip to content

Commit 1cfd076

Browse files
committed
fix: Get-SharedEntropy accepts files >= 32 bytes, uses first 32 only
The USPTO Python MCPs write 328 bytes to ~/.uspto_internal_auth_secret. The previous check required exactly 32 bytes and was wrongly recreating the file (destroying shared entropy for all other MCPs). Now accepts any file >= 32 bytes and returns only the first 32 bytes as the entropy seed, matching the Pinecone TypeScript simpleSecureStorage.ts behavior.
1 parent 761a22c commit 1cfd076

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

deploy/manage_api_keys.ps1

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,16 @@ $ProjectDir = Split-Path -Parent $ScriptDir
5050
function Get-SharedEntropy {
5151
if (Test-Path $SHARED_ENTROPY_PATH) {
5252
$bytes = [System.IO.File]::ReadAllBytes($SHARED_ENTROPY_PATH)
53-
if ($bytes.Length -eq $SHARED_ENTROPY_BYTES) {
53+
if ($bytes.Length -ge $SHARED_ENTROPY_BYTES) {
54+
# File may be larger than 32 bytes (USPTO Python format) - use only first 32 bytes as entropy
55+
if ($bytes.Length -gt $SHARED_ENTROPY_BYTES) {
56+
$seed = New-Object byte[] $SHARED_ENTROPY_BYTES
57+
[System.Array]::Copy($bytes, $seed, $SHARED_ENTROPY_BYTES)
58+
return $seed
59+
}
5460
return $bytes
5561
}
56-
Write-Host "[WARN] Entropy file has unexpected size ($($bytes.Length) bytes) - recreating" -ForegroundColor Yellow
62+
Write-Host "[WARN] Entropy file too small ($($bytes.Length) bytes, need $SHARED_ENTROPY_BYTES) - recreating" -ForegroundColor Yellow
5763
}
5864

5965
# Create new entropy file

0 commit comments

Comments
 (0)