MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / DeriveClaimCode

Function DeriveClaimCode

internal/server/claim_codes.go:78–81  ·  view source on GitHub ↗

DeriveClaimCode produces the 6-digit code for the given (user, workspace) at the given wall-clock time. Exported so the Phase E "Connect project" modal handler can render the same code the claim path will verify. secret must be at least 16 bytes of cryptographically-strong material — production wir

(secret []byte, userID, workspaceID string, at time.Time)

Source from the content-addressed store, hash-verified

76// Returns "000000"–"999999" zero-padded so the wire format is uniform
77// (avoids an agent stripping leading zeros when echoing the code back).
78func DeriveClaimCode(secret []byte, userID, workspaceID string, at time.Time) string {
79 bucket := at.UTC().Unix() / claimBucketSeconds
80 return deriveClaimCodeForBucket(secret, userID, workspaceID, bucket)
81}
82
83// deriveClaimCodeForBucket is the inner derive — split out so
84// VerifyClaimCode can derive both the current and previous bucket

Calls 1

deriveClaimCodeForBucketFunction · 0.85