Skip to content

Commit 311c9f4

Browse files
committed
merge 'main'
2 parents a931db0 + 17afb2c commit 311c9f4

File tree

221 files changed

+8371
-947
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

221 files changed

+8371
-947
lines changed

.github/workflows/test-client.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ on:
3131
required: false
3232
type: string
3333
default: https://raw.githubusercontent.com/input-output-hk/mithril/main/mithril-infra/configuration/pre-release-preview/genesis.vkey
34+
transactions_hashes_to_certify:
35+
description: Comma separated list of transactions hashes to test certification on.
36+
required: false
37+
type: string
3438
enable_debug:
3539
description: Enable debug output ("-vvv") for the mithril-client calls
3640
required: true
@@ -193,6 +197,7 @@ jobs:
193197
run: |
194198
echo "AGGREGATOR_ENDPOINT=${{ inputs.aggregator_endpoint }}" > ./www-test/.env
195199
echo "GENESIS_VERIFICATION_KEY=$(curl -s ${{ inputs.genesis_verification_key }})" >> ./www-test/.env
200+
echo "TRANSACTIONS_HASHES_TO_CERTIFY=${{ inputs.transactions_hashes_to_certify }}" >> ./www-test/.env
196201
197202
- name: Start the server
198203
working-directory: mithril-client-wasm

Cargo.lock

Lines changed: 59 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@ resolver = "2"
44

