BlockchainCommons / BlockchainCommons/did-method-onion

propose did-onion also for local verifications

Open
#10 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
6
Forks
3
PR merge metrics
No merged PRs in 30d

Description

## Type

Discussion
## Abstract

This issue documents how to extract Ed25519 public key from an onion address which could be used for local verification.

A Tor onion service requires an `Ed25519` keypair to operate. In fact, Tor v3 onion address is essentially an `Ed25519` public key. This property allows us to use `did:onion` (e.g. concatenated with #allow_local_verification or without any id) as a `verification method` that does not require Tor or Internet. Alternatively, we can convert `did:onion` to `did:key`.

## Introduction

Onion v3 address is 62 characters long (`fscst5exmlmr262byztwz4kzhggjlzumvc2ndvgytzoucr2tkgxf7mid.onion`) and is
defined as

```bash
onion_address = base32(Ed25519_pubkey | CHECKSUM | VERSION) + ".onion"
CHECKSUM = sha3_256(".onion checksum" | Ed25519_pubkey | VERSION)[:2]
```

where | represents byte concatenation, + string concatenation, version is 3
and the checksum is the first two bytes `[:2]` of the `sha3_256` digest.

So, to extract the `Ed25519_pubkey` we decode the first 56 characters of the onion address according to `base32` with `RFC4648
alphabet` and `no padding`. `Ed25519_pubkey` is represented by the first 32 bytes which can be converted into `JWK` or any other format.

## Example of a Key Conversion

Decoding `fscst5exmlmr262byztwz4kzhggjlzumvc2ndvgytzoucr2tkgxf7mid.onion` into `Ed25519` public key results in

```bash
[44, 133, 41, 244, 151, 98, 217, 29, 123, 65, 198, 103, 108, 241, 89, 57, 140, 149, 230, 140, 168, 180, 209, 212, 216, 158, 93, 65, 71, 83, 81, 174]
```

From here we can convert into different formats:

```json
"publicKeyBase58": "3zni9pmFAWvFvuGCnnMVSRxYkjv5gkFMKsMsAtqX1SJq"
```

```json
"publicKeyJwk": {
"crv": "Ed25519",
"kty": "OKP",
"x": "LIUp9Jdi2R17QcZnbPFZOYyV5oyotNHU2J5dQUdTUa4"
}
```

## Example of a VC

[TODO: make a smaller example and a good signature]

```json
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
{
"SoftwareSourceCode": "https://schema.org/SoftwareSourceCode",
"creator": "https://schema.org/creator",
"codeRepository": "https://schema.org/codeRepository",
"version": "https://schema.org/version",
"programmingLanguage": "https://schema.org/programmingLanguage"
}
],
"id": "urn:uuid:3f68f17e-c019-4193-9899-c1a8f2cafebd",
"type": [
"VerifiableCredential",
"SoftwareSourceCode"
],
"credentialSubject": {
"id": "urn:uuid:0c3049ec-433f-47cf-b502-6e25d73d2b04",
"programmingLanguage": "C++",
"creator": {
"id": "did:onion:fscst5exmlmr262byztwz4kzhggjlzumvc2ndvgytzoucr2tkgxf7mid",
"type": "Person|Organization"
},
"codeRepository": "https://github.com/BlockchainCommons/bc-seedtool-cli.git",
"version": "6b5b64afd16db4b075bfe68d06f6d58f3189f13a"
},
"issuer": "did:onion:fscst5exmlmr262byztwz4kzhggjlzumvc2ndvgytzoucr2tkgxf7mid",
"issuanceDate": "2021-01-10T19:23:24Z",
"proof": {
"type": "Ed25519Signature2018",
"proofPurpose": "assertionMethod",
"verificationMethod": "did:onion:fscst5exmlmr262byztwz4kzhggjlzumvc2ndvgytzoucr2tkgxf7mid",
"created": "2021-01-27T03:00:50.565Z",
"jws": "eyJhbGciOiJFZERTQSIsImNyaXQiOlsiYjY0Il0sImI2NCI6ZmFsc2V9..s8OLNCqDkwVhnRbyWewr3jNiPnhMoUdsp3-eOSGK6JlfrhsXDnTARZEhdIDaUqZ1iOBWRctWm0ecVvnq4I6xAw"
}
}
```

## Advantages

Besides online verification this method can also allow a verification without a Tor protocol or internet connection which is useful for many devices, including embedded devices.

## Downside

Tor daemon automatically generates an `Ed25519` keypair for an onion service. The private key is stored in an `expanded format` ([1](https://github.com/dalek-cryptography/ed25519-dalek/blob/925eb9ea56192053c9eb93b9d30d1b9419eee128/src/secret.rs#L200)) though, which makes it inconvertible to `JWK` format ([2](https://tools.ietf.org/html/rfc7517)). If a user wants to be able to make such a conversion it is recommended to generate a keypair outside of Tor and do conversions into any format from there.

EDIT: the major downside is the did method cannot be revoked. So probably this option is not viable.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.