{% extends "_layout.html" %} {% block title %}Common structure Specification{% endblock %} {% block content %}

Data types Specification

This document describes some data types common to all I2P-protocols, like I2NP, I2CP, NTCP, etc.

Integer

Description

Represents a nonnegative integer.

Contents

1 or more bytes in network byte order representing an unsigned integer

Date

Description

The number of milliseconds since midnight on January 1, 1970 in the GMT timezone. If the number is 0, the date is undefined or null.

Contents

8 byte Integer

String

Description

Represents a UTF-8 encoded string.

Contents

1 or more bytes where the first byte is the number of bytes(not characters!) in the string and the remaining 0-255 bytes are the non-null terminated UTF-8 encoded character array

Boolean

Description

A boolean value, supporting null/unknown representation 0=false, 1=true, 2=unknown/null

Contents

1 byte Integer

PublicKey

Description

This structure is used in ElGamal encryption, representing only the exponent, not the primes, which are constant and defined in the appropiate spec.

Contents

256 byte Integer

Javadoc

PrivateKey

Description

This structure is used in ElGama decryption, representing only the exponent, not the primes which are constant and defined in the appropiate spec.

Contents

256 byte Integer

Javadoc

SessionKey

Description

This structure is used for AES256 encryption and decryption.

Contents

32 byte Integer

Javadoc

SigningPublicKey

Description

This structure is used for verifying DSA signatures.

Contents

128 byte Integer

Javadoc

SigningPrivateKey

Description

This structure is used for creating DSA signatures.

Contents

20 byte Integer

Javadoc

Signature

Description

This structure represents the DSA signature of some data.

Contents

40 byte Integer

Javadoc

Hash

Description

Represents the SHA256 of some data.

Contents

32 bytes

Javadoc

TunnelId

Description

Defines an identifier that is unique within a particular set of routers for a tunnel.

Contents

4 byte Integer

Javadoc

Certificate

Description

A certificate is a container for various receipts or proof of works used throughout the I2P network.

Contents

1 byte Integer specifying certificate type, followed by a 2 Integer specifying the size of the certificate payload, then that many bytes.

{% filter escape %}
+----+----+----+----+----+--//
|type| length  | payload
+----+----+----+----+----+--//

type :: Integer
        length -> 1 byte

        case 0 -> NULL
        case 1 -> HASHCASH
        case 2 -> HIDDEN
        case 3 -> SIGNED
        case 4 -> MULTIPLE

length :: Integer
          length -> 2 bytes

payload :: data
           length -> $length bytes
{% endfilter %}

Javadoc

Common structure specification

RouterIdentity

Description

Defines the way to uniquely identify a particular router

Contents

PublicKey followed by SigningPublicKey and then a Certificate entangled with the PublicKey

{% filter escape %}
+----+----+----+----+----+----+----+----+
| public_key                            |
+                                       +
|                                       |
~                                       ~

~                                       ~
|                                       |
+----+----+----+----+----+----+----+----+
| signing_key                           |
+                                       +
|                                       |
~                                       ~

~                                       ~
|                                       |
+----+----+----+----+----+----+----+----+
| certificate                           |
+----+----+----+--//

public_key :: PublicKey
              length -> 256 bytes

signing_key :: SigningPublicKey
               length -> 128 bytes

certificate :: Certificate
               length -> >= 3 bytes

{% endfilter %}

Javadoc

Destination

Description

A Destination defines a particular endpoint to which messages can be directed for secure delivery.

Contents

PublicKey followed by a SigningPublicKey and then a Certificate entangled with the PublicKey.

{% filter escape %}
+----+----+----+----+----+----+----+----+
| public_key                            |
+                                       +
|                                       |
~                                       ~

~                                       ~
|                                       |
+----+----+----+----+----+----+----+----+
| signing_public_key                    |
+                                       +
|                                       |
~                                       ~

~                                       ~
|                                       |
+----+----+----+----+----+----+----+----+
| certificate                           
+---//

public_key :: PublicKey
              length -> 256 bytes

signing_public_key :: SigningPublicKey
                      length -> 128 bytes

certificate :: Certificate
               length -> >= 3 bytes
{% endfilter %}

Javadoc

Lease

Description

Defines the authorization for a particular tunnel to receive messages targeting a Destination.

Contents

RouterIdentity of the gateway router, then the TunnelId, and then a start Date and finally an end Date

{% filter escape %}
+----+----+----+----+----+----+----+----+
| tunnel_gw                             |
+                                       +
|                                       |
~                                       ~

~                                       ~
|                                       |
+                   +----+----+----+----+
|                   | tunnel_id         |
+----+----+----+----+----+----+----+----+
| start_date                            |
+----+----+----+----+----+----+----+----+
| end_date                              |
+----+----+----+----+----+----+----+----+

tunnel_gw :: RouterIdentity
             length -> >= 387 bytes

