11// Copyright (c) 2025 IOTA Stiftung
22// SPDX-License-Identifier: Apache-2.0
33
4- use std:: sync:: Arc ;
5-
6- use crate :: error:: Result ;
7-
8- /// A member of a Validator Committee
9- ///
10- /// # BCS
11- ///
12- /// The BCS serialized form for this type is defined by the following ABNF:
13- ///
14- /// ```text
15- /// validator-committee-member = bls-public-key
16- /// u64 ; stake
17- /// ```
18- #[ derive( Clone , Debug , uniffi:: Record ) ]
19- pub struct ValidatorCommitteeMember {
20- pub public_key : Arc < Bls12381PublicKey > ,
21- pub stake : u64 ,
22- }
4+ pub mod multisig;
5+ pub mod passkey;
6+ pub mod validator;
7+ pub mod zklogin;
238
24- impl From < iota_types:: ValidatorCommitteeMember > for ValidatorCommitteeMember {
25- fn from ( value : iota_types:: ValidatorCommitteeMember ) -> Self {
26- Self {
27- public_key : Arc :: new ( value. public_key . into ( ) ) ,
28- stake : value. stake ,
29- }
30- }
31- }
9+ use std:: sync:: Arc ;
3210
33- impl From < ValidatorCommitteeMember > for iota_types:: ValidatorCommitteeMember {
34- fn from ( value : ValidatorCommitteeMember ) -> Self {
35- Self {
36- public_key : * * value. public_key ,
37- stake : value. stake ,
38- }
39- }
40- }
11+ use crate :: { error:: Result , types:: signature:: SimpleSignature } ;
4112
42- macro_rules! impl_public_key {
13+ macro_rules! impl_crypto_object {
4314 ( $( #[ $meta: meta] ) * $t: ident) => {
4415 $( #[ $meta] ) *
4516 #[ derive( Copy , Clone , Debug , derive_more:: From , derive_more:: Deref , uniffi:: Object ) ]
@@ -70,7 +41,7 @@ macro_rules! impl_public_key {
7041 } ;
7142}
7243
73- impl_public_key ! (
44+ impl_crypto_object ! (
7445 /// A bls12381 min-sig public key.
7546 ///
7647 /// # BCS
@@ -87,7 +58,7 @@ impl_public_key!(
8758 /// binary form (in bcs) is 97 bytes long vs a more compact 96 bytes.
8859 Bls12381PublicKey
8960) ;
90- impl_public_key ! (
61+ impl_crypto_object ! (
9162 /// An ed25519 public key.
9263 ///
9364 /// # BCS
@@ -99,7 +70,7 @@ impl_public_key!(
9970 /// ```
10071 Ed25519PublicKey
10172) ;
102- impl_public_key ! (
73+ impl_crypto_object ! (
10374 /// A secp256k1 signature.
10475 ///
10576 /// # BCS
@@ -111,7 +82,7 @@ impl_public_key!(
11182 /// ```
11283 Secp256k1PublicKey
11384) ;
114- impl_public_key ! (
85+ impl_crypto_object ! (
11586 /// A secp256r1 signature.
11687 ///
11788 /// # BCS
@@ -123,3 +94,56 @@ impl_public_key!(
12394 /// ```
12495 Secp256r1PublicKey
12596) ;
97+ impl_crypto_object ! (
98+ /// An ed25519 signature.
99+ ///
100+ /// # BCS
101+ ///
102+ /// The BCS serialized form for this type is defined by the following ABNF:
103+ ///
104+ /// ```text
105+ /// ed25519-signature = 64OCTECT
106+ /// ```
107+ Ed25519Signature
108+ ) ;
109+ impl_crypto_object ! (
110+ /// A bls12381 min-sig public key.
111+ ///
112+ /// # BCS
113+ ///
114+ /// The BCS serialized form for this type is defined by the following ABNF:
115+ ///
116+ /// ```text
117+ /// bls-public-key = %x60 96OCTECT
118+ /// ```
119+ ///
120+ /// Due to historical reasons, even though a min-sig `Bls12381PublicKey` has a
121+ /// fixed-length of 96, IOTA's binary representation of a min-sig
122+ /// `Bls12381PublicKey` is prefixed with its length meaning its serialized
123+ /// binary form (in bcs) is 97 bytes long vs a more compact 96 bytes.
124+ Bls12381Signature
125+ ) ;
126+ impl_crypto_object ! (
127+ /// A secp256k1 public key.
128+ ///
129+ /// # BCS
130+ ///
131+ /// The BCS serialized form for this type is defined by the following ABNF:
132+ ///
133+ /// ```text
134+ /// secp256k1-public-key = 33OCTECT
135+ /// ```
136+ Secp256k1Signature
137+ ) ;
138+ impl_crypto_object ! (
139+ /// A secp256r1 public key.
140+ ///
141+ /// # BCS
142+ ///
143+ /// The BCS serialized form for this type is defined by the following ABNF:
144+ ///
145+ /// ```text
146+ /// secp256r1-public-key = 33OCTECT
147+ /// ```
148+ Secp256r1Signature
149+ ) ;
0 commit comments