Skip to content

Commit

Permalink
add CI
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Lodder <redmike7@gmail.com>
  • Loading branch information
mikelodder7 committed Oct 3, 2023
1 parent e9b9821 commit 015a347
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 27 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: anoncreds-v2-rs
on:
push:
branches:
- main
pull_request:
branches:
- main

env:
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: always
RUST_BACKTRACE: full
RUST_LOG: debug
RUST_LOG_STYLE: always

defaults:
run:
shell: bash

jobs:
lint:
runs-on: ubuntu-22.04
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
- name: Install latest stable
uses: actions-rs/toolchain@v1
with:
toolchain: 1.72.1
override: true
components: rustfmt, clippy

- name: Cache cargo resources
uses: Swatinem/rust-cache@v2

- name: Cargo check
run: cargo check

- name: Cargo format
run: cargo fmt --all -- --check

- name: Cargo clippy
run: cargo clippy -- -Dwarnings

test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install 1.72.1
uses: actions-rs/toolchain@v1
with:
toolchain: 1.72.1
override: true
components: rustfmt, clippy

- name: Cache cargo resources
uses: Swatinem/rust-cache@v2

- name: Cargo test
run: cargo test
28 changes: 28 additions & 0 deletions .github/workflows/security-audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Security Audit
on:
pull_request:
paths:
- Cargo.lock
- Cargo.toml
push:
branches:
- main
schedule:
- cron: "0 0 * * *"

jobs:
security_audit:
name: Security Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- uses: actions/cache@v3
with:
path: ~/.cargo/bin
key: ${{ runner.os }}-cargo-audit-v0.15.2
- uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
44 changes: 44 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: windows
on:
push:
branches:
- main
pull_request:
branches:
- main

env:
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: always
RUST_BACKTRACE: full
RUST_LOG: debug
RUST_LOG_STYLE: always

jobs:
test:
runs-on: windows-latest
name: (${{ matrix.target }}, ${{ matrix.cfg_release_channel }})
env:
CFG_RELEASE_CHANNEL: ${{ matrix.cfg_release_channel }}
strategy:
max-parallel: 2
fail-fast: false
matrix:
target: [i686-pc-windows-msvc, x86_64-pc-windows-msvc]
cfg_release_channel: 1.72.1
steps:
- name: Disable git eol translation
run: git config --global core.autocrlf false
- name: Checkout
run: actions/checkout@v3
- name: Install 1.72.1
run: |
$ProgressPreference = "SilentlyContinue"
Invoke-WebRequest https://win.rustup.rs/ -OutFile rustup-init.exe
.\rustup-init.exe -y --default-host=x86_64-pc-windows-msvc --default-toolchain=none
del rustup-init.exe
rustup target add ${{ matrix.target }}
shell: powershell

