-
Notifications
You must be signed in to change notification settings - Fork 95
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
Include chunked phase2 script #439
base: phase2
Are you sure you want to change the base?
Conversation
cargo $CARGO_VER build --release --bin setup2 | ||
|
||
phase2_new="cargo run --release --features cli -- new --curve-type $CURVE --chunk-size $CHUNK_SIZE --batch-size $BATCH --contribution-mode full" | ||
phase2_chunked="cargo run --release --bin setup2 --features cli -- --curve-type $CURVE --chunk-size $CHUNK_SIZE --batch-size $BATCH --contribution-mode full --proving-system $PROVING_SYSTEM" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should come with an argument for the binary, right? That is, one of new
, contribute
, etc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we're still missing the seed
and the proving_system
in the related struct (edit: and possibly more judging by the rest of the script, and assuming it is correct).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The command is actually specified lower in the script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emmorais are these commands currently complete?
phase2_1="cargo run --release --bin setup2 --features cli -- --curve-type $CURVE --batch-size $BATCH --contribution-mode chunked --chunk-size $CHUNK_SIZE --seed seed1 --proving-system $PROVING_SYSTEM" | ||
phase2_2="cargo run --release --bin setup2 --features cli -- --curve-type $CURVE --batch-size $BATCH --contribution-mode chunked --chunk-size $CHUNK_SIZE --seed seed2 --proving-system $PROVING_SYSTEM" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for these two?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
774524c
to
f7cd635
Compare
UseCompression::Yes, | ||
CheckForCorrectness::Full, | ||
UseCompression::No, | ||
CheckForCorrectness::No, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we've already checked the output of Phase1, then we don't need to check for correctness, which makes the preparation step faster. This should be re-enabled if we did not check that the output of Phase 1 is in the appropriate prime-order group.
if input.len() > 10 { | ||
let mut input = input | ||
.par_iter() | ||
.map(|(coeff, lag)| { | ||
let ind = match *lag { | ||
Index::Public(i) => i, | ||
Index::Private(i) => num_inputs + i, | ||
}; | ||
sum += coeffs[ind].mul(coeff).into_projective(); | ||
sum | ||
}, | ||
) | ||
.reduce(|| C::Projective::zero(), |a, b| a + b) | ||
(coeff, ind) | ||
}) | ||
.collect::<Vec<_>>(); | ||
input.sort_unstable_by(|a, b| a.1.cmp(&b.1)); | ||
let input = input | ||
.into_par_iter() | ||
.map(|(coeff, _)| coeff.to_repr()) | ||
.collect::<Vec<_>>(); | ||
snarkvm_algorithms::msm::variable_base::VariableBaseMSM::multi_scalar_mul(coeffs, &input) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dot product can be computed quickly using a variable base MSM. We do this if input.len()
is large enough.
let mut points: Vec<_> = cfg_iter!(bases) | ||
.map(|base| base.into_projective().mul(*coeff)) | ||
.map(|base| base.mul_bits(BitIteratorBE::new(coeff))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change ensures that we use mixed addition, which makes the multiplication slightly faster.
let address = Address::try_from(private_key)?.to_string(); | ||
|
||
let message = format!("{} {}", method.to_lowercase(), path.to_lowercase()); | ||
let signature = hex::encode(&view_key.sign(message.as_bytes(), rng)?.to_bytes_le()?); | ||
let signature = hex::encode(&private_key.sign(message.as_bytes(), rng)?.to_bytes_le()?); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: is this change warranted? Not sure if this breaks things (did the address scheme change since the code was written?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @howardwu
let private_key = PrivateKey::<Testnet2>::from_str(signing_key)?; | ||
let signature = hex::encode(&private_key.sign(message.as_bytes(), rng)?.to_bytes_le()?); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
Update: in the latest commit, the error that Eduardo encountered is no longer present, so the |
In the latest commit, most tests are passing, except some tests in To get the tests passing, I can sample a new |
This may need a rebase after #448 is merged. |
Merged |
Ongoing work. Currently getting the following error: