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

Allow 1 input max 20 output #259

Merged
merged 1 commit into from
Apr 17, 2023
Merged
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
Binary file modified api/parameters/transfer-vk-specific.bin
Binary file not shown.
15 changes: 10 additions & 5 deletions api/src/gen-params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ use noah::setup::{
BulletproofParams, BulletproofURS, ProverParams, VerifierParams, VerifierParamsCommon,
VerifierParamsSplitCommon, ANON_XFR_BP_GENS_LEN,
MAX_ANONYMOUS_RECORD_NUMBER_CONSOLIDATION_RECEIVER,
MAX_ANONYMOUS_RECORD_NUMBER_CONSOLIDATION_SENDER, MAX_ANONYMOUS_RECORD_NUMBER_STANDARD,
MAX_ANONYMOUS_RECORD_NUMBER_CONSOLIDATION_SENDER, MAX_ANONYMOUS_RECORD_NUMBER_ONE_INPUT,
MAX_ANONYMOUS_RECORD_NUMBER_STANDARD,
};
use noah_algebra::bls12_381::BLSG1;
use noah_algebra::secq256k1::{PedersenCommitmentSecq256k1, Secq256k1BulletproofGens};
Expand Down Expand Up @@ -122,9 +123,13 @@ fn gen_transfer_vk(directory: PathBuf) {
let mut bytes: HashMap<usize, Vec<Vec<u8>>> = is
.par_iter()
.map(|i| {
let js: Vec<usize> = (1..=MAX_ANONYMOUS_RECORD_NUMBER_STANDARD)
.map(|j| j)
.collect();
let max_receiver = if *i == 1 {
MAX_ANONYMOUS_RECORD_NUMBER_ONE_INPUT
} else {
MAX_ANONYMOUS_RECORD_NUMBER_STANDARD
};

let js: Vec<usize> = (1..=max_receiver).map(|j| j).collect();
let mut bytes: HashMap<usize, Vec<u8>> = js
.par_iter()
.map(|j| {
Expand All @@ -139,7 +144,7 @@ fn gen_transfer_vk(directory: PathBuf) {
})
.collect();
let mut ordered = vec![];
for i in 1..=MAX_ANONYMOUS_RECORD_NUMBER_STANDARD {
for i in 1..=max_receiver {
ordered.push(bytes.remove(&i).unwrap())
}
(*i, ordered)
Expand Down
3 changes: 3 additions & 0 deletions api/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ pub const MAX_ANONYMOUS_RECORD_NUMBER_STANDARD: usize = 6;
pub const MAX_ANONYMOUS_RECORD_NUMBER_CONSOLIDATION_SENDER: usize = 8;
/// The maximal number of outputs supported by this setup program, for consolidation.
pub const MAX_ANONYMOUS_RECORD_NUMBER_CONSOLIDATION_RECEIVER: usize = 3;
/// The maximal number of outputs supported by this setup program, for airport.
pub const MAX_ANONYMOUS_RECORD_NUMBER_ONE_INPUT: usize = 20;
/// The default number of Bulletproofs generators
pub const DEFAULT_BP_NUM_GENS: usize = 256;
/// The number of the Bulletproofs(over the Secq256k1 curve) generators needed for anonymous transfer.
Expand Down Expand Up @@ -936,6 +938,7 @@ impl VerifierParams {
|| n_payers > MAX_ANONYMOUS_RECORD_NUMBER_STANDARD)
&& (n_payers > MAX_ANONYMOUS_RECORD_NUMBER_CONSOLIDATION_SENDER
|| n_payees > MAX_ANONYMOUS_RECORD_NUMBER_CONSOLIDATION_RECEIVER)
&& (n_payers > 1 || n_payees > MAX_ANONYMOUS_RECORD_NUMBER_ONE_INPUT)
{
Err(SimpleError::new(d!(NoahError::MissingVerifierParamsError), None).into())
} else {
Expand Down