Skip to content

Commit e3a1fbe

Browse files
committed
refactor(add block types and cddl tests): verifcation and refactor
1 parent 8a58bbc commit e3a1fbe

File tree

7 files changed

+1673
-846
lines changed

7 files changed

+1673
-846
lines changed

rust/immutable-ledger/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ ulid = { version = "1.1.3", features = ["serde", "uuid"] }
1616
hex = "0.4.3"
1717
blake2b_simd = "1.0.2"
1818
blake3 = "=0.1.3"
19-
19+
cddl = "0.9.4"
2020

2121

2222

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
block = [
2+
block_header,
3+
block_data: metadata,
4+
validator_signature:metadata,
5+
]
6+
7+
block_header = [
8+
chain_id: ULID,
9+
height: int,
10+
timestamp: #6.1(uint .ge 1722470400), ; Epoch-based date/time
11+
prev_block_id: hash_bytes, ; hash of the previous block
12+
ledger_type: UUID,
13+
purpose_id: ULID / UUID,
14+
validator: validator,
15+
metadata: metadata,
16+
]
17+
18+
ULID = #6.32780(bytes) ; ULID type
19+
UUID = #6.37(bytes) ; UUID type
20+
21+
BLAKE_3 = #6.32781(bytes) ; Blake3 hash
22+
BLAKE_2B = #6.32782(bytes) ; Blake2b hash
23+
BLAKE_2S = #6.32783(bytes) ; Blake2s hash
24+
25+
hash_bytes = BLAKE_2B / BLAKE_3 / BLAKE_2S
26+
27+
kid = hash_bytes ; hash of the x509/c509 certificate
28+
29+
validator = (kid / [2* kid])
30+
31+
metadata = [ *any ]
32+
33+
validator_signature = (bytes / [2* bytes])
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
block_header = [
2+
chain_id: ULID,
3+
height: int,
4+
timestamp: #6.1(uint .ge 1722470400), ; Epoch-based date/time
5+
prev_block_id: hash_bytes, ; hash of the previous block
6+
ledger_type: UUID,
7+
purpose_id: ULID / UUID,
8+
validator: validator,
9+
metadata: metadata,
10+
]
11+
12+
ULID = #6.32780(bytes) ; ULID type
13+
UUID = #6.37(bytes) ; UUID type
14+
15+
BLAKE_3 = #6.32781(bytes) ; Blake3 hash
16+
BLAKE_2B = #6.32782(bytes) ; Blake2b hash
17+
BLAKE_2S = #6.32783(bytes) ; Blake2s hash
18+
19+
hash_bytes = BLAKE_2B / BLAKE_3 / BLAKE_2S
20+
21+
kid = hash_bytes ; hash of the x509/c509 certificate
22+
23+
validator = (kid / [2* kid])
24+
25+
metadata = [ *any ]
26+

rust/immutable-ledger/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
//!
55
//! Spec: `<https://input-output-hk.github.io/catalyst-voices/architecture/08_concepts/immutable_ledger/ledger>`
66
7-
/// Block validation logic
8-
pub mod validate;
9-
10-
/// Block encoding decoding
7+
/// Block encoding decoding and validation
118
pub mod serialize;
9+
10+
/// ac
11+
pub mod ser;

0 commit comments

Comments
 (0)