Skip to content

Namespace description #36

@jbenet

Description

@jbenet

@whyrusleeping here's a rough spec of ipns / the namespace:

  • Make an NSResolver interface.
type NSResolver interface {
  Resolve(name string) (string, error)
}
  • Implement DNS, proquint NSResolvers (which @Bren2010 started).
  • Implement a RoutingResolver (the meat of IPNS) which does:
// RoutingName is the de-serialized name structure that is stored (serialized) 
// in the routing system. Basically, a hash + a digital signature. (serialization can be
// protobuf, or a simple binary format)
type RoutingName {
  Hash        u.Key
  Signature []byte
}

// RoutingResolver implements NSResolver for the main IPFS SFS-like naming
type RoutingResolver {
  routing routing.IpfsRouting
  dag      mdag.DAGService
}

func (r *RoutingResolver) Resolve (name string) (string, error) {

  // name should be a multihash. if it isn't, error out here.

  // use the routing system to get the name.
  // /ipns/<name>
  key := u.Key(name) // or whatever
  val, err := r.routing.Get(key)
  if err != nil {
    return "", err
  }

  // name should be a public key retrievable from ipfs
  // /ipfs/<name>
  node, err :=  r.dag.Get(key)
  if err != nil {
    return "", err
  }

  // get PublicKey from node.Data
  pk := PublicKey(node.Data)

  // check sig with pk
  if !pk.Verify(val.Hash, val.Signature) {
    return "", errors.New("Invalid value. Not signed by PrivateKey corresponding to %v", pk)
  }

  // ok sig checks out. this is a valid name.
  return string(val.Hash)
}
  • implement NameService or NameSystem object:
// NameSystem is the object implementing IPNS. It adheres to the `NSResolver` 
// interface, and uses child `NSResolvers`, depending on what the name looks like.
// 
// hashes -> routing, domains -> dns, proquints -> proquint
// we can add `.bit` and `.onion` resolution here in the future
// 
// in non-routing cases, the values returned are hashes to lookup in the routing system.
// (most of the time, if not ALL of the time. still deciding on this). meaning that 
// a dns record: `DNS TXT ipns=<some-hash>` needs to then resolve `<some-hash>`
// via the routing system.
type NameSystem struct {
  routing   RoutingResolver
  dns        DNSResovler
  proquint ProquintResolver
}
  • add mounting of /ipns to ipfs mount cmd (maybe have options for each i.e. -n, --ipns and -f, --ipfs to toggle each on/off)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions