Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions circuits/bin/dkg/Nargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
[workspace]
members = [
"pk",
"sk_share_computation",
"e_sm_share_computation",
"share_encryption",
"share_decryption",
]
"sk_share_computation_base",
"esm_share_computation_base",
"share_computation_chunk",
]

7 changes: 0 additions & 7 deletions circuits/bin/dkg/e_sm_share_computation/Nargo.toml

This file was deleted.

1 change: 0 additions & 1 deletion circuits/bin/dkg/e_sm_share_computation/README.md

This file was deleted.

29 changes: 0 additions & 29 deletions circuits/bin/dkg/e_sm_share_computation/src/main.nr

This file was deleted.

7 changes: 7 additions & 0 deletions circuits/bin/dkg/esm_share_computation_base/Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "esm_share_computation_base"
type = "bin"
authors = [""]

[dependencies]
lib = { path = "../../../lib" }
27 changes: 27 additions & 0 deletions circuits/bin/dkg/esm_share_computation_base/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: LGPL-3.0-only
//
// This file is provided WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE.

use lib::configs::default::dkg::{
L_THRESHOLD, N, SHARE_COMPUTATION_CHUNK_SIZE, SHARE_COMPUTATION_E_SM_BASE_CONFIGS,
SHARE_COMPUTATION_E_SM_BIT_SECRET, SHARE_COMPUTATION_N_CHUNKS,
};
use lib::configs::default::{N_PARTIES, T};
use lib::core::dkg::share_computation::base::SmudgingNoiseShareComputationBase;
use lib::math::polynomial::Polynomial;

fn main(
expected_secret_commitment: pub Field,
e_sm_secret: [Polynomial<N>; L_THRESHOLD],
y: [[[Field; N_PARTIES + 1]; L_THRESHOLD]; N],
) -> pub ([Field; SHARE_COMPUTATION_N_CHUNKS], [[Field; L_THRESHOLD]; N_PARTIES]) {
let circuit: SmudgingNoiseShareComputationBase<N, L_THRESHOLD, N_PARTIES, T, SHARE_COMPUTATION_E_SM_BIT_SECRET, SHARE_COMPUTATION_CHUNK_SIZE, SHARE_COMPUTATION_N_CHUNKS> = SmudgingNoiseShareComputationBase::new(
SHARE_COMPUTATION_E_SM_BASE_CONFIGS,
expected_secret_commitment,
e_sm_secret,
y,
);
circuit.execute()
}
7 changes: 7 additions & 0 deletions circuits/bin/dkg/share_computation_chunk/Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "share_computation_chunk"
type = "bin"
authors = [""]

[dependencies]
lib = { path = "../../../lib" }
27 changes: 27 additions & 0 deletions circuits/bin/dkg/share_computation_chunk/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: LGPL-3.0-only
//
// This file is provided WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE.

use lib::configs::default::dkg::{
L_THRESHOLD, PARITY_MATRIX, SHARE_COMPUTATION_BIT_SHARE, SHARE_COMPUTATION_CHUNK_SIZE,
SHARE_COMPUTATION_SK_CHUNK_CONFIGS,
};
use lib::configs::default::{N_PARTIES, T};
use lib::core::dkg::share_computation::chunk::ShareComputationChunk;

global CHUNK_IDX: u32 = 0; // change per chunk main

fn main(
chunk_commitment: pub Field,
y_chunk: [[[Field; N_PARTIES + 1]; L_THRESHOLD]; SHARE_COMPUTATION_CHUNK_SIZE],
) {
let circuit: ShareComputationChunk<L_THRESHOLD, N_PARTIES, T, SHARE_COMPUTATION_BIT_SHARE, SHARE_COMPUTATION_CHUNK_SIZE, CHUNK_IDX> = ShareComputationChunk::new(
SHARE_COMPUTATION_SK_CHUNK_CONFIGS,
chunk_commitment,
y_chunk,
PARITY_MATRIX,
);
circuit.execute()
}
8 changes: 0 additions & 8 deletions circuits/bin/dkg/sk_share_computation/Nargo.toml

