-
Notifications
You must be signed in to change notification settings - Fork 18
Fix multiple TODOs #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,9 +63,10 @@ impl<'a, E: EngineBLS> Signed for &'a Delinearized<E> { | |
|
|
||
| type M = &'a Message; | ||
| type PKG = &'a PublicKey<Self::E>; | ||
| type PKnM = ::std::collections::hash_map::Iter<'a, Message, PublicKey<E>>; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe the explicit use of hash_map was intentional to impose the hash_map's orders, do we know for sure if we remove the hash_map we get the same ordering? |
||
|
|
||
| fn messages_and_publickeys(self) -> Self::PKnM { | ||
| fn messages_and_publickeys( | ||
| self, | ||
| ) -> impl Iterator<Item = (&'a Message, &'a PublicKey<E>)> + ExactSizeIterator { | ||
| self.messages_n_publickeys.iter() | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -35,7 +35,7 @@ | |||||
| // https://twitter.com/btcVeg/status/1085490561082183681 | ||||||
|
|
||||||
| use core::borrow::Borrow; // BorrowMut | ||||||
| // We use BTreeMap instead of BTreeMap for no_std compatibility. | ||||||
| // We use BTreeMap instead of BTreeMap for no_std compatibility. | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| use alloc::collections::BTreeMap; | ||||||
|
|
||||||
| use ark_ff::Zero; | ||||||
|
|
@@ -134,9 +134,10 @@ impl<'a, E: EngineBLS> Signed for &'a MultiMessageSignatureAggregatorAssumingPoP | |||||
|
|
||||||
| type M = &'a Message; | ||||||
| type PKG = &'a PublicKey<Self::E>; | ||||||
| type PKnM = alloc::collections::btree_map::Iter<'a, Message, PublicKey<E>>; | ||||||
|
|
||||||
| fn messages_and_publickeys(self) -> Self::PKnM { | ||||||
| fn messages_and_publickeys( | ||||||
| self, | ||||||
| ) -> impl Iterator<Item = (&'a Message, &'a PublicKey<E>)> + ExactSizeIterator { | ||||||
| self.messages_n_publickeys.iter() | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -161,8 +162,8 @@ mod tests { | |||||
| use crate::Keypair; | ||||||
| use crate::Message; | ||||||
| use crate::UsualBLS; | ||||||
| use rand::SeedableRng; | ||||||
| use rand::rngs::StdRng; | ||||||
| use rand::SeedableRng; | ||||||
|
|
||||||
| use ark_bls12_381::Bls12_381; | ||||||
|
|
||||||
|
|
@@ -172,8 +173,9 @@ mod tests { | |||||
| fn verify_aggregate_single_message_single_signer() { | ||||||
| let good = Message::new(b"ctx", b"test message"); | ||||||
|
|
||||||
| let mut keypair = | ||||||
| Keypair::<UsualBLS<Bls12_381, ark_bls12_381::Config>>::generate(StdRng::from_seed([0u8; 32])); | ||||||
| let mut keypair = Keypair::<UsualBLS<Bls12_381, ark_bls12_381::Config>>::generate( | ||||||
| StdRng::from_seed([0u8; 32]), | ||||||
| ); | ||||||
| let good_sig0 = keypair.sign(&good); | ||||||
| assert!(good_sig0.verify(&good, &keypair.public)); | ||||||
| } | ||||||
|
|
@@ -182,12 +184,14 @@ mod tests { | |||||
| fn verify_aggregate_single_message_multi_signers() { | ||||||
| let good = Message::new(b"ctx", b"test message"); | ||||||
|
|
||||||
| let mut keypair0 = | ||||||
| Keypair::<UsualBLS<Bls12_381, ark_bls12_381::Config>>::generate(StdRng::from_seed([0u8; 32])); | ||||||
| let mut keypair0 = Keypair::<UsualBLS<Bls12_381, ark_bls12_381::Config>>::generate( | ||||||
| StdRng::from_seed([0u8; 32]), | ||||||
| ); | ||||||
| let good_sig0 = keypair0.sign(&good); | ||||||
|
|
||||||
| let mut keypair1 = | ||||||
| Keypair::<UsualBLS<Bls12_381, ark_bls12_381::Config>>::generate(StdRng::from_seed([1u8; 32])); | ||||||
| let mut keypair1 = Keypair::<UsualBLS<Bls12_381, ark_bls12_381::Config>>::generate( | ||||||
| StdRng::from_seed([1u8; 32]), | ||||||
| ); | ||||||
| let good_sig1 = keypair1.sign(&good); | ||||||
|
|
||||||
| let mut aggregated_sigs = MultiMessageSignatureAggregatorAssumingPoP::< | ||||||
|
|
@@ -210,8 +214,9 @@ mod tests { | |||||
| let good0 = Message::new(b"ctx", b"Tab over Space"); | ||||||
| let good1 = Message::new(b"ctx", b"Space over Tab"); | ||||||
|
|
||||||
| let mut keypair = | ||||||
| Keypair::<UsualBLS<Bls12_381, ark_bls12_381::Config>>::generate(StdRng::from_seed([0u8; 32])); | ||||||
| let mut keypair = Keypair::<UsualBLS<Bls12_381, ark_bls12_381::Config>>::generate( | ||||||
| StdRng::from_seed([0u8; 32]), | ||||||
| ); | ||||||
|
|
||||||
| let good_sig0 = keypair.sign(&good0); | ||||||
| let good_sig1 = keypair.sign(&good1); | ||||||
|
|
@@ -236,12 +241,14 @@ mod tests { | |||||
| let good0 = Message::new(b"ctx", b"in the beginning"); | ||||||
| let good1 = Message::new(b"ctx", b"there was a flying spaghetti monster"); | ||||||
|
|
||||||
| let mut keypair0 = | ||||||
| Keypair::<UsualBLS<Bls12_381, ark_bls12_381::Config>>::generate(StdRng::from_seed([0u8; 32])); | ||||||
| let mut keypair0 = Keypair::<UsualBLS<Bls12_381, ark_bls12_381::Config>>::generate( | ||||||
| StdRng::from_seed([0u8; 32]), | ||||||
| ); | ||||||
| let good_sig0 = keypair0.sign(&good0); | ||||||
|
|
||||||
| let mut keypair1 = | ||||||
| Keypair::<UsualBLS<Bls12_381, ark_bls12_381::Config>>::generate(StdRng::from_seed([1u8; 32])); | ||||||
| let mut keypair1 = Keypair::<UsualBLS<Bls12_381, ark_bls12_381::Config>>::generate( | ||||||
| StdRng::from_seed([1u8; 32]), | ||||||
| ); | ||||||
| let good_sig1 = keypair1.sign(&good1); | ||||||
|
|
||||||
| let mut aggregated_sigs = MultiMessageSignatureAggregatorAssumingPoP::< | ||||||
|
|
@@ -263,8 +270,9 @@ mod tests { | |||||
| fn verify_aggregate_single_message_repetative_signers() { | ||||||
| let good = Message::new(b"ctx", b"test message"); | ||||||
|
|
||||||
| let mut keypair = | ||||||
| Keypair::<UsualBLS<Bls12_381, ark_bls12_381::Config>>::generate(StdRng::from_seed([0u8; 32])); | ||||||
| let mut keypair = Keypair::<UsualBLS<Bls12_381, ark_bls12_381::Config>>::generate( | ||||||
| StdRng::from_seed([0u8; 32]), | ||||||
| ); | ||||||
| let good_sig = keypair.sign(&good); | ||||||
|
|
||||||
| let mut aggregated_sigs = MultiMessageSignatureAggregatorAssumingPoP::< | ||||||
|
|
@@ -287,12 +295,14 @@ mod tests { | |||||
| let good0 = Message::new(b"ctx", b"Space over Tab"); | ||||||
| let bad1 = Message::new(b"ctx", b"Tab over Space"); | ||||||
|
|
||||||
| let mut keypair0 = | ||||||
| Keypair::<UsualBLS<Bls12_381, ark_bls12_381::Config>>::generate(StdRng::from_seed([0u8; 32])); | ||||||
| let mut keypair0 = Keypair::<UsualBLS<Bls12_381, ark_bls12_381::Config>>::generate( | ||||||
| StdRng::from_seed([0u8; 32]), | ||||||
| ); | ||||||
| let good_sig0 = keypair0.sign(&good0); | ||||||
|
|
||||||
| let mut keypair1 = | ||||||
| Keypair::<UsualBLS<Bls12_381, ark_bls12_381::Config>>::generate(StdRng::from_seed([1u8; 32])); | ||||||
| let mut keypair1 = Keypair::<UsualBLS<Bls12_381, ark_bls12_381::Config>>::generate( | ||||||
| StdRng::from_seed([1u8; 32]), | ||||||
| ); | ||||||
| let bad_sig1 = keypair1.sign(&bad1); | ||||||
|
|
||||||
| let mut aggregated_sigs = MultiMessageSignatureAggregatorAssumingPoP::< | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain me that how is replacing Once with ExactSizeIterator works?