Skip to content
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

feat: support BLS (Boneh-Lynn-Shacham) signature #579

Merged
merged 17 commits into from
May 29, 2024
4 changes: 2 additions & 2 deletions .github/workflows/qaci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
- name: Run core browser tests
uses: coactions/setup-xvfb@v1
with:
run: cargo test -p rings-core --target=wasm32-unknown-unknown --features wasm --no-default-features
run: cargo test -p rings-core --release --target=wasm32-unknown-unknown --features wasm --no-default-features
working-directory: ./

- name: Run node browser tests
Expand All @@ -64,7 +64,7 @@ jobs:

build:
name: Build and test
timeout-minutes: 25
timeout-minutes: 30
strategy:
matrix:
os: ["ubuntu-latest"]
Expand Down
186 changes: 175 additions & 11 deletions Cargo.lock

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

5 changes: 5 additions & 0 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ browser_chrome_test = ["wasm"]

[dependencies]
# global
ark-bls12-381 = "0.4.0"
ark-ec = "0.4.2"
ark-ff = "0.4.2"
ark-serialize = "0.4.2"
ark-std = "0.4.0"
arrayref = "0.3.6"
async-lock = "2.5.0"
async-recursion = "1.0.0"
Expand Down
6 changes: 3 additions & 3 deletions crates/core/src/ecc/elgamal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub fn affine_to_str(a: &[Affine]) -> Result<String> {
field_to_str(a.iter().map(|x| x.x).collect::<Vec<Field>>().as_slice())
}

pub fn encrypt(s: &str, k: PublicKey) -> Result<Vec<(CurveEle, CurveEle)>> {
pub fn encrypt(s: &str, k: PublicKey<33>) -> Result<Vec<(CurveEle<33>, CurveEle<33>)>> {
let random_sar: Scalar = SecretKey::random().into();
let mut h: Affine = k.try_into()?;
h.y.normalize();
Expand All @@ -143,14 +143,14 @@ pub fn encrypt(s: &str, k: PublicKey) -> Result<Vec<(CurveEle, CurveEle)>> {
(a_c1, a_c2)
})
.collect();
let mut ret: Vec<(CurveEle, CurveEle)> = vec![];
let mut ret: Vec<(CurveEle<33>, CurveEle<33>)> = vec![];
for (c1, c2) in affines {
ret.push((c1.try_into()?, c2.try_into()?))
}
Ok(ret)
}

pub fn decrypt(m: &[(CurveEle, CurveEle)], k: SecretKey) -> Result<String> {
pub fn decrypt(m: &[(CurveEle<33>, CurveEle<33>)], k: SecretKey) -> Result<String> {
let sar: Scalar = k.into();
let cxt = ECMultContext::new_boxed();
affine_to_str(
Expand Down
Loading
Loading