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

Arkworks Elliptic Curve utils overhaul #1870

Merged
merged 6 commits into from
Oct 16, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Some bandersnatch-vrfs things are now copy
  • Loading branch information
davxy committed Oct 13, 2023
commit a82ed383aaa746095bf10d40f22722e45946d136
23 changes: 8 additions & 15 deletions substrate/primitives/core/src/bandersnatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,7 @@ pub mod vrf {
#[cfg(feature = "full_crypto")]
impl Pair {
fn vrf_sign_gen<const N: usize>(&self, data: &VrfSignData) -> VrfSignature {
let ios = core::array::from_fn(|i| {
let input = data.inputs[i].0.clone();
self.secret.vrf_inout(input)
});
let ios = core::array::from_fn(|i| self.secret.vrf_inout(data.inputs[i].0));

let thin_signature: ThinVrfSignature<N> =
self.secret.sign_thin_vrf(data.transcript.clone(), &ios);
Expand All @@ -559,7 +556,7 @@ pub mod vrf {
input: &VrfInput,
) -> [u8; N] {
let transcript = Transcript::new_labeled(context);
let inout = self.secret.vrf_inout(input.0.clone());
let inout = self.secret.vrf_inout(input.0);
inout.vrf_output_bytes(transcript)
}
}
Expand All @@ -575,7 +572,7 @@ pub mod vrf {
};

let preouts: [bandersnatch_vrfs::VrfPreOut; N] =
core::array::from_fn(|i| signature.outputs[i].0.clone());
core::array::from_fn(|i| signature.outputs[i].0);

// Deserialize only the proof, the rest has already been deserialized
// This is another hack used because backend signature type is generic over
Expand All @@ -588,7 +585,7 @@ pub mod vrf {
};
let signature = ThinVrfSignature { proof, preouts };

let inputs = data.inputs.iter().map(|i| i.0.clone());
let inputs = data.inputs.iter().map(|i| i.0);

public.verify_thin_vrf(data.transcript.clone(), inputs, &signature).is_ok()
}
Expand All @@ -602,8 +599,7 @@ pub mod vrf {
input: &VrfInput,
) -> [u8; N] {
let transcript = Transcript::new_labeled(context);
let inout =
bandersnatch_vrfs::VrfInOut { input: input.0.clone(), preoutput: self.0.clone() };
let inout = bandersnatch_vrfs::VrfInOut { input: input.0, preoutput: self.0 };
inout.vrf_output_bytes(transcript)
}
}
Expand Down Expand Up @@ -725,10 +721,7 @@ pub mod ring_vrf {
data: &VrfSignData,
prover: &RingProver,
) -> RingVrfSignature {
let ios = core::array::from_fn(|i| {
let input = data.inputs[i].0.clone();
self.secret.vrf_inout(input)
});
let ios = core::array::from_fn(|i| self.secret.vrf_inout(data.inputs[i].0));

let ring_signature: bandersnatch_vrfs::RingVrfSignature<N> =
bandersnatch_vrfs::RingProver { ring_prover: prover, secret: &self.secret }
Expand Down Expand Up @@ -784,12 +777,12 @@ pub mod ring_vrf {
};

let preouts: [bandersnatch_vrfs::VrfPreOut; N] =
core::array::from_fn(|i| self.outputs[i].0.clone());
core::array::from_fn(|i| self.outputs[i].0);

let signature =
bandersnatch_vrfs::RingVrfSignature { proof: vrf_signature.proof, preouts };

let inputs = data.inputs.iter().map(|i| i.0.clone());
let inputs = data.inputs.iter().map(|i| i.0);

bandersnatch_vrfs::RingVerifier(verifier)
.verify_ring_vrf(data.transcript.clone(), inputs, &signature)
Expand Down