Skip to content

Commit

Permalink
add melo-erasure-coding
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkingLee committed Jul 16, 2023
1 parent f01a865 commit 97aa567
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 1 deletion.
12 changes: 12 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
members = [
"node",
"primitives",
"crates/*",
"pallets/template",
"runtime",
]
Expand Down
30 changes: 30 additions & 0 deletions crates/melo-erasure-coding/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[package]
name = "melo-erasure-coding"
description = "Polynomial erasure coding implementation used in Melodot"
license = "Apache-2.0"
version = "0.1.0"
authors = ["DKLee <[email protected]>"]
edition = "2021"

[lib]
# Necessary for CLI options to work on benches
bench = false

[dependencies]
melo-primitives-crypto = { version = "0.1.0", path = "../../primitives", default-features = false }
rust-kzg-blst = { git = "https://github.com/sifraitech/rust-kzg", rev = "b416f2b", default-features = false }
kzg = { git = "https://github.com/sifraitech/rust-kzg", rev = "b416f2b", default-features = false }

[dev-dependencies]
rust-kzg-blst = { git = "https://github.com/sifraitech/rust-kzg", rev = "b416f2b"}
criterion = "0.4.0"
rand = "0.8.5"

[features]
default = ["std", "parallel"]
std = [
"rust-kzg-blst/std",
"kzg/std",
"melo-primitives-crypto/std",
]
parallel = ["rust-kzg-blst/parallel"]
30 changes: 30 additions & 0 deletions crates/melo-erasure-coding/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2023 ZeroDAO
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

extern crate alloc;

use alloc::sync::Arc;
use rust_kzg_blst::types::fft_settings::FsFFTSettings;

#[derive(Debug, Clone)]
pub struct ErasureCoding {
fft_settings: Arc<FsFFTSettings>,
}

impl ErasureCoding {
pub fn new(fft_settings: Arc<FsFFTSettings>) -> Self {
Self { fft_settings }
}

}
7 changes: 6 additions & 1 deletion primitives/src/kzg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use parity_scale_codec::{Decode, Encode, EncodeLike, Input, MaxEncodedLen};
use rust_kzg_blst::{
eip_4844::{
compute_blob_kzg_proof_rust, load_trusted_setup_filename_rust,
verify_blob_kzg_proof_batch_rust, verify_blob_kzg_proof_rust,
verify_blob_kzg_proof_batch_rust, verify_blob_kzg_proof_rust, blob_to_kzg_commitment_rust
},
types::{
fft_settings::FsFFTSettings, fr::FsFr, g1::FsG1, kzg_settings::FsKZGSettings, poly::FsPoly,
Expand Down Expand Up @@ -230,6 +230,11 @@ impl Blob {
})
.collect()
}

#[inline]
pub fn commit(&self, kzg: &KZG) -> KZGCommitment {
KZGCommitment(blob_to_kzg_commitment_rust(&self,&kzg.settings))
}
}

const TRUSTED_SETUP_FILENAME: &str = "eth-public-parameters.bin";
Expand Down

0 comments on commit 97aa567

Please sign in to comment.