Skip to content

Commit 1d60e9e

Browse files
nits
1 parent 71cb9b3 commit 1d60e9e

3 files changed

Lines changed: 19 additions & 164 deletions

File tree

consensus/src/marshal/coding/shards/engine.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -614,8 +614,12 @@ where
614614
};
615615
let participants_len = u64::try_from(scheme.participants().len())
616616
.expect("participant count impossibly out of bounds");
617-
let progressed =
618-
state.on_network_shard(peer, shard, InsertCtx::new(&scheme), &mut self.blocker);
617+
let progressed = state.on_network_shard(
618+
peer,
619+
shard,
620+
InsertCtx::new(scheme.as_ref()),
621+
&mut self.blocker,
622+
);
619623
if progressed {
620624
state = self
621625
.try_transition_state(commitment, participants_len, state)
@@ -905,7 +909,7 @@ where
905909
let mut progressed = false;
906910
let participants_len = u64::try_from(scheme.participants().len())
907911
.expect("participant count impossibly out of bounds");
908-
let ctx = InsertCtx::new(&scheme);
912+
let ctx = InsertCtx::new(scheme.as_ref());
909913
for (peer, shard) in buffered {
910914
progressed |= state.on_network_shard(peer, shard, ctx, &mut self.blocker);
911915
}

consensus/src/marshal/core/actor.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,8 +1318,12 @@ where
13181318
.iter()
13191319
.map(PendingVerification::as_subject_and_certificate)
13201320
.collect();
1321-
let verified =
1322-
verify_certificates(&mut context, &scheme, &cert_refs, &strategy);
1321+
let verified = verify_certificates(
1322+
&mut context,
1323+
scheme.as_ref(),
1324+
&cert_refs,
1325+
&strategy,
1326+
);
13231327
(delivers, verified)
13241328
});
13251329
let (returned, verified) = handle.await.expect("strategy task failed");
@@ -1351,8 +1355,12 @@ where
13511355
.iter()
13521356
.map(|&i| delivers[i].as_subject_and_certificate())
13531357
.collect();
1354-
let results =
1355-
verify_certificates(&mut context, &scheme, &group_refs, &strategy);
1358+
let results = verify_certificates(
1359+
&mut context,
1360+
scheme.as_ref(),
1361+
&group_refs,
1362+
&strategy,
1363+
);
13561364
(delivers, indices, results)
13571365
});
13581366
let (returned, indices, results) = handle.await.expect("strategy task failed");

cryptography/src/certificate.rs

Lines changed: 0 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -391,163 +391,6 @@ pub trait Scheme: Clone + Debug + Send + Sync + 'static {
391391
fn certificate_codec_config_unbounded() -> <Self::Certificate as Read>::Cfg;
392392
}
393393

