Categorygithub.com/ipfs/go-ipns
modulepackage
0.3.1
Repository: https://github.com/ipfs/go-ipns.git
Documentation: pkg.go.dev

# README

go-ipns

ipns record definitions

standard-readme compliant GoDoc

❗ This repo is no longer maintained.

👉 We highly recommend switching to the maintained version at https://github.com/ipfs/boxo/tree/main/ipns. 🏎️ Good news! There is tooling and documentation to expedite a switch in your repo.

⚠️ If you continue using this repo, please note that security fixes will not be provided (unless someone steps in to maintain it).

📚 Learn more, including how to take the maintainership mantle or ask questions, here.

This package contains all of the components necessary to create, understand, and validate IPNS records. It does not publish or resolve those records. Kubo uses this package internally to manipulate records.

Usage

To create a new IPNS record:

import (
	"time"

	ipns "github.com/ipfs/go-ipns"
	crypto "github.com/libp2p/go-libp2p-crypto"
)

// Generate a private key to sign the IPNS record with. Most of the time, 
// however, you'll want to retrieve an already-existing key from IPFS using the
// go-ipfs/core/coreapi CoreAPI.KeyAPI() interface.
privateKey, publicKey, err := crypto.GenerateKeyPair(crypto.RSA, 2048)
if err != nil {
  panic(err)
}

// Create an IPNS record that expires in one hour and points to the IPFS address
// /ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5
ipnsRecord, err := ipns.Create(privateKey, []byte("/ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5"), 0, time.Now().Add(1*time.Hour))
if err != nil {
	panic(err)
}

Once you have the record, you’ll need to use IPFS to publish it.

There are several other major operations you can do with go-ipns. Check out the API docs or look at the tests in this repo for examples.

Documentation

https://godoc.org/github.com/ipfs/go-ipns

Want to hack on IPFS?

License

Copyright (c) Protocol Labs, Inc. under the MIT license. See LICENSE file for details.

# Packages

No description provided by the author
No description provided by the author

# Functions

Compare compares two IPNS entries.
Create creates a new IPNS entry and signs it with the given private key.
EmbedPublicKey embeds the given public key in the given ipns entry.
ExtractPublicKey extracts a public key matching `pid` from the IPNS record, if possible.
GetEOL returns the EOL of this IPNS entry This function returns ErrUnrecognizedValidity if the validity type of the record isn't EOL.
RecordKey returns the libp2p record key for a given peer ID.
Validates validates the given IPNS entry against the given public key.

# Constants

10 KiB limit defined in https://github.com/ipfs/specs/pull/319 Deprecated: use github.com/ipfs/boxo/ipns.MaxRecordSize.

# Variables

ErrBadRecord should be returned when an ipns record cannot be unmarshalled Deprecated: use github.com/ipfs/boxo/ipns.ErrBadRecord.
ErrExpiredRecord should be returned when an ipns record is invalid due to being too old Deprecated: use github.com/ipfs/boxo/ipns.ErrExpiredRecord.
ErrInvalidPath should be returned when an ipns record path is not in a valid format Deprecated: use github.com/ipfs/boxo/ipns.ErrInvalidPath.
ErrKeyFormat should be returned when an ipns record key is incorrectly formatted (not a peer ID) Deprecated: use github.com/ipfs/boxo/ipns.ErrKeyFormat.
ErrPublicKeyMismatch should be returned when the public key embedded in the record doesn't match the expected public key.
ErrPublicKeyNotFound should be returned when the public key corresponding to the ipns record path cannot be retrieved from the peer store Deprecated: use github.com/ipfs/boxo/ipns.ErrPublicKeyNotFound.
ErrRecordSize should be returned when an ipns record is invalid due to being too big Deprecated: use github.com/ipfs/boxo/ipns.ErrRecordSize.
ErrSignature should be returned when an ipns record fails signature verification Deprecated: use github.com/ipfs/boxo/ipns.ErrSignature.
ErrUnrecognizedValidity is returned when an IpnsRecord has an unknown validity type.

# Structs

Validator is an IPNS record validator that satisfies the libp2p record validator interface.