@@ -10,16 +10,16 @@ broadcast_channel.onmessage = (e) => {
1010 let event = e . data ;
1111 if ( event . type === "CertificateChainValidationStarted" ) {
1212 console . log (
13- `The certificate chain validation has started, event_id: ${ event . payload . certificate_chain_validation_id } `
13+ `The certificate chain validation has started, event_id: ${ event . payload . certificate_chain_validation_id } ` ,
1414 ) ;
1515 } else if ( event . type === "CertificateValidated" ) {
1616 console . log (
17- `A certificate has been validated, certificate_hash: ${ event . payload . certificate_hash } , event_id: ${ event . payload . certificate_chain_validation_id } `
17+ `A certificate has been validated, certificate_hash: ${ event . payload . certificate_hash } , event_id: ${ event . payload . certificate_chain_validation_id } ` ,
1818 ) ;
1919 } else if ( event . type === "CertificateChainValidated" ) {
2020 certificate_chain_validated_occurs = true ;
2121 console . log (
22- `The certificate chain is valid, event_id: ${ event . payload . certificate_chain_validation_id } `
22+ `The certificate chain is valid, event_id: ${ event . payload . certificate_chain_validation_id } ` ,
2323 ) ;
2424 } else {
2525 console . log ( event ) ;
@@ -40,62 +40,69 @@ async function main() {
4040 http_headers : new Map ( [ [ "Content-Type" , "application/json" ] ] ) ,
4141 // The following option activates the unstable features of the client.
4242 // Unstable features will trigger an error if this option is not set.
43- unstable : true
43+ unstable : true ,
4444 } ) ;
4545
4646 console . log ( 1 , "Getting stake distributions list..." ) ;
4747 let mithril_stake_distributions_list = await client . list_mithril_stake_distributions ( ) ;
4848 console . log (
4949 "Result" ,
50- "got " + mithril_stake_distributions_list . length + " stake distributions ✔️"
50+ "got " + mithril_stake_distributions_list . length + " stake distributions ✔️" ,
5151 ) ;
5252 console . log ( "stake distributions:" , mithril_stake_distributions_list ) ;
5353 let last_mithril_stake_distribution = mithril_stake_distributions_list [ 0 ] ;
5454
5555 console . log (
5656 2 ,
57- "Getting last stake distribution with hash: " + last_mithril_stake_distribution . hash + "..."
57+ "Getting last stake distribution with hash: " + last_mithril_stake_distribution . hash + "..." ,
5858 ) ;
5959 let last_stake_distribution = await client . get_mithril_stake_distribution (
60- last_mithril_stake_distribution . hash
60+ last_mithril_stake_distribution . hash ,
6161 ) ;
6262 console . log ( "Result" , "got last stake distribution ✔️" ) ;
6363 console . log ( "last_stake_distribution:" , {
6464 epoch : last_stake_distribution . epoch ,
65- signers : last_stake_distribution . signers . map ( ( s ) => `${ s . party_id } - ${ s . stake } lovelace` )
65+ signers : last_stake_distribution . signers . map ( ( s ) => `${ s . party_id } - ${ s . stake } lovelace` ) ,
6666 } ) ;
6767
6868 console . log (
6969 3 ,
7070 "Getting Mithril certificate from certificate hash: " +
71- last_stake_distribution . certificate_hash +
72- "..."
71+ last_stake_distribution . certificate_hash +
72+ "..." ,
7373 ) ;
7474 let certificate = await client . get_mithril_certificate ( last_stake_distribution . certificate_hash ) ;
7575 console . log ( "Result" , "got Mithril certificate ✔️" ) ;
76- console . log ( "certificate:" , certificate . hash , "epoch:" , certificate . epoch , "signed_entity:" , certificate . signed_entity_type ) ;
76+ console . log (
77+ "certificate:" ,
78+ certificate . hash ,
79+ "epoch:" ,
80+ certificate . epoch ,
81+ "signed_entity:" ,
82+ certificate . signed_entity_type ,
83+ ) ;
7784
7885 console . log ( 4 , "Verifying certificate chain..." ) ;
7986 let last_certificate_from_chain = await client . verify_certificate_chain ( certificate . hash ) ;
8087 await waitUntilCertificateChainValidatedOccursOrTimeout ( ) ;
8188 console . log ( "Result" , "certificate chain verified ✔️" ) ;
8289 console . log (
8390 "verify_certificate_chain OK, last_certificate_from_chain:" ,
84- last_certificate_from_chain . hash
91+ last_certificate_from_chain . hash ,
8592 ) ;
8693
8794 console . log ( 5 , "Computing the Mithril stake distribution message..." ) ;
8895 let mithril_stake_distributions_message = await client . compute_mithril_stake_distribution_message (
8996 last_stake_distribution ,
90- last_certificate_from_chain
97+ last_certificate_from_chain ,
9198 ) ;
9299 console . log ( "Result" , "Mithril stake distribution message computed ✔️" ) ;
93100 console . log ( "mithril_stake_distributions_message:" , mithril_stake_distributions_message ) ;
94101
95102 console . log ( 6 , "Validating Mithril stake distribution message..." ) ;
96103 let valid_stake_distribution_message = await client . verify_message_match_certificate (
97104 mithril_stake_distributions_message ,
98- last_certificate_from_chain
105+ last_certificate_from_chain ,
99106 ) ;
100107 console . log ( "Result" , "Mithril stake distribution message validated ✔️" ) ;
101108 console . log ( "valid_stake_distribution_message:" , valid_stake_distribution_message ) ;
@@ -104,17 +111,11 @@ async function main() {
104111 const proof = await client . get_cardano_transaction_proofs ( [
105112 "eac09f970f47ef3ab378db9232914e146773853397e79b904f1a45123a23c21f" ,
106113 "81fe7a5dab42867ef309b6d7210158bf99331884ac3c3b6c7188a8c9c18d5974" ,
107- "320c13f4a3e51f6f4f66fcd9007e02bf658aa4ee9a88a509028d867d3b8a8e9a"
114+ "320c13f4a3e51f6f4f66fcd9007e02bf658aa4ee9a88a509028d867d3b8a8e9a" ,
108115 ] ) ;
109116 console . log ( "Certificate hash of the returned proof" , proof . certificate_hash ) ;
110- console . log (
111- "Transactions hashes included in the proof:" ,
112- proof . transactions_hashes
113- ) ;
114- console . log (
115- "Transactions hashes not included in the proof:" ,
116- proof . non_certified_transactions
117- ) ;
117+ console . log ( "Transactions hashes included in the proof:" , proof . transactions_hashes ) ;
118+ console . log ( "Transactions hashes not included in the proof:" , proof . non_certified_transactions ) ;
118119
119120 console . log ( 9 , "Verifying certificate chain..." ) ;
120121 let proof_certificate = await client . verify_certificate_chain ( proof . certificate_hash ) ;
@@ -125,19 +126,18 @@ async function main() {
125126 console . log ( 10 , "Validating Cardano transaction proof message..." ) ;
126127 let protocol_message = await client . verify_cardano_transaction_proof_then_compute_message (
127128 proof ,
128- proof_certificate
129+ proof_certificate ,
129130 ) ;
130131 console . log ( "Ensure that the proof is indeed signed in the associated certificate" ) ;
131- if ( ( await client . verify_message_match_certificate ( protocol_message , proof_certificate ) ) === true ) {
132+ if (
133+ ( await client . verify_message_match_certificate ( protocol_message , proof_certificate ) ) === true
134+ ) {
132135 console . log ( "Result" , "The proof is signed in the associated certificate ✔️" ) ;
133136 } else {
134137 console . log ( "Result" , "Proof and certificate don't match ❌" ) ;
135138 }
136139 console . log ( "Transactions hashes certified" , proof . transactions_hashes ) ;
137- console . log (
138- "Transactions hashes not certified" ,
139- proof . non_certified_transactions
140- ) ;
140+ console . log ( "Transactions hashes not certified" , proof . non_certified_transactions ) ;
141141
142142 process . exit ( 0 ) ;
143143}
0 commit comments