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

Include layer index before node when creating label preimage. #1139

Merged
merged 1 commit into from
Jun 2, 2020

Conversation

porcuquine
Copy link
Collaborator

@porcuquine porcuquine commented Jun 2, 2020

This adds constraints, which slightly surprised me — since it does not increase the length of the preimage being hashed. I believe the reason for this is that the padding bits being replaced were in fact boolean constants. Some initial operations in the sha256 computation involving them may therefore have been optimized away at synthesis time.

UPDATE: I don't think my explanation above makes sense. I think the actual source of the increase is the booleanity constraints introduced when allocating the bits.

UPDATE 2: Although my update is accurate, there should not have been an allocation. The latest should now correctly use constants everywhere.

fn test_private_por_input_circuit_poseidon_oct() {
test_private_por_input_circuit::<TestTree<PoseidonHasher, typenum::U8>>(1_068);
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a missing test I added while I was editing circuit tests. It is not otherwise related to this PR.

@porcuquine porcuquine force-pushed the feat/layer-index-label branch 3 times, most recently from 038454f to ff97285 Compare June 2, 2020 07:56
@porcuquine
Copy link
Collaborator Author

I'm not sure why the seal lifecycle tests are failing on CI. With fresh groth parameters, they (at least 2Kib) pass locally for me. Maybe I accidentally reused a CI parameter cache key. Will poke at it more tomorrow.

@cryptonemo
Copy link
Collaborator

I'm not sure why the seal lifecycle tests are failing on CI. With fresh groth parameters, they (at least 2Kib) pass locally for me. Maybe I accidentally reused a CI parameter cache key. Will poke at it more tomorrow.

Yes, I also made that mistake, so v27c as a key has been burned first here: #1132 Then here: #1138

Go ahead and claim v27d and I'll update mine for things other than that.

@@ -16,7 +16,7 @@ use std::io::{self, SeekFrom};
use std::path::{Path, PathBuf};

/// Bump this when circuits change to invalidate the cache.
pub const VERSION: usize = 27;
pub const VERSION: usize = 28;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this requires a version bump here to 28?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this version shouldn’t change, only when we have published 27 and need to change sth

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmmm. I guess we have concretized a more recent policy. I'll go with that but note it means developers will more often get caught with stale parameters.

@@ -177,8 +182,15 @@ mod tests {
assert_eq!(cs.num_constraints(), 532_024);

let (l1, l2) = data.split_at_mut(size * NODE_SIZE);
super::super::super::vanilla::create_label_exp(&graph, &id_fr.into(), &*l2, l1, node)
.unwrap();
super::super::super::vanilla::create_label_exp(
Copy link
Contributor

@DrPeterVanNostrand DrPeterVanNostrand Jun 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super not cool. Maybe add use crate::stacked::vanilla::create_label_exp to the imports

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you mean Super not chocolate ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dammit, why did this change have to touch that line? @DrPeterVanNostrand I'll look into it.

@porcuquine porcuquine added the cryptocomputelab CryptoComputeLab work label Jun 2, 2020
@porcuquine porcuquine force-pushed the feat/layer-index-label branch 4 times, most recently from b1290c8 to c3ded18 Compare June 2, 2020 16:18
nicola
nicola previously approved these changes Jun 2, 2020
Copy link
Contributor

@nicola nicola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is adding correctly the layer as an constant input to create_label in a way that does not increase the sha input and does not any constraint

Copy link
Collaborator

@cryptonemo cryptonemo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@porcuquine porcuquine merged commit 13c7ac5 into master Jun 2, 2020
@porcuquine porcuquine deleted the feat/layer-index-label branch June 2, 2020 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cryptocomputelab CryptoComputeLab work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants