-
Notifications
You must be signed in to change notification settings - Fork 120
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
ipfs: add support to pull images by ref #1968
base: main
Are you sure you want to change the base?
Conversation
20d3c42
to
bfee105
Compare
cmd/go.mod
Outdated
@@ -49,6 +49,7 @@ require ( | |||
github.com/containernetworking/plugins v1.5.1 // indirect | |||
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect | |||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect | |||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect |
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.
Can we remove this dependency on "Decred" cryptocurrency to avoid potential confusion?
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.
This might be a bit difficult. 'Decred' is introduced by the following two packages:
github.com/libp2p/go-libp2p/core/crypto
github.com/libp2p/go-libp2p/core/peer
These two packages are used to compute the public key and peer ID in IPFS.
The Kubo project also introduces 'Decred':
https://github.com/ipfs/kubo/blob/master/go.mod#L119
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.
Can we just exec the ipfs command for computing them?
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.
Actually we got a compliant about a dependency on a bitcoin-originated library in the past, although it was not for mining nor trading bitcoin
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.
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.
Let me think. Do you mean that in ipnskey.go's (g *DetKeyGen) generateKey(name string)
, after we obtain the seed bytes for the deterministic keys through reader.Read(seedBytes)
, we execute the IPFS
command using an OS command (for example, exec.Command) to calculate the public key and peer ID?
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.
Oh, actually, there's no need to use the IPFS command; we can just use the API. We can import the private key into IPFS and then use the list API to obtain the public key ID and peer ID. I'll update the PR.
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.
done
6b511ab
to
3545af1
Compare
cmd/go.mod
Outdated
@@ -49,6 +49,7 @@ require ( | |||
github.com/containernetworking/plugins v1.5.1 // indirect | |||
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect | |||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect | |||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect |
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.
This should be removed.
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.
done
Refer to: #1968 (comment)
ipfs/ipnskey/ipnskey.go
Outdated
|
||
// KeyStore manages a collection of DetKeyGen instances | ||
type KeyStore struct { | ||
store map[string]*DetKeyGen |
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.
Is this tolerant to restart?
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.
KeyStore has been removed now
ipfs/client/client.go
Outdated
if err := json.NewDecoder(resp.Body).Decode(&rs); err != nil { | ||
return "", err | ||
} | ||
|
||
parts := strings.Split(rs.Path, "/") | ||
if len(parts) < 3 || parts[1] != "ipfs" { | ||
return "", fmt.Errorf("invalid resolved path format: %s", rs.Path) | ||
} | ||
|
||
return parts[2], nil |
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.
needs docs
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.
done, add doc to docs/ipfs.md
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.
can you add a comment of link to ipfs api docs?
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.
done
ipfs/ipnskey/ipnskey.go
Outdated
package ipnskey | ||
|
||
import ( | ||
"bytes" | ||
"crypto/ed25519" | ||
"crypto/sha256" | ||
"crypto/x509" | ||
"encoding/pem" | ||
"fmt" | ||
"sync" | ||
|
||
"github.com/libp2p/go-libp2p/core/crypto" | ||
"github.com/libp2p/go-libp2p/core/peer" |
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.
This shouldn't be imported to stargz snapshotter but should be done in ipfs daemon.
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.
done
Refer to: #1968 (comment)
b7a87c0
to
6c36913
Compare
@AkihiroSuda @ktock
|
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.
Can you add integration tests?
cmd/go.mod
Outdated
github.com/ipfs/go-cid v0.1.0 // indirect | ||
github.com/ipfs/go-cid v0.4.1 // indirect |
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.
why?
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.
no need update to v0.4.1
done
ipfs/client/client.go
Outdated
if err := json.NewDecoder(resp.Body).Decode(&rs); err != nil { | ||
return "", err | ||
} | ||
|
||
parts := strings.Split(rs.Path, "/") | ||
if len(parts) < 3 || parts[1] != "ipfs" { | ||
return "", fmt.Errorf("invalid resolved path format: %s", rs.Path) | ||
} | ||
|
||
return parts[2], nil |
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.
can you add a comment of link to ipfs api docs?
limitations under the License. | ||
*/ | ||
|
||
package ipnskey |
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.
needs explanation comments and link to docs
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.
done
1eb20d7
to
a015bb6
Compare
Hi, @ktock
|
client = http.DefaultClient | ||
} | ||
|
||
ipfsAPINamePublish := c.Address + "/api/v0/name/publish" |
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.
Can we have docs about lifetime and republishing of contents?
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.
limitations under the License. | ||
*/ | ||
|
||
// Package ipnskey provides functionality for generating deterministic Ed25519 key pairs |
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.
Can't we use the gen
API for this? https://docs.ipfs.tech/reference/kubo/rpc/#api-v0-key-gen
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.
@wswsmao can you check this ^
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.
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.
So this sounds like all users on the IPFS network can get the private key of an image ref and update and sign the image. How can a user verify the image is updated by a trusted one, just like the default IPNS settings?
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.
When using IPFS, we have configured a IPFS private network by default, where the nodes within this private network are considered trusted. Additionally, nodes outside of the private network, even if they obtain the private key, will not be able to publish or resolve image files.
Signed-off-by: abushwang <[email protected]>
all review done @ktock |
The solution for issue #1944 has been finalized, with the main design concepts outlined as follows:
IPNS
IPNS provides the
ipfs name publish
andipfs name resolve
commands, which allow for associating a file with an IPNS name, enabling publishing and retrieval.For IPFS images, we can consider publishing the root descriptor file, allowing other nodes to resolve this file to pull the image. IPNS requires key management to control the publishing and resolution of IPNS names, with each key corresponding to a unique IPNS name.
This characteristic is well-suited for associating with image references, ultimately establishing the following relationship:
Image ref -> Key -> Root Descriptor -> Image File
Deterministic Keys
Different nodes will share the same deterministic key algorithm to ensure that each node receives the same key for the same image name. This allows every node to pull and push images. Specifically:
Additional Notes
This submission is compatible with the existing method. During the push / pull phase, the input will be checked to determine if it is a ref. If users still prefer to use CID, this method will remain valid.
Feature Demonstration
On Node A:
On other nodes:
Other nodes can also rebuild
docker.io/abushwang/oc9-busybox:org
, and then run:At this point, Node A can pull the updated image: