From 2e14c51ce78b6437a6cd3cc7cc1e21c9af9b9088 Mon Sep 17 00:00:00 2001 From: Victor Date: Fri, 24 May 2019 15:49:39 +0200 Subject: [PATCH 1/2] Added how to verify the signature --- old/ipv8-packet.md | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 old/ipv8-packet.md diff --git a/old/ipv8-packet.md b/old/ipv8-packet.md new file mode 100644 index 0000000..bdb84a5 --- /dev/null +++ b/old/ipv8-packet.md @@ -0,0 +1,57 @@ +# 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 +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 + +(No communities exist yet) + + +# Serializing a packet + +## Header +//TODO: Implement + +## Signing + From 09907e6a77ea41859ee82190cfc749e59fa59faa Mon Sep 17 00:00:00 2001 From: Victor Date: Fri, 24 May 2019 18:47:57 +0200 Subject: [PATCH 2/2] old docs beginnings --- legacy/ipv8-packet.md | 17 ----------------- {src => new}/SUMMARY.md | 0 {src => new}/introduction.md | 0 old/ipv8-packet.md | 23 ++++++++++++++++++----- old/tmp.md | 21 +++++++++++++++++++++ 5 files changed, 39 insertions(+), 22 deletions(-) delete mode 100644 legacy/ipv8-packet.md rename {src => new}/SUMMARY.md (100%) rename {src => new}/introduction.md (100%) create mode 100644 old/tmp.md diff --git a/legacy/ipv8-packet.md b/legacy/ipv8-packet.md deleted file mode 100644 index dbc0bfc..0000000 --- a/legacy/ipv8-packet.md +++ /dev/null @@ -1,17 +0,0 @@ -# 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 - -### Payloads -Various Payloads diff --git a/src/SUMMARY.md b/new/SUMMARY.md similarity index 100% rename from src/SUMMARY.md rename to new/SUMMARY.md diff --git a/src/introduction.md b/new/introduction.md similarity index 100% rename from src/introduction.md rename to new/introduction.md diff --git a/old/ipv8-packet.md b/old/ipv8-packet.md index bdb84a5..ffd0cd8 100644 --- a/old/ipv8-packet.md +++ b/old/ipv8-packet.md @@ -33,19 +33,25 @@ The trailer almost always consist of a signature signing the packet ## Header //TODO: Implement -## Verify +## 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 signature to `r`,`s` -6. Parse `r`,`s` into a `EcdsaSig` +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 yet) +(No communities exist in our implmentation yet) # Serializing a packet @@ -53,5 +59,12 @@ The rest is handled by the correct community ## Header //TODO: Implement -## Signing +## 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. diff --git a/old/tmp.md b/old/tmp.md new file mode 100644 index 0000000..60869c5 --- /dev/null +++ b/old/tmp.md @@ -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