-
Notifications
You must be signed in to change notification settings - Fork 297
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
feat: program refactor #651
Conversation
prover/src/lib.rs
Outdated
// TODO: this is very subject to change as groth16 e2e is stabilized | ||
// Convert pv.vkey_digest to a bn254 field element | ||
let vkey_hash = babybears_to_bn254(&pv.sp1_vk_digest); | ||
let mut vkey_hash = Bn254Fr::zero(); | ||
for (i, word) in pv.sp1_vk_digest.iter().enumerate() { | ||
if i == 0 { | ||
// Truncate top 3 bits | ||
vkey_hash = Bn254Fr::from_canonical_u32(word.as_canonical_u32() & 0x1fffffffu32); | ||
} else { | ||
vkey_hash *= Bn254Fr::from_canonical_u64(1 << 32); | ||
vkey_hash += Bn254Fr::from_canonical_u32(word.as_canonical_u32()); | ||
} | ||
} | ||
|
||
// Convert pv.committed_value_digest to a bn254 field element | ||
let committed_values_digest_bytes: [BabyBear; 32] = | ||
words_to_bytes(&pv.committed_value_digest) | ||
.try_into() | ||
.unwrap(); | ||
let committed_values_digest = babybear_bytes_to_bn254(&committed_values_digest_bytes); | ||
let mut committed_values_digest = Bn254Fr::zero(); | ||
for (i, word) in pv.committed_value_digest.iter().enumerate() { | ||
for (j, byte) in word.0.iter().enumerate() { | ||
if i == 0 && j == 0 { | ||
// Truncate top 3 bits | ||
committed_values_digest = | ||
Bn254Fr::from_canonical_u32(byte.as_canonical_u32() & 0x1f); | ||
} else { | ||
committed_values_digest *= Bn254Fr::from_canonical_u32(256); | ||
committed_values_digest += Bn254Fr::from_canonical_u32(byte.as_canonical_u32()); | ||
} | ||
} | ||
} |
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 code was moved out already, should be as it is in main
prover/src/lib.rs
Outdated
witness.commited_values_digest = committed_values_digest; | ||
witness.vkey_hash = vkey_hash; |
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 be as it was
let (shard_proofs, kinds) = | ||
batch.iter().cloned().unzip::<_, _, Vec<_>, Vec<_>>(); | ||
|
||
let input = SP1ReduceMemoryLayout { | ||
compress_vk: &self.compress_vk, | ||
recursive_machine: &self.compress_machine, | ||
shard_proofs, | ||
kinds, | ||
is_complete, | ||
}; | ||
|
||
let mut runtime = RecursionRuntime::<Val<InnerSC>, Challenge<InnerSC>, _>::new( | ||
&self.compress_program, | ||
self.compress_machine.config().perm.clone(), | ||
); | ||
|
||
let mut witness_stream = Vec::new(); | ||
witness_stream.extend(input.write()); | ||
|
||
runtime.witness_stream = witness_stream.into(); | ||
runtime.run(); | ||
runtime.print_stats(); | ||
|
||
let mut recursive_challenger = self.compress_machine.config().challenger(); | ||
let mut proof = self.compress_machine.prove::<LocalProver<_, _>>( | ||
&self.compress_pk, | ||
runtime.record, | ||
&mut recursive_challenger, | ||
); | ||
|
||
debug_assert_eq!(proof.shard_proofs.len(), 1); | ||
(proof.shard_proofs.pop().unwrap(), ReduceProgramType::Reduce) |
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.
shouldn't this be a call to verify_batch or some function
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.
LGTM
No description provided.