feat(backend): Use Schnorr signatures for signed PODs (#236)
* Implement non-native extension field arithmetic * Schnorr signature verification (#221) * Use Schnorr signatures for signed PODs * add custom gates (#237) * Clippy * Formatting * Apply suggestions from code review Co-authored-by: Eduard S. <eduardsanou@posteo.net> * Fix typo * Fix tests * Point -> PublicKey * Remove default nnf_div implementation for clarity * Code review & edits for clarity * Remove suspicious mutation * Simplify computation * Fix division * Fix * Update src/backends/plonky2/primitives/ec/curve.rs Co-authored-by: Eduard S. <eduardsanou@posteo.net> * Update src/backends/plonky2/primitives/ec/curve.rs Co-authored-by: Eduard S. <eduardsanou@posteo.net> * Fixes * Add public key to signed POD struct * Style * Elaborate on in-circuit field->biguint conversion * Add missing gates * Comments * Add bits to biguint struct * Comments * Comment --------- Co-authored-by: Daniel Gulotta <dgulotta@alum.mit.edu> Co-authored-by: Eduard S. <eduardsanou@posteo.net>
This commit is contained in:
parent
541c264586
commit
c66506c048
22 changed files with 2995 additions and 456 deletions
|
|
@ -78,14 +78,19 @@ impl From<SignedPod> for SerializedSignedPod {
|
|||
impl From<SerializedSignedPod> for SignedPod {
|
||||
fn from(serialized: SerializedSignedPod) -> Self {
|
||||
match serialized.pod_type {
|
||||
SignedPodType::Signed => SignedPod {
|
||||
pod: Box::new(Plonky2SignedPod {
|
||||
id: serialized.id,
|
||||
signature: Plonky2SignedPod::decode_signature(&serialized.proof).unwrap(),
|
||||
dict: Dictionary::new(serialized.entries.clone()).unwrap(),
|
||||
}),
|
||||
kvs: serialized.entries,
|
||||
},
|
||||
SignedPodType::Signed => {
|
||||
let (signer, signature) =
|
||||
Plonky2SignedPod::decode_proof(&serialized.proof).unwrap();
|
||||
SignedPod {
|
||||
pod: Box::new(Plonky2SignedPod {
|
||||
id: serialized.id,
|
||||
signer,
|
||||
signature,
|
||||
dict: Dictionary::new(serialized.entries.clone()).unwrap(),
|
||||
}),
|
||||
kvs: serialized.entries,
|
||||
}
|
||||
}
|
||||
SignedPodType::MockSigned => SignedPod {
|
||||
pod: Box::new(MockSignedPod::new(
|
||||
serialized.id,
|
||||
|
|
@ -210,7 +215,7 @@ mod tests {
|
|||
backends::plonky2::{
|
||||
mainpod::Prover,
|
||||
mock::{mainpod::MockProver, signedpod::MockSigner},
|
||||
primitives::signature::SecretKey,
|
||||
primitives::ec::schnorr::SecretKey,
|
||||
signedpod::Signer,
|
||||
},
|
||||
examples::{
|
||||
|
|
@ -221,7 +226,7 @@ mod tests {
|
|||
middleware::{
|
||||
self,
|
||||
containers::{Array, Set},
|
||||
Params, RawValue, TypedValue,
|
||||
Params, TypedValue,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -309,7 +314,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_signed_pod_serialization() {
|
||||
let builder = signed_pod_builder();
|
||||
let mut signer = Signer(SecretKey(RawValue::from(1)));
|
||||
let mut signer = Signer(SecretKey(1u32.into()));
|
||||
let pod = builder.sign(&mut signer).unwrap();
|
||||
|
||||
let serialized = serde_json::to_string_pretty(&pod).unwrap();
|
||||
|
|
@ -377,11 +382,11 @@ mod tests {
|
|||
|
||||
let (gov_id_builder, pay_stub_builder, sanction_list_builder) =
|
||||
zu_kyc_sign_pod_builders(¶ms);
|
||||
let mut signer = Signer(SecretKey(RawValue::from(1)));
|
||||
let mut signer = Signer(SecretKey(1u32.into()));
|
||||
let gov_id_pod = gov_id_builder.sign(&mut signer)?;
|
||||
let mut signer = Signer(SecretKey(RawValue::from(2)));
|
||||
let mut signer = Signer(SecretKey(2u32.into()));
|
||||
let pay_stub_pod = pay_stub_builder.sign(&mut signer)?;
|
||||
let mut signer = Signer(SecretKey(RawValue::from(3)));
|
||||
let mut signer = Signer(SecretKey(3u32.into()));
|
||||
let sanction_list_pod = sanction_list_builder.sign(&mut signer)?;
|
||||
let kyc_builder =
|
||||
zu_kyc_pod_builder(¶ms, &gov_id_pod, &pay_stub_pod, &sanction_list_pod)?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue