Skip to content

Commit

Permalink
Merge pull request #10 from dfns-labs/udigest
Browse files Browse the repository at this point in the history
udigest support
  • Loading branch information
survived authored Nov 22, 2023
2 parents 8ada318 + 4a7f7e7 commit 31105a9
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 303 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
crate: cargo-rdme
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.STARK_CURVE_KEY }}
ssh-private-key: |
${{ secrets.STARK_CURVE_KEY }}
${{ secrets.UDIGEST_KEY }}
- name: Check that readme matches lib.rs
run: cargo rdme -w generic-ec -r README.md --check
8 changes: 6 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ jobs:
- uses: actions/checkout@v3
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.STARK_CURVE_KEY }}
ssh-private-key: |
${{ secrets.STARK_CURVE_KEY }}
${{ secrets.UDIGEST_KEY }}
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: "true"
Expand All @@ -41,7 +43,9 @@ jobs:
- uses: actions/checkout@v3
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.STARK_CURVE_KEY }}
ssh-private-key: |
${{ secrets.STARK_CURVE_KEY }}
${{ secrets.UDIGEST_KEY }}
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: "true"
Expand Down
4 changes: 2 additions & 2 deletions generic-ec-curves/src/rust_crypto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ impl<C, X> PartialEq for RustCryptoCurve<C, X> {
impl<C, X> Eq for RustCryptoCurve<C, X> {}

impl<C, X> PartialOrd for RustCryptoCurve<C, X> {
fn partial_cmp(&self, _other: &Self) -> Option<core::cmp::Ordering> {
Some(core::cmp::Ordering::Equal)
fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
Some(self.cmp(other))
}
}

Expand Down
5 changes: 3 additions & 2 deletions generic-ec-zkp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ edition = "2021"

[dependencies]
generic-ec = { path = "../generic-ec", default-features = false }
udigest = { git = "https://github.com/dfns-labs/udigest", branch = "m", features = ["derive"], optional = true }

subtle = "2.4"
digest = "0.10"
rand_core = "0.6"

serde = { version = "1", features = ["derive"], optional = true }
Expand All @@ -29,5 +29,6 @@ generic-ec = { path = "../generic-ec", default-features = false, features = ["al
[features]
default = ["std"]
std = ["alloc"]
alloc = []
alloc = ["udigest/alloc"]
serde = ["dep:serde", "generic-ec/serde", "generic-array/serde"]
udigest = ["dep:udigest", "generic-ec/udigest"]
288 changes: 0 additions & 288 deletions generic-ec-zkp/src/hash_commitment.rs

This file was deleted.

1 change: 0 additions & 1 deletion generic-ec-zkp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ extern crate alloc;
// We don't want this dependency to trigger unused dep lint
use generic_array as _;

pub mod hash_commitment;
pub mod polynomial;
pub mod schnorr_pok;
1 change: 1 addition & 0 deletions generic-ec-zkp/src/polynomial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ mod requires_alloc {
/// Polynomial is generic over type of coefficients `C`, it can be `Scalar<E>`, `NonZero<Scalar<E>>`, `SecretScalar<E>`, `Point<E>`,
/// or any other type that implements necessary traits.
#[derive(Debug, Clone)]
#[cfg_attr(feature = "udigest", derive(udigest::Digestable))]
pub struct Polynomial<C> {
/// `coefs[i]` is coefficient of `x^i` term
///
Expand Down
3 changes: 3 additions & 0 deletions generic-ec-zkp/src/schnorr_pok.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ use serde::{Deserialize, Serialize};
/// Committed prover ephemeral secret
#[derive(Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(bound = ""))]
#[cfg_attr(feature = "udigest", derive(udigest::Digestable), udigest(bound = ""))]
pub struct Commit<E: Curve>(pub Point<E>);

/// Prover ephemeral secret
Expand All @@ -99,6 +100,7 @@ pub struct ProverSecret<E: Curve> {
/// Challenge generated by verifier
#[derive(Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(bound = ""))]
#[cfg_attr(feature = "udigest", derive(udigest::Digestable), udigest(bound = ""))]
pub struct Challenge<E: Curve> {
pub nonce: Scalar<E>,
}
Expand All @@ -115,6 +117,7 @@ impl<E: Curve> Challenge<E> {
/// The proof that can convince $\V$ that $\P$ knows secret $x$
#[derive(Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(bound = ""))]
#[cfg_attr(feature = "udigest", derive(udigest::Digestable), udigest(bound = ""))]
pub struct Proof<E: Curve>(pub Scalar<E>);

impl<E: Curve> Proof<E> {
Expand Down
Loading

0 comments on commit 31105a9

Please sign in to comment.