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

Update supported Python versions #171

Merged
merged 10 commits into from
Jan 23, 2024
54 changes: 18 additions & 36 deletions .github/workflows/workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
components: clippy
override: true
profile: minimal
components: clippy, rustfmt
- uses: actions/cache@v3
continue-on-error: false
with:
Expand All @@ -39,10 +37,7 @@ jobs:
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- run: cargo clippy --all --all-features -- -D warnings
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- run: cargo fmt --all -- --check
- name: Install cargo-machete
uses: baptiste0928/cargo-install@v1
with:
Expand All @@ -66,12 +61,10 @@ jobs:
rust: stable
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
targets: ${{ matrix.target }}
- uses: actions/cache@v3
continue-on-error: false
with:
Expand Down Expand Up @@ -100,12 +93,10 @@ jobs:
- wasm32-unknown-unknown
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
targets: ${{ matrix.target }}
- run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- run: wasm-pack test --node
working-directory: ferveo-wasm
Expand All @@ -120,12 +111,10 @@ jobs:
- wasm32-unknown-unknown
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
targets: ${{ matrix.target }}
- run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- run: wasm-pack build --target nodejs
working-directory: ferveo-wasm
Expand All @@ -148,6 +137,7 @@ jobs:
target:
- wasm32-unknown-unknown
python:
- "3.11"
- "3.12"
steps:
- uses: actions/checkout@v3
Expand All @@ -156,12 +146,10 @@ jobs:
python-version: ${{ matrix.python }}

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
targets: ${{ matrix.target }}

- name: Install Ferveo Python package
run: pip install -e .
Expand Down Expand Up @@ -195,12 +183,10 @@ jobs:
needs: [ test ]
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@v1
with:
profile: minimal
toolchain: stable
target: x86_64-unknown-linux-gnu
override: true
targets: x86_64-unknown-linux-gnu
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
# Only checking the coverage of the main library,
Expand All @@ -219,12 +205,10 @@ jobs:
needs: [ test ]
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@v1
with:
profile: minimal
toolchain: stable
target: x86_64-unknown-linux-gnu
override: true
targets: x86_64-unknown-linux-gnu
- name: Compile benchmarks
run: cargo bench --no-run --no-default-features

Expand All @@ -244,12 +228,10 @@ jobs:
- tpke
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@v1
with:
profile: minimal
toolchain: nightly
target: x86_64-unknown-linux-gnu
override: true
targets: x86_64-unknown-linux-gnu
- uses: actions/cache@v3
continue-on-error: false
with:
Expand Down
34 changes: 34 additions & 0 deletions Cargo.lock

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

2 changes: 0 additions & 2 deletions ferveo-python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
"Programming Language :: Rust",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Security :: Cryptography",
Expand Down
2 changes: 1 addition & 1 deletion ferveo-tdec/benches/tpke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ pub fn bench_create_decryption_share(c: &mut Criterion) {
.map(|ctx| {
// Using create_unchecked here to avoid the cost of verifying the ciphertext
DecryptionShareSimple::create_unchecked(
&ctx.validator_private_key,
&ctx.setup_params.b,
&ctx.private_key_share,
&setup.shared.ciphertext.header().unwrap(),
)
Expand Down
8 changes: 3 additions & 5 deletions ferveo-tdec/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct PublicDecryptionContextSimple<E: Pairing> {

#[derive(Clone, Debug)]
pub struct SetupParams<E: Pairing> {
pub b: E::ScalarField,
pub b: E::ScalarField, // Validator private key
pub b_inv: E::ScalarField,
pub g: E::G1Affine,
pub g_inv: E::G1Prepared,
Expand Down Expand Up @@ -71,8 +71,6 @@ pub struct PrivateDecryptionContextSimple<E: Pairing> {
pub setup_params: SetupParams<E>,
pub private_key_share: PrivateKeyShare<E>,
pub public_decryption_contexts: Vec<PublicDecryptionContextSimple<E>>,
// TODO: Remove/replace with `setup_params.b` after refactoring
pub validator_private_key: E::ScalarField,
}

impl<E: Pairing> PrivateDecryptionContextSimple<E> {
Expand All @@ -82,7 +80,7 @@ impl<E: Pairing> PrivateDecryptionContextSimple<E> {
aad: &[u8],
) -> Result<DecryptionShareSimple<E>> {
DecryptionShareSimple::create(
&self.validator_private_key,
&self.setup_params.b,
&self.private_key_share,
ciphertext_header,
aad,
Expand All @@ -104,7 +102,7 @@ impl<E: Pairing> PrivateDecryptionContextSimple<E> {

DecryptionSharePrecomputed::new(
self.index,
&self.validator_private_key,
&self.setup_params.b,
&self.private_key_share,
ciphertext_header,
aad,
Expand Down
1 change: 0 additions & 1 deletion ferveo-tdec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ pub mod test_common {
h,
},
private_key_share,
validator_private_key: b,
public_decryption_contexts: vec![],
});
public_contexts.push(PublicDecryptionContextSimple::<E> {
Expand Down
24 changes: 8 additions & 16 deletions ferveo-wasm/examples/node/src/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@ const genEthAddr = (i: number) => {
return EthereumAddress.fromString(ethAddr);
};

function setupTest() {
const tau = 1;
const sharesNum = 4;
const threshold = Math.floor((sharesNum * 2) / 3);

const tau = 1;
function setupTest(sharesNum :number, threshold: number) {
const validatorKeypairs: Keypair[] = [];
const validators: Validator[] = [];
for (let i = 0; i < sharesNum; i++) {
Expand Down Expand Up @@ -63,9 +60,6 @@ function setupTest() {
const ciphertext = ferveoEncrypt(msg, aad, dkg.publicKey());

return {
tau,
sharesNum,
threshold,
validatorKeypairs,
validators,
dkg,
Expand All @@ -79,17 +73,16 @@ function setupTest() {
// This test suite replicates tests from ferveo-wasm/tests/node.rs
describe("ferveo-wasm", () => {
it("simple tdec variant", () => {
const sharesNum = 4;
const threshold = 3;
const {
tau,
sharesNum,
threshold,
validatorKeypairs,
validators,
messages,
msg,
aad,
ciphertext,
} = setupTest();
} = setupTest(sharesNum, threshold);

// Having aggregated the transcripts, the validators can now create decryption shares
const decryptionShares: DecryptionShareSimple[] = [];
Expand Down Expand Up @@ -128,17 +121,16 @@ describe("ferveo-wasm", () => {
});

it("precomputed tdec variant", () => {
const sharesNum = 4;
const threshold = sharesNum; // threshold is equal to sharesNum in precomputed variant
const {
tau,
sharesNum,
threshold,
validatorKeypairs,
validators,
messages,
msg,
aad,
ciphertext,
} = setupTest();
} = setupTest(sharesNum, threshold);

// Having aggregated the transcripts, the validators can now create decryption shares
const decryptionShares: DecryptionSharePrecomputed[] = [];
Expand Down
Loading
Loading