55
members = [
66
"demo/protocol-demo",
7+
"examples/client-cardano-transaction",
78
"examples/client-mithril-stake-distribution",
89
"examples/client-snapshot",
910
"mithril-aggregator",
11+
"mithril-build-script",
1012
"mithril-client",
1113
"mithril-client-cli",
1214
"mithril-client-wasm",
1315
"mithril-common",
16+
"mithril-doc",
17+
"mithril-doc-derive",
1418
"mithril-persistence",
1519
"mithril-relay",
1620
"mithril-signer",

demo/protocol-demo/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithrildemo"
3-
version = "0.1.29"
3+
version = "0.1.30"
44
authors = { workspace = true }
55
edition = { workspace = true }
66
documentation = { workspace = true }
@@ -15,6 +15,7 @@ clap = { version = "4.4.18", features = ["derive"] }
1515
hex = "0.4.3"
1616
log = "0.4.20"
1717
mithril-common = { path = "../../mithril-common", features = ["fs"] }
18+
mithril-doc = { path = "../../mithril-doc" }
1819
rand_chacha = "0.3.1"
1920
rand_core = "0.6.4"
2021
serde = { version = "1.0.196", features = ["derive"] }

demo/protocol-demo/src/demonstrator.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ impl Demonstrator {
316316
})
317317
.collect::<Vec<Vec<u8>>>();
318318
Self {
319-
config: *config,
319+
config: config.clone(),
320320
parties,
321321
verifier: None,
322322
messages,
@@ -495,6 +495,7 @@ mod tests {
495495
fn default_config() -> crate::Config {
496496
let protocol_parameters = setup_protocol_parameters();
497497
crate::Config {
498+
command: None,
498499
m: protocol_parameters.m,
499500
k: protocol_parameters.k,
500501
phi_f: protocol_parameters.phi_f,

demo/protocol-demo/src/main.rs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@ mod demonstrator;
22
mod types;
33

44
use crate::demonstrator::{Demonstrator, ProtocolDemonstrator};
5-
use clap::Parser;
5+
use clap::{CommandFactory, Parser, Subcommand};
6+
use mithril_doc::GenerateDocCommands;
67
use rand_chacha::ChaCha20Rng;
78
use rand_core::SeedableRng;
89

910
/// Simple demonstration of the Mithril protocol
10-
#[derive(Parser, Debug, PartialEq, Clone, Copy)]
11+
#[derive(Parser, Debug, PartialEq)]
1112
pub struct Config {
13+
/// Available commands
14+
#[command(subcommand)]
15+
command: Option<DemoCommands>,
16+
1217
/// Security parameter, upper bound on indices
1318
#[clap(short, long, default_value_t = 200)]
1419
m: u64,
@@ -30,9 +35,29 @@ pub struct Config {
3035
nmessages: usize,
3136
}
3237

38+
impl Clone for Config {
39+
fn clone(&self) -> Self {
40+
Config {
41+
command: None,
42+
..*self
43+
}
44+
}
45+
}
46+
47+
#[derive(Subcommand, Debug, PartialEq)]
48+
enum DemoCommands {
49+
#[clap(alias("doc"), hide(true))]
50+
GenerateDoc(GenerateDocCommands),
51+
}
52+
3353
fn main() {
3454
let config = Config::parse();
3555

56+
if let Some(DemoCommands::GenerateDoc(cmd)) = &config.command {
57+
cmd.execute(&mut Config::command()).unwrap();
58+
return;
59+
}
60+
3661
println!(">> Launch Mithril protocol demonstrator with configuration: \n{config:#?}");
3762

3863
//////////////////////

docs/website/root/glossary.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ A Cardano node is a node that runs in a [Cardano network](#cardano-network). The
2424

2525
A Cardano key pair is an asymmetric key pair used to identify a [stake pool operator](#stake-pool-operator-spo) on the [Cardano network](#cardano-network).
2626

27+
## Cardano transaction
28+
29+
A Cardano transaction proof is a cryptographic proof that a sub-set of Cardano transactions is included in the Cardano transactions set. It is generated upon request from a [Mithril client](#mithril-client) and is signed by a [certificate](#certificate).
30+
31+
A Cardano transactions set commitment represents, in a succinct way, the Cardano transactions set that was signed by Mithril at a given [Beacon](#beacon).
32+
2733
## Certificate
2834

2935
The Mithril aggregator combines the produced [multi-signature](#multi-signature) and some metadata into a Mithril certificate that will be later used by the [Mithril client](#mithril-client) to verify the authenticity of a [snapshot](#snapshot). The certificates are chained so that the [stake distribution](#stake-distribution) used to create the signatures is verifiably genuine.

docs/website/root/manual/developer-docs/nodes/mithril-client-library-wasm.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Mithril client library WASM can be used by Javascript developers to use the Mith
1414
It is responsible for handling the different types of data certified by Mithril, and available through a Mithril aggregator:
1515
- [**Snapshot**](../../../glossary.md#snapshot): list and get.
1616
- [**Mithril stake distribution**](../../../glossary.md#stake-distribution): list and get.
17+
- [**Cardano transaction**](../../../glossary.md#cardano-transaction): list & get commitments, get proofs
1718
- [**Certificate**](../../../glossary.md#certificate): list, get, and chain validation.
1819

1920
:::
@@ -113,6 +114,36 @@ let valid_stake_distribution_message = await client.verify_message_match_certifi
113114
console.log("valid_stake_distribution_message:", valid_stake_distribution_message);
114115
```
115116

117+
If the aggregator signs **CardanoTransactions**, you can add the code below to the previous example:
118+
119+
:::tip
120+
121+
You can verify that the aggregator signs **CardanoTransactions** by running the command below:
122+
123+
```bash
124+
wget -q -O - YOUR_AGGREGATOR_ENDPOINT | jq '.capabilities.signed_entity_types | contains(["CardanoTransactions"])'
125+
```
126+
127+
For example with the aggregator on `testing-sanchonet` Mithril network:
128+
129+
```bash
130+
wget -q -O - https://aggregator.testing-sanchonet.api.mithril.network/aggregator | jq '.capabilities.signed_entity_types | contains(["CardanoTransactions"])'
131+
```
132+
133+
:::
134+
135+
```js
136+
const proof = await client.unstable.get_cardano_transaction_proofs(["CARDANO_TRANSACTION_HASH_1", "CARDANO_TRANSACTION_HASH_2"]);
137+
console.log("Proof tx hash", proof.transactions_hashes);
138+
console.log("Proof certificate hash", proof.certificate_hash);
139+
140+
let proof_certificate = await client.verify_certificate_chain(proof.certificate_hash);
141+
console.log("verify_certificate_chain OK, last_certificate_from_chain:", proof_certificate);
142+
143+
let valid_cardano_transaction_proof = await client.unstable.verify_cardano_transaction_proof_then_compute_message(proof, proof_certificate);
144+
console.log("valid_cardano_transaction_proof:", valid_cardano_transaction_proof);
145+
```
146+
116147
:::tip
117148

118149
You can read the complete [Rust developer documentation](https://mithril.network/rust-doc/mithril_client_wasm/index.html).

0 commit comments

Comments
 (0)