-
Notifications
You must be signed in to change notification settings - Fork 36
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
Oracle JSON format proposal #150
Conversation
We need a format for both kinds of descriptors |
c69accb
to
15d37f0
Compare
Good point thanks, updated |
There was a problem hiding this 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, |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"
]
}
There was a problem hiding this comment.
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).
It was discussed to work instead on the format defined in #163 test vectors. |
As mentioned in #134 this is a proposal for JSON serialization of oracle messages.
Closes #134