-
Notifications
You must be signed in to change notification settings - Fork 1
FEE wrap material on blob_encryption_params (FIL-480) #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e054d52
feat(registry,migrations): FEE wrap material on blob_locations (FIL-480)
claude 3f445a1
refactor: Tighten up migration comment
Peeja 9c91922
fix(registry): enforce all-or-nothing FEE invariant in PutLocation (F…
claude 3db7e44
style(inmem): gofmt test map alignment (FIL-480)
claude b3b1e3a
Merge branch 'main' into claude/fil-480-cipgkz
bajtos b864480
feat(registry): store FEE params in their own table
bajtos 893e930
feat(registry): add a dedicated re-wrap method
bajtos f83f9c0
Merge branch 'main' into claude/fil-480-cipgkz
bajtos d666f5f
stop storing RegionWrappedCEK and RegionKeyVersion in DB
bajtos bf5de99
Merge branch 'main' into claude/fil-480-cipgkz
bajtos f08520e
refactor(registry): trim FEE params to the read path
bajtos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| /Users/bajtos/src/fil-forge/ingot/.claude | ||
|
bajtos marked this conversation as resolved.
Outdated
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,18 +11,19 @@ import ( | |
| ) | ||
|
|
||
| // In-memory implementations of the architecture's relational stores | ||
| // (registry.BlobRefStore / IntentStore / LocationStore / MultipartStore / | ||
| // GCStore), mirroring the Postgres tables so the in-process suite and | ||
| // standalone mode exercise the same write/read/delete code paths. | ||
| // (registry.BlobRefStore / IntentStore / LocationStore / EncryptionParamsStore / | ||
| // MultipartStore / GCStore), mirroring the Postgres tables so the in-process | ||
| // suite and standalone mode exercise the same write/read/delete code paths. | ||
|
|
||
| // Compile-time assertions: *MemStore satisfies every store interface. | ||
| var ( | ||
| _ registry.BlobRefStore = (*MemStore)(nil) | ||
| _ registry.IntentStore = (*MemStore)(nil) | ||
| _ registry.LocationStore = (*MemStore)(nil) | ||
| _ registry.InclusionStore = (*MemStore)(nil) | ||
| _ registry.MultipartStore = (*MemStore)(nil) | ||
| _ registry.GCStore = (*MemStore)(nil) | ||
| _ registry.BlobRefStore = (*MemStore)(nil) | ||
| _ registry.IntentStore = (*MemStore)(nil) | ||
| _ registry.LocationStore = (*MemStore)(nil) | ||
| _ registry.EncryptionParamsStore = (*MemStore)(nil) | ||
| _ registry.InclusionStore = (*MemStore)(nil) | ||
| _ registry.MultipartStore = (*MemStore)(nil) | ||
| _ registry.GCStore = (*MemStore)(nil) | ||
| ) | ||
|
|
||
| func cloneBytes(b []byte) []byte { | ||
|
|
@@ -125,9 +126,7 @@ func (m *MemStore) DeleteIntent(_ context.Context, digest []byte) error { | |
| func (m *MemStore) PutLocation(_ context.Context, loc registry.BlobLocation) error { | ||
| m.mu.Lock() | ||
| defer m.mu.Unlock() | ||
| cp := loc | ||
| cp.Digest = cloneBytes(loc.Digest) | ||
| m.locations[locKey{loc.Space, string(loc.Digest)}] = cp | ||
| m.locations[locKey{loc.Space, string(loc.Digest)}] = cloneLocation(loc) | ||
| return nil | ||
| } | ||
|
|
||
|
|
@@ -138,8 +137,7 @@ func (m *MemStore) GetLocation(_ context.Context, space did.DID, digest []byte) | |
| if !ok { | ||
| return nil, registry.ErrNotFound | ||
| } | ||
| cp := loc | ||
| cp.Digest = cloneBytes(loc.Digest) | ||
| cp := cloneLocation(loc) | ||
| return &cp, nil | ||
| } | ||
|
|
||
|
|
@@ -150,6 +148,54 @@ func (m *MemStore) DeleteLocation(_ context.Context, space did.DID, digest []byt | |
| return nil | ||
| } | ||
|
|
||
| // EncryptionParamsStore ====================================================== | ||
|
|
||
| func (m *MemStore) PutEncryptionParams(_ context.Context, params registry.BlobEncryptionParams) error { | ||
| // Match the Postgres store, whose columns are all NOT NULL. | ||
| if err := params.Validate(); err != nil { | ||
| return err | ||
| } | ||
| m.mu.Lock() | ||
| defer m.mu.Unlock() | ||
| m.encParams[locKey{params.Space, string(params.Digest)}] = cloneEncryptionParams(params) | ||
| return nil | ||
| } | ||
|
|
||
| func (m *MemStore) GetEncryptionParams(_ context.Context, space did.DID, digest []byte) (*registry.BlobEncryptionParams, error) { | ||
| m.mu.Lock() | ||
| defer m.mu.Unlock() | ||
| params, ok := m.encParams[locKey{space, string(digest)}] | ||
| if !ok { | ||
| return nil, registry.ErrNotFound | ||
| } | ||
| cp := cloneEncryptionParams(params) | ||
| return &cp, nil | ||
| } | ||
|
|
||
| func (m *MemStore) RewrapEncryptionParams(_ context.Context, space did.DID, digest, wrappedCEK []byte, keyVersion string) error { | ||
| if err := registry.ValidateRewrap(wrappedCEK, keyVersion); err != nil { | ||
| return err | ||
| } | ||
| m.mu.Lock() | ||
| defer m.mu.Unlock() | ||
| key := locKey{space, string(digest)} | ||
| params, ok := m.encParams[key] | ||
| if !ok { | ||
| return registry.ErrNotFound | ||
| } | ||
| params.RegionWrappedCEK = cloneBytes(wrappedCEK) | ||
| params.RegionKeyVersion = keyVersion | ||
| m.encParams[key] = params | ||
| return nil | ||
| } | ||
|
|
||
| func (m *MemStore) DeleteEncryptionParams(_ context.Context, space did.DID, digest []byte) error { | ||
| m.mu.Lock() | ||
| defer m.mu.Unlock() | ||
| delete(m.encParams, locKey{space, string(digest)}) | ||
| return nil | ||
| } | ||
|
|
||
| // ParkStore ================================================================== | ||
|
|
||
| func (m *MemStore) PutPark(_ context.Context, p registry.BlobPark) error { | ||
|
|
@@ -386,6 +432,24 @@ func cloneSession(s registry.MultipartSession) registry.MultipartSession { | |
| return s | ||
| } | ||
|
|
||
| // cloneLocation deep-copies a BlobLocation's digest so the stored copy and any | ||
| // returned copy never alias the caller's slice. | ||
| func cloneLocation(loc registry.BlobLocation) registry.BlobLocation { | ||
| loc.Digest = cloneBytes(loc.Digest) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just use
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Written by Claude. Done, and removed the local |
||
| return loc | ||
| } | ||
|
|
||
| // cloneEncryptionParams deep-copies a BlobEncryptionParams' byte-slice fields — | ||
| // the digest and the key material — so the stored copy and any returned copy | ||
| // never alias the caller's slices. | ||
| func cloneEncryptionParams(p registry.BlobEncryptionParams) registry.BlobEncryptionParams { | ||
| p.Digest = cloneBytes(p.Digest) | ||
| p.RegionWrappedCEK = cloneBytes(p.RegionWrappedCEK) | ||
| p.BaseNonce = cloneBytes(p.BaseNonce) | ||
| p.AAD = cloneBytes(p.AAD) | ||
| return p | ||
| } | ||
|
|
||
| func clonePart(p registry.MultipartPart) registry.MultipartPart { | ||
| p.ETagMD5 = cloneBytes(p.ETagMD5) | ||
| if p.BlobDigests != nil { | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Written by Claude.
Removed. It is a symlink my worktree setup creates, committed by accident. I left it out of
.gitignoreon purpose so the repo can still check in a shared.claude/config later.