cml_multi_era_wasm/byron/mpc/
mod.rs

1// This file was code-generated using an experimental CDDL to rust tool:
2// https://github.com/dcSpark/cddl-codegen
3
4use crate::byron::{
5    AddressIdList, Blake2b256, ByronPubKey, ByronSignature, BytesList, EpochId, StakeholderIdList,
6    VssDecryptedShareList, VssPubKeyList,
7};
8use cml_chain_wasm::byron::{AddressId, StakeholderId};
9use cml_core_wasm::{
10    impl_wasm_cbor_json_api_cbor_event_serialize, impl_wasm_conversions, impl_wasm_list,
11    impl_wasm_map_btree,
12};
13use wasm_bindgen::prelude::wasm_bindgen;
14
15#[derive(Clone, Debug)]
16#[wasm_bindgen]
17pub struct Ssc(cml_multi_era::byron::mpc::Ssc);
18
19impl_wasm_cbor_json_api_cbor_event_serialize!(Ssc);
20
21impl_wasm_conversions!(cml_multi_era::byron::mpc::Ssc, Ssc);
22
23#[wasm_bindgen]
24impl Ssc {
25    pub fn new_ssc_commitments_payload(ssc_commitments_payload: &SscCommitmentsPayload) -> Self {
26        Self(cml_multi_era::byron::mpc::Ssc::new_ssc_commitments_payload(
27            ssc_commitments_payload.clone().into(),
28        ))
29    }
30
31    pub fn new_ssc_openings_payload(ssc_openings_payload: &SscOpeningsPayload) -> Self {
32        Self(cml_multi_era::byron::mpc::Ssc::new_ssc_openings_payload(
33            ssc_openings_payload.clone().into(),
34        ))
35    }
36
37    pub fn new_ssc_shares_payload(ssc_shares_payload: &SscSharesPayload) -> Self {
38        Self(cml_multi_era::byron::mpc::Ssc::new_ssc_shares_payload(
39            ssc_shares_payload.clone().into(),
40        ))
41    }
42
43    pub fn new_ssc_certificates_payload(ssc_certificates_payload: &SscCertificatesPayload) -> Self {
44        Self(
45            cml_multi_era::byron::mpc::Ssc::new_ssc_certificates_payload(
46                ssc_certificates_payload.clone().into(),
47            ),
48        )
49    }
50
51    pub fn kind(&self) -> SscKind {
52        match &self.0 {
53            cml_multi_era::byron::mpc::Ssc::SscCommitmentsPayload(_) => {
54                SscKind::SscCommitmentsPayload
55            }
56            cml_multi_era::byron::mpc::Ssc::SscOpeningsPayload(_) => SscKind::SscOpeningsPayload,
57            cml_multi_era::byron::mpc::Ssc::SscSharesPayload(_) => SscKind::SscSharesPayload,
58            cml_multi_era::byron::mpc::Ssc::SscCertificatesPayload(_) => {
59                SscKind::SscCertificatesPayload
60            }
61        }
62    }
63
64    pub fn as_ssc_commitments_payload(&self) -> Option<SscCommitmentsPayload> {
65        match &self.0 {
66            cml_multi_era::byron::mpc::Ssc::SscCommitmentsPayload(ssc_commitments_payload) => {
67                Some(ssc_commitments_payload.clone().into())
68            }
69            _ => None,
70        }
71    }
72
73    pub fn as_ssc_openings_payload(&self) -> Option<SscOpeningsPayload> {
74        match &self.0 {
75            cml_multi_era::byron::mpc::Ssc::SscOpeningsPayload(ssc_openings_payload) => {
76                Some(ssc_openings_payload.clone().into())
77            }
78            _ => None,
79        }
80    }
81
82    pub fn as_ssc_shares_payload(&self) -> Option<SscSharesPayload> {
83        match &self.0 {
84            cml_multi_era::byron::mpc::Ssc::SscSharesPayload(ssc_shares_payload) => {
85                Some(ssc_shares_payload.clone().into())
86            }
87            _ => None,
88        }
89    }
90
91    pub fn as_ssc_certificates_payload(&self) -> Option<SscCertificatesPayload> {
92        match &self.0 {
93            cml_multi_era::byron::mpc::Ssc::SscCertificatesPayload(ssc_certificates_payload) => {
94                Some(ssc_certificates_payload.clone().into())
95            }
96            _ => None,
97        }
98    }
99}
100
101#[derive(Clone, Debug)]
102#[wasm_bindgen]
103pub struct SscCert(cml_multi_era::byron::mpc::SscCert);
104
105impl_wasm_cbor_json_api_cbor_event_serialize!(SscCert);
106
107impl_wasm_conversions!(cml_multi_era::byron::mpc::SscCert, SscCert);
108
109#[wasm_bindgen]
110impl SscCert {
111    pub fn vss_pub_key(&self) -> VssPubKey {
112        self.0.vss_pub_key.clone()
113    }
114
115    pub fn epoch_id(&self) -> EpochId {
116        self.0.epoch_id
117    }
118
119    pub fn byron_pub_key(&self) -> ByronPubKey {
120        self.0.byron_pub_key.clone()
121    }
122
123    pub fn byron_signature(&self) -> ByronSignature {
124        self.0.byron_signature.clone()
125    }
126
127    pub fn new(
128        vss_pub_key: VssPubKey,
129        epoch_id: EpochId,
130        byron_pub_key: ByronPubKey,
131        byron_signature: ByronSignature,
132    ) -> Self {
133        Self(cml_multi_era::byron::mpc::SscCert::new(
134            vss_pub_key,
135            epoch_id,
136            byron_pub_key,
137            byron_signature,
138        ))
139    }
140}
141
142#[derive(Clone, Debug)]
143#[wasm_bindgen]
144pub struct SscCertificatesPayload(cml_multi_era::byron::mpc::SscCertificatesPayload);
145
146impl_wasm_cbor_json_api_cbor_event_serialize!(SscCertificatesPayload);
147
148impl_wasm_conversions!(
149    cml_multi_era::byron::mpc::SscCertificatesPayload,
150    SscCertificatesPayload
151);
152
153#[wasm_bindgen]
154impl SscCertificatesPayload {
155    pub fn ssc_certs(&self) -> SscCerts {
156        self.0.ssc_certs.clone().into()
157    }
158
159    pub fn new(ssc_certs: &SscCerts) -> Self {
160        Self(cml_multi_era::byron::mpc::SscCertificatesPayload::new(
161            ssc_certs.clone().into(),
162        ))
163    }
164}
165
166#[derive(Clone, Debug)]
167#[wasm_bindgen]
168pub struct SscCertificatesProof(cml_multi_era::byron::mpc::SscCertificatesProof);
169
170impl_wasm_cbor_json_api_cbor_event_serialize!(SscCertificatesProof);
171
172impl_wasm_conversions!(
173    cml_multi_era::byron::mpc::SscCertificatesProof,
174    SscCertificatesProof
175);
176
177#[wasm_bindgen]
178impl SscCertificatesProof {
179    pub fn blake2b256(&self) -> Blake2b256 {
180        self.0.blake2b256.into()
181    }
182
183    pub fn new(blake2b256: &Blake2b256) -> Self {
184        Self(cml_multi_era::byron::mpc::SscCertificatesProof::new(
185            blake2b256.clone().into(),
186        ))
187    }
188}
189
190impl_wasm_list!(cml_multi_era::byron::mpc::SscCert, SscCert, SscCerts);
191
192#[derive(Clone, Debug)]
193#[wasm_bindgen]
194pub struct SscCommitment(cml_multi_era::byron::mpc::SscCommitment);
195
196impl_wasm_cbor_json_api_cbor_event_serialize!(SscCommitment);
197
198impl_wasm_conversions!(cml_multi_era::byron::mpc::SscCommitment, SscCommitment);
199
200#[wasm_bindgen]
201impl SscCommitment {
202    pub fn vss_shares(&self) -> VssShares {
203        self.0.vss_shares.clone().into()
204    }
205
206    pub fn vss_proof(&self) -> VssProof {
207        self.0.vss_proof.clone().into()
208    }
209
210    pub fn new(vss_shares: &VssShares, vss_proof: &VssProof) -> Self {
211        Self(cml_multi_era::byron::mpc::SscCommitment::new(
212            vss_shares.clone().into(),
213            vss_proof.clone().into(),
214        ))
215    }
216}
217
218#[derive(Clone, Debug)]
219#[wasm_bindgen]
220pub struct SscCommitmentsPayload(cml_multi_era::byron::mpc::SscCommitmentsPayload);
221
222impl_wasm_cbor_json_api_cbor_event_serialize!(SscCommitmentsPayload);
223
224impl_wasm_conversions!(
225    cml_multi_era::byron::mpc::SscCommitmentsPayload,
226    SscCommitmentsPayload
227);
228
229#[wasm_bindgen]
230impl SscCommitmentsPayload {
231    pub fn ssc_signed_commitments(&self) -> SscSignedCommitments {
232        self.0.ssc_signed_commitments.clone().into()
233    }
234
235    pub fn ssc_certs(&self) -> SscCerts {
236        self.0.ssc_certs.clone().into()
237    }
238
239    pub fn new(ssc_signed_commitments: &SscSignedCommitments, ssc_certs: &SscCerts) -> Self {
240        Self(cml_multi_era::byron::mpc::SscCommitmentsPayload::new(
241            ssc_signed_commitments.clone().into(),
242            ssc_certs.clone().into(),
243        ))
244    }
245}
246
247#[derive(Clone, Debug)]
248#[wasm_bindgen]
249pub struct SscCommitmentsProof(cml_multi_era::byron::mpc::SscCommitmentsProof);
250
251impl_wasm_cbor_json_api_cbor_event_serialize!(SscCommitmentsProof);
252
253impl_wasm_conversions!(
254    cml_multi_era::byron::mpc::SscCommitmentsProof,
255    SscCommitmentsProof
256);
257
258#[wasm_bindgen]
259impl SscCommitmentsProof {
260    pub fn blake2b256(&self) -> Blake2b256 {
261        self.0.blake2b256.into()
262    }
263
264    pub fn blake2b2562(&self) -> Blake2b256 {
265        self.0.blake2b2562.into()
266    }
267
268    pub fn new(blake2b256: &Blake2b256, blake2b2562: &Blake2b256) -> Self {
269        Self(cml_multi_era::byron::mpc::SscCommitmentsProof::new(
270            blake2b256.clone().into(),
271            blake2b2562.clone().into(),
272        ))
273    }
274}
275
276#[wasm_bindgen]
277pub enum SscKind {
278    SscCommitmentsPayload,
279    SscOpeningsPayload,
280    SscSharesPayload,
281    SscCertificatesPayload,
282}
283
284#[derive(Clone, Debug)]
285#[wasm_bindgen]
286pub struct SscOpeningsPayload(cml_multi_era::byron::mpc::SscOpeningsPayload);
287
288impl_wasm_cbor_json_api_cbor_event_serialize!(SscOpeningsPayload);
289
290impl_wasm_conversions!(
291    cml_multi_era::byron::mpc::SscOpeningsPayload,
292    SscOpeningsPayload
293);
294
295#[wasm_bindgen]
296impl SscOpeningsPayload {
297    pub fn ssc_opens(&self) -> SscOpens {
298        self.0.ssc_opens.clone().into()
299    }
300
301    pub fn ssc_certs(&self) -> SscCerts {
302        self.0.ssc_certs.clone().into()
303    }
304
305    pub fn new(ssc_opens: &SscOpens, ssc_certs: &SscCerts) -> Self {
306        Self(cml_multi_era::byron::mpc::SscOpeningsPayload::new(
307            ssc_opens.clone().into(),
308            ssc_certs.clone().into(),
309        ))
310    }
311}
312
313#[derive(Clone, Debug)]
314#[wasm_bindgen]
315pub struct SscOpeningsProof(cml_multi_era::byron::mpc::SscOpeningsProof);
316
317impl_wasm_cbor_json_api_cbor_event_serialize!(SscOpeningsProof);
318
319impl_wasm_conversions!(
320    cml_multi_era::byron::mpc::SscOpeningsProof,
321    SscOpeningsProof
322);
323
324#[wasm_bindgen]
325impl SscOpeningsProof {
326    pub fn blake2b256(&self) -> Blake2b256 {
327        self.0.blake2b256.into()
328    }
329
330    pub fn blake2b2562(&self) -> Blake2b256 {
331        self.0.blake2b2562.into()
332    }
333
334    pub fn new(blake2b256: &Blake2b256, blake2b2562: &Blake2b256) -> Self {
335        Self(cml_multi_era::byron::mpc::SscOpeningsProof::new(
336            blake2b256.clone().into(),
337            blake2b2562.clone().into(),
338        ))
339    }
340}
341
342impl_wasm_map_btree!(
343    cml_chain::byron::StakeholderId,
344    cml_multi_era::byron::mpc::Vsssec,
345    StakeholderId,
346    Vsssec,
347    StakeholderIdList,
348    SscOpens,
349    false,
350    true,
351    false,
352    false
353);
354
355#[derive(Clone, Debug)]
356#[wasm_bindgen]
357pub struct SscProof(cml_multi_era::byron::mpc::SscProof);
358
359impl_wasm_cbor_json_api_cbor_event_serialize!(SscProof);
360
361impl_wasm_conversions!(cml_multi_era::byron::mpc::SscProof, SscProof);
362
363#[wasm_bindgen]
364impl SscProof {
365    pub fn new_ssc_commitments_proof(ssc_commitments_proof: &SscCommitmentsProof) -> Self {
366        Self(
367            cml_multi_era::byron::mpc::SscProof::new_ssc_commitments_proof(
368                ssc_commitments_proof.clone().into(),
369            ),
370        )
371    }
372
373    pub fn new_ssc_openings_proof(ssc_openings_proof: &SscOpeningsProof) -> Self {
374        Self(cml_multi_era::byron::mpc::SscProof::new_ssc_openings_proof(
375            ssc_openings_proof.clone().into(),
376        ))
377    }
378
379    pub fn new_ssc_shares_proof(ssc_shares_proof: &SscSharesProof) -> Self {
380        Self(cml_multi_era::byron::mpc::SscProof::new_ssc_shares_proof(
381            ssc_shares_proof.clone().into(),
382        ))
383    }
384
385    pub fn new_ssc_certificates_proof(ssc_certificates_proof: &SscCertificatesProof) -> Self {
386        Self(
387            cml_multi_era::byron::mpc::SscProof::new_ssc_certificates_proof(
388                ssc_certificates_proof.clone().into(),
389            ),
390        )
391    }
392
393    pub fn kind(&self) -> SscProofKind {
394        match &self.0 {
395            cml_multi_era::byron::mpc::SscProof::SscCommitmentsProof(_) => {
396                SscProofKind::SscCommitmentsProof
397            }
398            cml_multi_era::byron::mpc::SscProof::SscOpeningsProof(_) => {
399                SscProofKind::SscOpeningsProof
400            }
401            cml_multi_era::byron::mpc::SscProof::SscSharesProof(_) => SscProofKind::SscSharesProof,
402            cml_multi_era::byron::mpc::SscProof::SscCertificatesProof(_) => {
403                SscProofKind::SscCertificatesProof
404            }
405        }
406    }
407
408    pub fn as_ssc_commitments_proof(&self) -> Option<SscCommitmentsProof> {
409        match &self.0 {
410            cml_multi_era::byron::mpc::SscProof::SscCommitmentsProof(ssc_commitments_proof) => {
411                Some(ssc_commitments_proof.clone().into())
412            }
413            _ => None,
414        }
415    }
416
417    pub fn as_ssc_openings_proof(&self) -> Option<SscOpeningsProof> {
418        match &self.0 {
419            cml_multi_era::byron::mpc::SscProof::SscOpeningsProof(ssc_openings_proof) => {
420                Some(ssc_openings_proof.clone().into())
421            }
422            _ => None,
423        }
424    }
425
426    pub fn as_ssc_shares_proof(&self) -> Option<SscSharesProof> {
427        match &self.0 {
428            cml_multi_era::byron::mpc::SscProof::SscSharesProof(ssc_shares_proof) => {
429                Some(ssc_shares_proof.clone().into())
430            }
431            _ => None,
432        }
433    }
434
435    pub fn as_ssc_certificates_proof(&self) -> Option<SscCertificatesProof> {
436        match &self.0 {
437            cml_multi_era::byron::mpc::SscProof::SscCertificatesProof(ssc_certificates_proof) => {
438                Some(ssc_certificates_proof.clone().into())
439            }
440            _ => None,
441        }
442    }
443}
444
445#[wasm_bindgen]
446pub enum SscProofKind {
447    SscCommitmentsProof,
448    SscOpeningsProof,
449    SscSharesProof,
450    SscCertificatesProof,
451}
452
453impl_wasm_map_btree!(
454    cml_chain::byron::AddressId,
455    cml_multi_era::byron::mpc::SscSharesSubmap,
456    AddressId,
457    SscSharesSubmap,
458    AddressIdList,
459    SscShares
460);
461
462#[derive(Clone, Debug)]
463#[wasm_bindgen]
464pub struct SscSharesPayload(cml_multi_era::byron::mpc::SscSharesPayload);
465
466impl_wasm_cbor_json_api_cbor_event_serialize!(SscSharesPayload);
467
468impl_wasm_conversions!(
469    cml_multi_era::byron::mpc::SscSharesPayload,
470    SscSharesPayload
471);
472
473#[wasm_bindgen]
474impl SscSharesPayload {
475    pub fn ssc_shares(&self) -> SscShares {
476        self.0.ssc_shares.clone().into()
477    }
478
479    pub fn ssc_certs(&self) -> SscCerts {
480        self.0.ssc_certs.clone().into()
481    }
482
483    pub fn new(ssc_shares: &SscShares, ssc_certs: &SscCerts) -> Self {
484        Self(cml_multi_era::byron::mpc::SscSharesPayload::new(
485            ssc_shares.clone().into(),
486            ssc_certs.clone().into(),
487        ))
488    }
489}
490
491#[derive(Clone, Debug)]
492#[wasm_bindgen]
493pub struct SscSharesProof(cml_multi_era::byron::mpc::SscSharesProof);
494
495impl_wasm_cbor_json_api_cbor_event_serialize!(SscSharesProof);
496
497impl_wasm_conversions!(cml_multi_era::byron::mpc::SscSharesProof, SscSharesProof);
498
499#[wasm_bindgen]
500impl SscSharesProof {
501    pub fn blake2b256(&self) -> Blake2b256 {
502        self.0.blake2b256.into()
503    }
504
505    pub fn blake2b2562(&self) -> Blake2b256 {
506        self.0.blake2b2562.into()
507    }
508
509    pub fn new(blake2b256: &Blake2b256, blake2b2562: &Blake2b256) -> Self {
510        Self(cml_multi_era::byron::mpc::SscSharesProof::new(
511            blake2b256.clone().into(),
512            blake2b2562.clone().into(),
513        ))
514    }
515}
516
517impl_wasm_map_btree!(
518    cml_chain::byron::AddressId,
519    Vec<Vec<u8>>,
520    AddressId,
521    VssDecryptedShareList,
522    AddressIdList,
523    SscSharesSubmap
524);
525
526#[derive(Clone, Debug)]
527#[wasm_bindgen]
528pub struct SscSignedCommitment(cml_multi_era::byron::mpc::SscSignedCommitment);
529
530impl_wasm_cbor_json_api_cbor_event_serialize!(SscSignedCommitment);
531
532impl_wasm_conversions!(
533    cml_multi_era::byron::mpc::SscSignedCommitment,
534    SscSignedCommitment
535);
536
537#[wasm_bindgen]
538impl SscSignedCommitment {
539    pub fn byron_pub_key(&self) -> ByronPubKey {
540        self.0.byron_pub_key.clone()
541    }
542
543    pub fn ssc_commitment(&self) -> SscCommitment {
544        self.0.ssc_commitment.clone().into()
545    }
546
547    pub fn byron_signature(&self) -> ByronSignature {
548        self.0.byron_signature.clone()
549    }
550
551    pub fn new(
552        byron_pub_key: ByronPubKey,
553        ssc_commitment: &SscCommitment,
554        byron_signature: ByronSignature,
555    ) -> Self {
556        Self(cml_multi_era::byron::mpc::SscSignedCommitment::new(
557            byron_pub_key,
558            ssc_commitment.clone().into(),
559            byron_signature,
560        ))
561    }
562}
563
564impl_wasm_list!(
565    cml_multi_era::byron::mpc::SscSignedCommitment,
566    SscSignedCommitment,
567    SscSignedCommitments
568);
569
570pub type VssDecryptedShare = Vec<u8>;
571
572#[derive(Clone, Debug)]
573#[wasm_bindgen]
574pub struct VssEncryptedShare(cml_multi_era::byron::mpc::VssEncryptedShare);
575
576impl_wasm_cbor_json_api_cbor_event_serialize!(VssEncryptedShare);
577
578impl_wasm_conversions!(
579    cml_multi_era::byron::mpc::VssEncryptedShare,
580    VssEncryptedShare
581);
582
583#[wasm_bindgen]
584impl VssEncryptedShare {
585    pub fn index_0(&self) -> Vec<u8> {
586        self.0.index_0.clone()
587    }
588
589    pub fn new(index_0: Vec<u8>) -> Self {
590        Self(cml_multi_era::byron::mpc::VssEncryptedShare::new(index_0))
591    }
592}
593
594#[derive(Clone, Debug)]
595#[wasm_bindgen]
596pub struct VssProof(cml_multi_era::byron::mpc::VssProof);
597
598impl_wasm_cbor_json_api_cbor_event_serialize!(VssProof);
599
600impl_wasm_conversions!(cml_multi_era::byron::mpc::VssProof, VssProof);
601
602#[wasm_bindgen]
603impl VssProof {
604    pub fn extra_gen(&self) -> Vec<u8> {
605        self.0.extra_gen.clone()
606    }
607
608    pub fn proof(&self) -> Vec<u8> {
609        self.0.proof.clone()
610    }
611
612    pub fn parallel_proofs(&self) -> Vec<u8> {
613        self.0.parallel_proofs.clone()
614    }
615
616    pub fn bytess(&self) -> BytesList {
617        self.0.bytess.clone().into()
618    }
619
620    pub fn new(
621        extra_gen: Vec<u8>,
622        proof: Vec<u8>,
623        parallel_proofs: Vec<u8>,
624        bytess: &BytesList,
625    ) -> Self {
626        Self(cml_multi_era::byron::mpc::VssProof::new(
627            extra_gen,
628            proof,
629            parallel_proofs,
630            bytess.clone().into(),
631        ))
632    }
633}
634
635pub type VssPubKey = Vec<u8>;
636
637impl_wasm_map_btree!(
638    cml_multi_era::byron::mpc::VssPubKey,
639    cml_multi_era::byron::mpc::VssEncryptedShare,
640    VssPubKey,
641    VssEncryptedShare,
642    VssPubKeyList,
643    VssShares,
644    true,
645    false,
646    false,
647    false
648);
649
650pub type Vsssec = Vec<u8>;