This file was deleted.

1 change: 0 additions & 1 deletion circuits/bin/dkg/sk_share_computation/README.md

This file was deleted.

29 changes: 0 additions & 29 deletions circuits/bin/dkg/sk_share_computation/src/main.nr

This file was deleted.

7 changes: 7 additions & 0 deletions circuits/bin/dkg/sk_share_computation_base/Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "sk_share_computation_base"
type = "bin"
authors = [""]

[dependencies]
lib = { path = "../../../lib" }
27 changes: 27 additions & 0 deletions circuits/bin/dkg/sk_share_computation_base/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: LGPL-3.0-only
//
// This file is provided WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE.

use lib::configs::default::dkg::{
L_THRESHOLD, N, SHARE_COMPUTATION_CHUNK_SIZE, SHARE_COMPUTATION_N_CHUNKS,
SHARE_COMPUTATION_SK_BASE_CONFIGS, SHARE_COMPUTATION_SK_BIT_SECRET,
};
use lib::configs::default::{N_PARTIES, T};
use lib::core::dkg::share_computation::base::SecretKeyShareComputationBase;
use lib::math::polynomial::Polynomial;

fn main(
expected_secret_commitment: pub Field,
sk_secret: Polynomial<N>,
y: [[[Field; N_PARTIES + 1]; L_THRESHOLD]; N],
) -> pub ([Field; SHARE_COMPUTATION_N_CHUNKS], [[Field; L_THRESHOLD]; N_PARTIES]) {
let sk_share_computation_base: SecretKeyShareComputationBase<N, L_THRESHOLD, N_PARTIES, T, SHARE_COMPUTATION_SK_BIT_SECRET, SHARE_COMPUTATION_CHUNK_SIZE, SHARE_COMPUTATION_N_CHUNKS> = SecretKeyShareComputationBase::new(
SHARE_COMPUTATION_SK_BASE_CONFIGS,
expected_secret_commitment,
sk_secret,
y,
);
sk_share_computation_base.execute()
}
23 changes: 16 additions & 7 deletions circuits/lib/src/configs/insecure/dkg.nr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

use crate::configs::default::{N_PARTIES, T};
pub use crate::configs::insecure::threshold::{L as L_THRESHOLD, QIS as QIS_THRESHOLD};
use crate::core::dkg::share_computation::Configs as ShareComputationConfigs;
use crate::core::dkg::share_computation::base::Configs as ShareComputationBaseConfigs;
use crate::core::dkg::share_computation::chunk::Configs as ShareComputationChunkConfigs;
use crate::core::dkg::share_encryption::Configs as ShareEncryptionConfigs;

// Global configs for DKG insecure preset
Expand Down Expand Up @@ -49,9 +50,15 @@ share_computation_sk (CIRCUIT 2a)
pub global SHARE_COMPUTATION_BIT_SHARE: u32 = 36;
pub global SHARE_COMPUTATION_SK_BIT_SECRET: u32 = 1;

// share_computation_sk - configs
pub global SHARE_COMPUTATION_SK_CONFIGS: ShareComputationConfigs<L_THRESHOLD> =
ShareComputationConfigs::new(QIS_THRESHOLD);
// With N=512 and 5 parties, a single chunk covers all coefficients
pub global SHARE_COMPUTATION_CHUNK_SIZE: u32 = 512;
pub global SHARE_COMPUTATION_N_CHUNKS: u32 = 1; // N / CHUNK_SIZE = 512 / 512

pub global SHARE_COMPUTATION_SK_BASE_CONFIGS: ShareComputationBaseConfigs<L_THRESHOLD> =
ShareComputationBaseConfigs::new(QIS_THRESHOLD);

pub global SHARE_COMPUTATION_SK_CHUNK_CONFIGS: ShareComputationChunkConfigs<L_THRESHOLD> =
ShareComputationChunkConfigs::new(QIS_THRESHOLD);