tunnel_id :: TunnelId
             length -> 4 bytes

start_date :: Date
              length -> 8 bytes

end_date :: Date
            length -> 8 bytes
{% endfilter %}

Javadoc

LeaseSet

Description

Contains all of the currently authorized Leases for a particular Destination, the PublicKey to which garlic messages can be encrypted, and then the the public key that can be used to revoke this particular version of the structure. The LeaseSet is one of the two structures stored in the network database( the other being RouterInfo), and is keyed under the SHA256 of the contained Destination.

Contents

Destination, followed by a PublicKey for encryption, then a SigningPublicKey which can be used to revoke this version of the LeaseSet, then a 1 byte Integer specifying how many Lease structures are in the set, followed by the actual Lease structures and finally a Signature of the previous bytes signed by the Destination's SigningPrivateKey

{% filter escape %}
+----+----+----+----+----+----+----+----+
| destination                           |
+                                       +
|                                       |
~                                       ~

~                                       ~
|                                       |
+----+----+----+----+----+----+----+----+
| encryption_key                        |
+                                       +
|                                       |
~                                       ~

~                                       ~
|                                       |
+----+----+----+----+----+----+----+----+
| signing_key                           |
+                                       +
|                                       |
~                                       ~

~                                       ~
|                                       |
+----+----+----+----+----+----+----+----+
|num | Lease 0                          |
+----+                                  +
|                                       |
~                                       ~

~                                       ~
|                                       |
+----+----+----+----+----+----+----+----+
| Lease 1                               |
+                                       +
|                                       |
~                                       ~

~                                       ~
~                                       ~

~                                       ~
|                                       |
+----+----+----+----+----+----+----+----+
| Lease ($num-1)                        |
+                                       +
|                                       |
~                                       ~

~                                       ~
|                                       |
+----+----+----+----+----+----+----+----+
| signature                             |
+                                       +
|                                       |
+                                       +
|                                       |
+                                       +
|                                       |
+                                       +
|                                       |
+----+----+----+----+----+----+----+----+

destination :: Destination
               length -> >= 397 bytes

encryption_key :: PublicKey
                  length -> 256 bytes

signing_key :: SigningPublicKey
               length -> 128 bytes

num :: Integer
       length -> 1 byte

leases :: [Lease]
          length -> >= $num*407 bytes

signature :: Signature
             length -> 40 bytes

{% endfilter %}

Javadoc

RouterAddress

Description

This structure defines the means to contact a router through a transport protocol.

Contents

1 byte Integer defining the relative cost of using the address, where 0 is free and 255 is expensive, followed by the expiration Date after which the address should not be used, or if null, the address never expires. After that comes a String defining the transport protocol this router address uses. Finally there is a Mapping containing all of the transport specific options necessary to establish the connection, such as IP address, port number, email address, URL, etc.

{% filter escape %}
+----+
|cost|
+----+----+----+----+----+----+----+----+
| expiration                            |
+----+----+----+----+--//+----+----+----+
| transport_style                       |
+----+----+----+----+--//+----+----+----+
| options                               |
+----+----+----+----+--//+----+----+----+

cost :: Integer
        length -> 1 byte

        case 0 -> free
        case 255 -> expensive

expiration :: Date
              length -> 8 bytes

              case null -> never expires

transport_style :: String
                   length -> 1-256 bytes

options :: Mapping
{% endfilter %}

Javadoc

RouterInfo

Description

Defines all of the data that a router wants to publish for the network to see. The RouterInfo is one of two structures stored in the network database(the other being LeaseSet, and is keyed under the SHA256 of the contained RouterIdentity.

Contents

RouterIdentity followed by the Date, when the entry was published

{% filter escape %}
+----+----+----+----+----+----+----+----+
| router_ident                          |
+                                       +
|                                       |
~                                       ~

~                                       ~
|                                       |
+----+----+----+----+----+----+----+----+
| published                             |
+----+----+----+----+----+----+----+----+
|size| RouterAddress 0                  |
+----+                                  +
|                                       |
~                                       ~

~                                       ~
|                                       |
+----+----+----+----+----+----+----+----+
| RouterAddress 1                       |
+                                       +
|                                       |
~                                       ~
~                                       ~

~                                       ~
~                                       ~
|                                       |
+----+----+----+----+----+----+----+----+
| RouterAddress ($size-1)               |
+                                       +
|                                       |
~                                       ~

~                                       ~
|                                       |
+----+----+----+----+-//-+----+----+----+
|psiz| options                          |
+----+----+----+----+-//-+----+----+----+

router_ident :: RouterIdentity
                length -> >= 387 bytes

published :: Date
             length -> 8 bytes

size :: Integer
        length -> 1 byte

addresses :: [RouterAddress]
             length -> >= $size*267 bytes

peer_size :: Integer
             length -> 1 byte

             value -> 0

options :: Mapping
{% endfilter %}

Javadoc

{% endblock %}