-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a057497
commit a143ec2
Showing
62 changed files
with
982 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Serialization Format | ||
|
||
With the `serialization` feature, which is enabled by default, all structs that | ||
need to communicated will have `serialize()` and `deserialize()` methods. | ||
|
||
The format is basically the `serde` encoding of the structs using the | ||
[`postcard`](https://docs.rs/postcard/latest/postcard/) crate. | ||
|
||
- Integers are encoded in [varint | ||
format](https://postcard.jamesmunns.com/wire-format#varint-encoded-integers) | ||
- Fixed-size byte arrays are encoded as-is (e.g. scalars, elements) | ||
- Note that the encoding of scalars and elements are defined by the | ||
ciphersuites. | ||
- Variable-size byte arrays are encoded with a length prefix (varint-encoded) | ||
and the array as-is (e.g. the message) | ||
- Maps are encoded as the varint-encoded item count, followed by concatenated | ||
item encodings. | ||
- Ciphersuite IDs are encoded as the 4-byte CRC-32 of the ID string. | ||
- Structs are encoded as the concatenation of the encodings of its items. | ||
|
||
For example, the following Signing Package: | ||
|
||
- Commitments (map): | ||
- Identifier (byte array): `2a00000000000000000000000000000000000000000000000000000000000000` | ||
- Signing Commitments: | ||
- Hiding (byte array): `e2f2ae0a6abc4e71a884a961c500515f58e30b6aa582dd8db6a65945e08d2d76` | ||
- Bindng (byte array): `6a493210f7499cd17fecb510ae0cea23a110e8d5b901f8acadd3095c73a3b919` | ||
- Ciphersuite ID: `"FROST(ristretto255, SHA-512)"` | ||
- Message (variable size byte array): `68656c6c6f20776f726c64` (`"hello world"` in UTF-8) | ||
- Ciphersuite ID (4 bytes): `"FROST(ristretto255, SHA-512)"` | ||
|
||
Is encoded as | ||
|
||
``` | ||
012a000000000000000000000000000000000000000000000000000000000000 | ||
00e2f2ae0a6abc4e71a884a961c500515f58e30b6aa582dd8db6a65945e08d2d | ||
766a493210f7499cd17fecb510ae0cea23a110e8d5b901f8acadd3095c73a3b9 | ||
19e6811b690b68656c6c6f20776f726c64e6811b69 | ||
``` | ||
|
||
- `01`: the length of the map | ||
- `2a00000000000000000000000000000000000000000000000000000000000000`: the identifier | ||
- `e2f2ae0a6abc4e71a884a961c500515f58e30b6aa582dd8db6a65945e08d2d76`: the hinding commitment | ||
- `6a493210f7499cd17fecb510ae0cea23a110e8d5b901f8acadd3095c73a3b919`: the binding commitment | ||
- `e6811b69`: the ciphersuite ID of the SigningCommitments, CRC-32 of "FROST(ristretto255, SHA-512)" | ||
- `0b`: the length of the message | ||
- `68656c6c6f20776f726c64`: the message | ||
- `e6811b69`: the ciphersuite ID of the SigningPackage, CRC-32 of "FROST(ristretto255, SHA-512)" | ||
|
||
```admonish note | ||
The ciphersuite ID is encoded multiple times in this case because `SigningPackage` includes | ||
`SigningCommitments`, which also need to be communicated in Round 1 and thus also encodes | ||
its ciphersuite ID. This is the only instance where this happens. | ||
``` | ||
|
||
## Test Vectors | ||
|
||
Check the | ||
[`snapshots`](https://github.com/search?q=repo%3AZcashFoundation%2Ffrost+path%3Asnapshots&type=code) | ||
files in each ciphersuite crate for test vectors. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,11 @@ edition = "2021" | |
# - Update CHANGELOG.md | ||
# - Create git tag. | ||
version = "0.6.0" | ||
authors = ["Deirdre Connolly <[email protected]>", "Chelsea Komlo <[email protected]>", "Conrado Gouvea <[email protected]>"] | ||
authors = [ | ||
"Deirdre Connolly <[email protected]>", | ||
"Chelsea Komlo <[email protected]>", | ||
"Conrado Gouvea <[email protected]>", | ||
] | ||
readme = "README.md" | ||
license = "MIT OR Apache-2.0" | ||
repository = "https://github.com/ZcashFoundation/frost" | ||
|
@@ -18,9 +22,11 @@ features = ["nightly"] | |
|
||
[dependencies] | ||
byteorder = "1.4" | ||
const-crc32 = "1.2.0" | ||
debugless-unwrap = "0.0.4" | ||
derive-getters = "0.3.0" | ||
hex = { version = "0.4.3", features = ["serde"] } | ||
postcard = { version = "1.0.0", features = ["use-std"], optional = true } | ||
rand_core = "0.6" | ||
serde = { version = "1.0.160", features = ["derive"], optional = true } | ||
serdect = { version = "0.2.0", optional = true } | ||
|
@@ -43,9 +49,10 @@ serde_json = "1.0" | |
|
||
[features] | ||
nightly = [] | ||
default = [] | ||
default = ["serialization"] | ||
internals = [] | ||
serde = ["dep:serde", "dep:serdect"] | ||
serialization = ["serde", "dep:postcard"] | ||
# Exposes ciphersuite-generic tests for other crates to use | ||
test-impl = ["proptest", "serde_json", "criterion"] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.