Skip to content

Commit

Permalink
Compatible with the latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
ImJeremyHe committed Oct 29, 2024
1 parent 2b046e0 commit 85cad75
Show file tree
Hide file tree
Showing 24 changed files with 1,416 additions and 160 deletions.
114 changes: 60 additions & 54 deletions arbitrator/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 42 additions & 1 deletion arbitrator/espresso-crypto-helper/src/hotshot_types.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use committable::{Commitment, Committable, RawCommitmentBuilder};
use std::ops::Range;
use tagged_base64::tagged;

use ark_bn254::Bn254;
use ark_serialize::CanonicalDeserialize;
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
use digest::OutputSizeUser;
use jf_pcs::{
prelude::UnivariateUniversalParams, univariate_kzg::UnivariateKzgPCS,
PolynomialCommitmentScheme,
Expand All @@ -16,6 +19,7 @@ use jf_vid::{
use lazy_static::lazy_static;
use serde::{Deserialize, Serialize};
use sha2::Sha256;
use typenum::Unsigned;

/// Private type alias for the EC pairing type parameter for [`Advz`].
type E = Bn254;
Expand All @@ -26,6 +30,43 @@ type Advz = advz::Advz<E, H>;

pub type VidCommitment = <VidSchemeType as VidScheme>::Commit;
pub type VidCommon = <VidSchemeType as VidScheme>::Common;
type Sha256Digest = [u8; <sha2::Sha256 as OutputSizeUser>::OutputSize::USIZE];

#[tagged("BUILDER_COMMITMENT")]
#[derive(Clone, Debug, Hash, PartialEq, Eq, CanonicalDeserialize, CanonicalSerialize)]
/// Commitment that builders use to sign block options.
/// A thin wrapper around a Sha256 digest.
pub struct BuilderCommitment(Sha256Digest);

impl AsRef<Sha256Digest> for BuilderCommitment {
fn as_ref(&self) -> &Sha256Digest {
&self.0
}
}

/// Type-safe wrapper around `u64` so we know the thing we're talking about is a view number.
#[derive(
Copy,
Clone,
Debug,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
Serialize,
Deserialize,
CanonicalSerialize,
CanonicalDeserialize,
)]
pub struct ViewNumber(pub u64);

impl Committable for ViewNumber {
fn commit(&self) -> Commitment<Self> {
let builder = RawCommitmentBuilder::new("View Number Commitment");
builder.u64(self.0).finalize()
}
}

pub struct VidSchemeType(Advz);

Expand Down
Loading

0 comments on commit 85cad75

Please sign in to comment.