Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
27 lines (23 sloc)
767 Bytes
This file contains 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
| package examples | |
| import ( | |
| "time" | |
| pb "github.com/ipfs/go-ipns/pb" | |
| ipns "github.com/ipfs/go-ipns" | |
| crypto "github.com/libp2p/go-libp2p-core/crypto" | |
| ) | |
| // CreateEntryWithEmbed shows how you can create an IPNS entry | |
| // and embed it with a public key. For ed25519 keys this is not needed | |
| // so attempting to embed with an ed25519 key, will not actually embed the key | |
| func CreateEntryWithEmbed(ipfsPath string, publicKey crypto.PubKey, privateKey crypto.PrivKey) (*pb.IpnsEntry, error) { | |
| ipfsPathByte := []byte(ipfsPath) | |
| eol := time.Now().Add(time.Hour * 48) | |
| entry, err := ipns.Create(privateKey, ipfsPathByte, 1, eol, 0) | |
| if err != nil { | |
| return nil, err | |
| } | |
| err = ipns.EmbedPublicKey(publicKey, entry) | |
| if err != nil { | |
| return nil, err | |
| } | |
| return entry, nil | |
| } |