Skip to content

Commit

Permalink
Allow 1 input max 20 output (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
weikengchen authored Apr 17, 2023
1 parent e499629 commit 7f8c030
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
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

0 comments on commit 7f8c030

Please sign in to comment.