Skip to content

Commit

Permalink
chore: add new erasure_codes crate
Browse files Browse the repository at this point in the history
  • Loading branch information
kevaundray committed May 27, 2024
1 parent 304c483 commit 217a733
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/release-rust-crates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ jobs:
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_RELEASE_TOKEN }}

- name: Publish erasure_codes
run: |
cargo publish --package crate_crypto_internal_peerdas_erasure_codes
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_RELEASE_TOKEN }}

- name: Publish kzg_multi_open
run: |
cargo publish --package crate_crypto_kzg_multi_open_fk20
Expand Down
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ members = [
"eip7594",
"kzg_multi_open",
"polynomial",
"erasure_codes",
]

resolver = "2"
Expand All @@ -27,6 +28,7 @@ repository = "https://github.com/crate-crypto/peerdas-kzg"
# all dependencies to be published and not local.
bls12_381 = { package = "crate_crypto_internal_peerdas_bls12_381", version = "0.3.0", path = "bls12_381" }
polynomial = { package = "crate_crypto_internal_peerdas_polynomial", version = "0.3.0", path = "polynomial" }
erasure_codes = { package = "crate_crypto_internal_peerdas_erasure_codes", version = "0.3.0", path = "erasure_codes" }
eip7594 = { version = "0.3.0", path = "eip7594" }
kzg_multi_open = { package = "crate_crypto_kzg_multi_open_fk20", version = "0.3.0", path = "kzg_multi_open" }
c_peerdas_kzg = { version = "0.3.0", path = "bindings/c" }
Expand Down
13 changes: 13 additions & 0 deletions erasure_codes/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "crate_crypto_internal_peerdas_erasure_codes"
description = "This crate provides an implementation of erasure encoding and decoding"
version = { workspace = true }
authors = { workspace = true }
edition = { workspace = true }
license = { workspace = true }
rust-version = { workspace = true }
repository = { workspace = true }

[dependencies]
bls12_381 = { workspace = true }
polynomial = { workspace = true }
3 changes: 3 additions & 0 deletions erasure_codes/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub mod reed_solomon;

pub use reed_solomon::ReedSolomon;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use bls12_381::{batch_inversion::batch_inverse, Scalar};

use crate::{domain::Domain, monomial::vanishing_poly};
use bls12_381::ff::Field;
use polynomial::{domain::Domain, monomial::vanishing_poly};

// The erasures can be either indices of the polynomial
// or groups of indices
Expand Down Expand Up @@ -160,7 +160,7 @@ fn smoke_test_recovery() {
#[test]
fn smoke_test_recovery_no_errors() {
let rs = ReedSolomon::new(16, 2);
let poly_coeff = vec![Scalar::random(&mut rand::thread_rng()); 15];
let poly_coeff: Vec<_> = (0..15).map(|i| -Scalar::from(i)).collect();

let codewords = rs.encode(poly_coeff);
assert_eq!(codewords.len(), 32);
Expand Down

0 comments on commit 217a733

Please sign in to comment.