Skip to content
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

Oracle JSON format proposal #150

Closed

Conversation

Tibo-lg
Copy link
Member

@Tibo-lg Tibo-lg commented Mar 1, 2021

As mentioned in #134 this is a proposal for JSON serialization of oracle messages.

Closes #134

@Tibo-lg Tibo-lg requested a review from Christewart March 1, 2021 02:05
@benthecarman
Copy link
Contributor

benthecarman commented Mar 1, 2021

We need a format for both kinds of descriptors

@Tibo-lg Tibo-lg force-pushed the oracle-json-serialization branch from c69accb to 15d37f0 Compare March 1, 2021 12:05
@Tibo-lg
Copy link
Member Author

Tibo-lg commented Mar 1, 2021

We need a format for both kinds of descriptors

Good point thanks, updated

Copy link
Contributor

@benthecarman benthecarman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

```

where:
`anouncementSignature` is a hex string of length 128 representing a BIP340 Schnorr signature,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

of what? Presumably a serialization of this JSON string without the signature field or something like that?

@@ -204,6 +204,89 @@ The algorithm `Sign(sk, message, tag)` is defined as:
* Let `m` = H(`message`)
* Return `BIP340_sign(sk, m)`

## JSON Serialization
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The introduction of this option means that a field must be added to the TLV format in front of oracle_signature specifying what the oracle has signed (TLV vs. JSON vs. other) as the client will have to reconstruct that message from the TLV.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To answer to both your questions, it's a good point that I hadn't specified this. My thinking was that it would be the same signature as the TLV version. It could be nice and practical to allow signature of JSON messages, but JSON being non canonical it's not trivial to do. We would need to adopt a specification for that or make a custom one which feels cumbersome.
Also (as you mention here) we would need clients to at the end probably support both signing format. I feel instead it is better to have oralce implement TLV signing which compared to the client TLV is not that hard to implement IMHO.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that JSON messages being non canonical does not make it difficult to sign them. It is of course very difficult if you are trying to embed the JSON that is signed along side the signature. The most straightforward way is to encode the json in a string inside the outer json.

curl -sL https://h00.ooo/time/2021-06-02T01:00:00?occur | jq
{
  "announcement": {
    "oracle_event": {
      "encoding": "json",
      "data": "{\"id\":\"/time/2021-06-02T01:00:00?occur\",\"expected_outcome_time\":\"2021-06-02T01:00:00\",\"descriptor\":{\"type\":\"enum\",\"outcomes\":[\"true\"]},\"nonces\":[\"0c2f40112642c09db886e5ce24ed94687ea022e0616990e1cfc0104348dc7a43\"]}"
    },
    "signature": "4c4861d830e9914351b59daacbb58b17d62865319163f732e399f2102e1080273729ecef419f7d04e536ca9e730e8d16793df56e8c3c716e7e28dba6c9a0df02"
  },
  "attestation": null
}

Then after verifying the signature you decode the announcement:

curl -sL https://h00.ooo/time/2021-06-02T01:00:00?occur | jq .announcement.oracle_event.data -r | jq
{
  "id": "/time/2021-06-02T01:00:00?occur",
  "expected_outcome_time": "2021-06-02T01:00:00",
  "descriptor": {
    "type": "enum",
    "outcomes": [
      "true"
    ]
  },
  "nonces": [
    "0c2f40112642c09db886e5ce24ed94687ea022e0616990e1cfc0104348dc7a43"
  ]
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah so that's one way. We would need to define how we encode the string as well. But what doesn't work very well is if we want to pass along announcements to counter parties. Of course we could embed the string again as well, but I feel it becomes complicated personally (and quite inefficient).

@Christewart
Copy link
Contributor

@Tibo-lg Is this the format used in test vectors in #163 ?

@Tibo-lg
Copy link
Member Author

Tibo-lg commented Apr 13, 2022

It was discussed to work instead on the format defined in #163 test vectors.

@Tibo-lg Tibo-lg closed this Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JSON serialization of oracle announcement and attestations
5 participants