394-
impl<S: Scheme> Scheme for Arc<S> {
395-
type Subject<'a, D: Digest> = S::Subject<'a, D>;
396-
type PublicKey = S::PublicKey;
397-
type Signature = S::Signature;
398-
type Certificate = S::Certificate;
399-
400-
fn me(&self) -> Option<Participant> {
401-
self.as_ref().me()
402-
}
403-
404-
fn participants(&self) -> &Set<Self::PublicKey> {
405-
self.as_ref().participants()
406-
}
407-
408-
fn sign<D: Digest>(&self, subject: Self::Subject<'_, D>) -> Option<Attestation<Self>> {
409-
self.as_ref().sign(subject).map(|attestation| Attestation {
410-
signer: attestation.signer,
411-
signature: attestation.signature,
412-
})
413-
}
414-
415-
fn verify_attestation<R, D>(
416-
&self,
417-
rng: &mut R,
418-
subject: Self::Subject<'_, D>,
419-
attestation: &Attestation<Self>,
420-
strategy: &impl Strategy,
421-
) -> bool
422-
where
423-
R: CryptoRngCore,
424-
D: Digest,
425-
{
426-
let attestation = Attestation::<S> {
427-
signer: attestation.signer,
428-
signature: attestation.signature.clone(),
429-
};
430-
self.as_ref()
431-
.verify_attestation(rng, subject, &attestation, strategy)
432-
}
433-
434-
fn verify_attestations<R, D, I>(
435-
&self,
436-
rng: &mut R,
437-
subject: Self::Subject<'_, D>,
438-
attestations: I,
439-
strategy: &impl Strategy,
440-
) -> Verification<Self>
441-
where
442-
R: CryptoRngCore,
443-
D: Digest,
444-
I: IntoIterator<Item = Attestation<Self>>,
445-
I::IntoIter: Send,
446-
{
447-
let Verification { verified, invalid } = self.as_ref().verify_attestations::<R, D, _>(
448-
rng,
449-
subject,
450-
attestations
451-
.into_iter()
452-
.map(|attestation| Attestation::<S> {
453-
signer: attestation.signer,
454-
signature: attestation.signature,
455-
}),
456-
strategy,
457-
);
458-
let verified = verified
459-
.into_iter()
460-
.map(|attestation| Attestation::<Self> {
461-
signer: attestation.signer,
462-
signature: attestation.signature,
463-
})
464-
.collect();
465-
Verification::new(verified, invalid)
466-
}
467-
468-
fn assemble<I, M>(&self, attestations: I, strategy: &impl Strategy) -> Option<Self::Certificate>
469-
where
470-
I: IntoIterator<Item = Attestation<Self>>,
471-
I::IntoIter: Send,
472-
M: Faults,
473-
{
474-
self.as_ref().assemble::<_, M>(
475-
attestations
476-
.into_iter()
477-
.map(|attestation| Attestation::<S> {
478-
signer: attestation.signer,
479-
signature: attestation.signature,
480-
}),
481-
strategy,
482-
)
483-
}
484-
485-
fn verify_certificate<R, D, M>(
486-
&self,
487-
rng: &mut R,
488-
subject: Self::Subject<'_, D>,
489-
certificate: &Self::Certificate,
490-
strategy: &impl Strategy,
491-
) -> bool
492-
where
493-
R: CryptoRngCore,
494-
D: Digest,
495-
M: Faults,
496-
{
497-
self.as_ref()
498-
.verify_certificate::<_, _, M>(rng, subject, certificate, strategy)
499-
}
500-
501-
fn verify_certificates<'a, R, D, I, M>(
502-
&self,
503-
rng: &mut R,
504-
certificates: I,
505-
strategy: &impl Strategy,
506-
) -> bool
507-
where
508-
R: CryptoRngCore,
509-
D: Digest,
510-
I: Iterator<Item = (Self::Subject<'a, D>, &'a Self::Certificate)>,
511-
M: Faults,
512-
{
513-
self.as_ref()
514-
.verify_certificates::<R, D, I, M>(rng, certificates, strategy)
515-
}
516-
517-
fn verify_certificates_bisect<'a, R, D, M>(
518-
&self,
519-
rng: &mut R,
520-
certificates: &[(Self::Subject<'a, D>, &'a Self::Certificate)],
521-
strategy: &impl Strategy,
522-
) -> Vec<bool>
523-
where
524-
R: CryptoRngCore,
525-
D: Digest,
526-
Self::Subject<'a, D>: Copy,
527-
Self::Certificate: 'a,
528-
M: Faults,
529-
{
530-
self.as_ref()
531-
.verify_certificates_bisect::<R, D, M>(rng, certificates, strategy)
532-
}
533-
534-
fn is_attributable() -> bool {
535-
S::is_attributable()
536-
}
537-
538-
fn is_batchable() -> bool {
539-
S::is_batchable()
540-
}
541-
542-
fn certificate_codec_config(&self) -> <Self::Certificate as Read>::Cfg {
543-
self.as_ref().certificate_codec_config()
544-
}
545-
546-
fn certificate_codec_config_unbounded() -> <Self::Certificate as Read>::Cfg {
547-
S::certificate_codec_config_unbounded()
548-
}
549-
}
550-
551394
/// Supplies the signing scheme for a given scope.
552395
///
553396
/// This trait uses an associated `Scope` type, allowing implementations to work

0 commit comments

Comments
 (0)