- name: Cargo test
run: cargo test
7 changes: 3 additions & 4 deletions src/claim/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,9 @@ impl ClaimData {
Ok(ClaimData::Number(NumberClaim { value }))
}
SCALAR => {
let value =
Option::<Scalar>::from(Scalar::from_be_hex(&s[4..])).ok_or_else(|| {
Error::InvalidClaimData("unable to deserialize scalar claim hex string")
})?;
let value = Option::<Scalar>::from(Scalar::from_be_hex(&s[4..])).ok_or({
Error::InvalidClaimData("unable to deserialize scalar claim hex string")
})?;
Ok(ClaimData::Scalar(ScalarClaim { value }))
}
REVOCATION => {
Expand Down
42 changes: 21 additions & 21 deletions src/knox/accumulator/vb20/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ impl MembershipProofCommitting {
pubkey: PublicKey,
) -> Self {
let message = y.get_message();
let mut rng = rand_core::OsRng;
let rng = rand_core::OsRng;
// Randomly select σ, ρ
let sigma = generate_fr(SALT, None, &mut rng);
let rho = generate_fr(SALT, None, &mut rng);
let sigma = generate_fr(SALT, None, rng);
let rho = generate_fr(SALT, None, rng);

// E_C = C + (σ + ρ)Z
let e_c = proof_params.z * (sigma + rho) + witness.0;
Expand All @@ -131,11 +131,11 @@ impl MembershipProofCommitting {
// Randomly pick r_σ,r_ρ,r_δσ,r_δρ
// r_y is either generated randomly or supplied in case this proof is used to
// bind to an external proof
let r_y = y.get_blinder(&mut rng).unwrap();
let r_sigma = generate_fr(SALT, None, &mut rng);
let r_rho = generate_fr(SALT, None, &mut rng);
let r_delta_sigma = generate_fr(SALT, None, &mut rng);
let r_delta_rho = generate_fr(SALT, None, &mut rng);
let r_y = y.get_blinder(rng).unwrap();
let r_sigma = generate_fr(SALT, None, rng);
let r_rho = generate_fr(SALT, None, rng);
let r_delta_sigma = generate_fr(SALT, None, rng);
let r_delta_rho = generate_fr(SALT, None, rng);

// R_σ = r_σ X
let cap_r_sigma = proof_params.x * r_sigma;
Expand Down Expand Up @@ -418,12 +418,12 @@ impl NonMembershipProofCommitting {
pubkey: PublicKey,
blinding_factor: Option<Element>,
) -> Self {
let mut rng = rand_core::OsRng;
let rng = rand_core::OsRng;
// Randomly pick r_σ,r_ρ,r_δσ,r_δρ

// Randomly select σ, ρ
let sigma = generate_fr(SALT, None, &mut rng);
let rho = generate_fr(SALT, None, &mut rng);
let sigma = generate_fr(SALT, None, rng);
let rho = generate_fr(SALT, None, rng);

// E_C = C + (σ + ρ)Z
let e_c = proof_params.z * (sigma + rho) + witness.c;
Expand All @@ -445,11 +445,11 @@ impl NonMembershipProofCommitting {
// bind to an external proof
let r_y = blinding_factor
.map(|bf| bf.into())
.unwrap_or_else(|| generate_fr(SALT, None, &mut rng));
let r_sigma = generate_fr(SALT, None, &mut rng);
let r_rho = generate_fr(SALT, None, &mut rng);
let r_delta_sigma = generate_fr(SALT, None, &mut rng);
let r_delta_rho = generate_fr(SALT, None, &mut rng);
.unwrap_or_else(|| generate_fr(SALT, None, rng));
let r_sigma = generate_fr(SALT, None, rng);
let r_rho = generate_fr(SALT, None, rng);
let r_delta_sigma = generate_fr(SALT, None, rng);
let r_delta_rho = generate_fr(SALT, None, rng);

// R_σ = r_σ X
let cap_r_sigma = proof_params.x * r_sigma;
Expand All @@ -464,8 +464,8 @@ impl NonMembershipProofCommitting {
let cap_r_delta_rho = cap_r(&[t_rho, -proof_params.y], &[r_y, r_delta_rho]);

// Randomly pick \tau, \pi
let tau = generate_fr(SALT, None, &mut rng);
let pi = generate_fr(SALT, None, &mut rng);
let tau = generate_fr(SALT, None, rng);
let pi = generate_fr(SALT, None, rng);

// E_d = d P + \tau K
let e_d = cap_r(
Expand All @@ -480,9 +480,9 @@ impl NonMembershipProofCommitting {
);

// Randomly pick r_u,r_v,r_w
let r_u = generate_fr(SALT, None, &mut rng);
let r_v = generate_fr(SALT, None, &mut rng);
let r_w = generate_fr(SALT, None, &mut rng);
let r_u = generate_fr(SALT, None, rng);
let r_v = generate_fr(SALT, None, rng);
let r_w = generate_fr(SALT, None, rng);

// R_A = r_u P + r_v K
let cap_r_a = cap_r(&[G1Projective::GENERATOR, proof_params.k], &[r_u, r_v]);
Expand Down
4 changes: 3 additions & 1 deletion src/knox/short_group_sig_core/proof_committed_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ mod test {
pb.commit(G1Projective::IDENTITY, Scalar::from(2u64));

pb.add_challenge_contribution(b"test", &mut transcript);
let proof = pb.generate_proof(challenge, &[Scalar::from(1337u64)]).unwrap();
let proof = pb
.generate_proof(challenge, &[Scalar::from(1337u64)])
.unwrap();
assert!(!proof.is_empty());
}
}
2 changes: 1 addition & 1 deletion tests/flow.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::time::Instant;
use blsful::inner_types::*;
use credx::blind::BlindCredentialRequest;
use credx::claim::{
Expand All @@ -23,6 +22,7 @@ use rand::thread_rng;
use rand_core::RngCore;
use regex::Regex;
use sha2;
use std::time::Instant;

#[test]
fn presentation_1_credential_works() {
Expand Down

0 comments on commit 015a347

Please sign in to comment.