ipld-eth-server/vendor/github.com/ipfs/go-ipns
2019-12-02 13:24:49 -06:00
..
pb update dependencies to work with update eth-block-extractor 2019-12-02 13:24:49 -06:00
.travis.yml update dependencies to work with update eth-block-extractor 2019-12-02 13:24:49 -06:00
codecov.yml update dependencies to work with update eth-block-extractor 2019-12-02 13:24:49 -06:00
errors.go update dependencies to work with update eth-block-extractor 2019-12-02 13:24:49 -06:00
go.mod update dependencies to work with update eth-block-extractor 2019-12-02 13:24:49 -06:00
go.sum update dependencies to work with update eth-block-extractor 2019-12-02 13:24:49 -06:00
ipns.go update dependencies to work with update eth-block-extractor 2019-12-02 13:24:49 -06:00
LICENSE update dependencies to work with update eth-block-extractor 2019-12-02 13:24:49 -06:00
Makefile update dependencies to work with update eth-block-extractor 2019-12-02 13:24:49 -06:00
package.json update dependencies to work with update eth-block-extractor 2019-12-02 13:24:49 -06:00
README.md update dependencies to work with update eth-block-extractor 2019-12-02 13:24:49 -06:00
record.go update dependencies to work with update eth-block-extractor 2019-12-02 13:24:49 -06:00

go-ipns

standard-readme compliant GoDoc

ipns record definitions

This package contains all of the components necessary to create, understand, and validate IPNS records. It does not publish or resolve those records. go-ipfs 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, youll 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

Contribute

Feel free to join in. All welcome. Open an issue!

This repository falls under the IPFS Code of Conduct.

Want to hack on IPFS?

License

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