/************************************
-------------------------------------
Expand All @@ -62,9 +69,11 @@ share_computation_e_sm (CIRCUIT 2b)
// share_computation_e_sm - bit parameters
pub global SHARE_COMPUTATION_E_SM_BIT_SECRET: u32 = 24;

// verify_shares - configs
pub global SHARE_COMPUTATION_E_SM_CONFIGS: ShareComputationConfigs<L_THRESHOLD> =
ShareComputationConfigs::new(QIS_THRESHOLD);
pub global SHARE_COMPUTATION_E_SM_BASE_CONFIGS: ShareComputationBaseConfigs<L_THRESHOLD> =
ShareComputationBaseConfigs::new(QIS_THRESHOLD);

pub global SHARE_COMPUTATION_E_SM_CHUNK_CONFIGS: ShareComputationChunkConfigs<L_THRESHOLD> =
ShareComputationChunkConfigs::new(QIS_THRESHOLD);

/************************************
-------------------------------------
Expand Down
27 changes: 18 additions & 9 deletions circuits/lib/src/configs/secure/dkg.nr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

use crate::configs::default::{N_PARTIES, T};
pub use crate::configs::secure::threshold::{L as L_THRESHOLD, QIS as QIS_THRESHOLD};
use crate::core::dkg::share_computation::Configs as ShareComputationConfigs;
use crate::core::dkg::share_computation::base::Configs as ShareComputationBaseConfigs;
use crate::core::dkg::share_computation::chunk::Configs as ShareComputationChunkConfigs;
use crate::core::dkg::share_encryption::Configs as ShareEncryptionConfigs;

// Global configs for DKG secure preset
Expand Down Expand Up @@ -55,27 +56,35 @@ share_computation_sk (CIRCUIT 2a)
-------------------------------------
************************************/

// share_computation_sk - bit parameters
pub global SHARE_COMPUTATION_BIT_SHARE: u32 = 53;
pub global SHARE_COMPUTATION_SK_BIT_SECRET: u32 = 1;

// share_computation_sk - configs
pub global SHARE_COMPUTATION_SK_CONFIGS: ShareComputationConfigs<L_THRESHOLD> =
ShareComputationConfigs::new(QIS_THRESHOLD);
// Chunk size controls circuit size vs number of chunks tradeoff.
// N_CHUNKS = N / CHUNK_SIZE
// At 5 parties: CHUNK_SIZE=512, N_CHUNKS=16
// At 50 parties: reduce CHUNK_SIZE to keep chunk circuit constant size
pub global SHARE_COMPUTATION_CHUNK_SIZE: u32 = 512;
// N / CHUNK_SIZE = 8192 / 512 =1 6
pub global SHARE_COMPUTATION_N_CHUNKS: u32 = 16;
pub global SHARE_COMPUTATION_SK_BASE_CONFIGS: ShareComputationBaseConfigs<L_THRESHOLD> =
ShareComputationBaseConfigs::new(QIS_THRESHOLD);

pub global SHARE_COMPUTATION_SK_CHUNK_CONFIGS: ShareComputationChunkConfigs<L_THRESHOLD> =
ShareComputationChunkConfigs::new(QIS_THRESHOLD);

/************************************
-------------------------------------
share_computation_e_sm (CIRCUIT 2b)
-------------------------------------
************************************/

// share_computation_e_sm - bit parameters
pub global SHARE_COMPUTATION_E_SM_BIT_SECRET: u32 = 192;

// verify_shares - configs
pub global SHARE_COMPUTATION_E_SM_CONFIGS: ShareComputationConfigs<L_THRESHOLD> =
ShareComputationConfigs::new(QIS_THRESHOLD);
pub global SHARE_COMPUTATION_E_SM_BASE_CONFIGS: ShareComputationBaseConfigs<L_THRESHOLD> =
ShareComputationBaseConfigs::new(QIS_THRESHOLD);

pub global SHARE_COMPUTATION_E_SM_CHUNK_CONFIGS: ShareComputationChunkConfigs<L_THRESHOLD> =
ShareComputationChunkConfigs::new(QIS_THRESHOLD);
/************************************
-------------------------------------
share_encryption_sk (CIRCUIT 3a)
Expand Down
Loading
Loading