Skip to content

Docs for the current/old version #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions legacy/ipv8-packet.md

This file was deleted.

File renamed without changes.
File renamed without changes.
70 changes: 70 additions & 0 deletions old/ipv8-packet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# IPv8 Packet

## Overview
| version number | master_peer.mid | msg_id | payloads | trailer |
|----------------|-----------------|--------------|------------|------------|
| 2 bytes | 40 Bytes | 1 byte | x bytes | x bytes |


### Version number
* 1: Dispersy
* 2: py-ipv8

### Master Peer Mid
SHA1 hash of the public key

### Message ID
A message ID which determines which community and of what type the message is.

Basically to determine to whom to pass the decoded packet.

### Payloads
The first


### Trailer
The trailer almost always consist of a signature signing the packet

# Deserializing a packet
1. Header
2. Verify
3. Rest

## Header
//TODO: Implement

## Verify (OpenSSL)
1. Get the Public key from the BinKey payload
2. Parse it into a proper key (add pem header/trailer and give to to openssl)
3. Find out its algorithm and curve
4. Use the algo/curve to determine the length of the signature
5. Extract the ECDSA signature to `r`,`s`
6. Parse `r`,`s` into an `EcdsaSig`
7. Verify the signature with the public key

## Verify (libnacl-ed25519)
1. Get the public key from the BinKey payload (detectable by the `libnacl` prefix)
2. Parse into ed25519 public key
3. extract the signature from the end (length is known)
4. Verify the signature with the key

## The rest
The rest is handled by the correct community

(No communities exist in our implmentation yet)


# Serializing a packet

## Header
//TODO: Implement

## Signing (OpenSSL)
1. Get the private key from the user.
2. Use the algorithm and corresponding curve of the key to calculate the signature (r,s) and needed padding.
3. Return a Signature

## Signing (libnacl-ed25519)
1. Use the users private key to generate a signature over the given packet.
2. Append the signature.

21 changes: 21 additions & 0 deletions old/tmp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Deserializing a packet

1. Header
2. Verify
3. Rest


## Header
The header consists of

## Verify
1. Get the Public key from the BinKey payload
2. Parse it into a proper key (add pem header/trailer and give to to openssl)
3. Find out its algorithm and curve
4. Use the algo/curve to determine the length of the signature
5. Extract the signature to `r`,`s`
6. Parse `r`,`s` into a `EcdsaSig`
7. Verify the signature with the public key

## The rest
The rest is handled by the correct community