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:
Ahmad Afuni 2025-06-10 00:24:16 +10:00 committed by GitHub
parent 541c264586
commit c66506c048
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 2995 additions and 456 deletions

View file

@ -27,7 +27,9 @@ pub use operation::*;
use serialization::*;
pub use statement::*;
use crate::backends::plonky2::primitives::merkletree::MerkleProof;
use crate::backends::plonky2::primitives::{
ec::curve::Point as PublicKey, merkletree::MerkleProof,
};
pub const SELF: PodId = PodId(SELF_ID_HASH);
@ -56,6 +58,8 @@ pub enum TypedValue {
),
// Uses the serialization for middleware::Value:
Raw(RawValue),
// Public key variant
PublicKey(PublicKey),
// UNTAGGED TYPES:
#[serde(untagged)]
Array(Array),
@ -95,6 +99,12 @@ impl From<Hash> for TypedValue {
}
}
impl From<PublicKey> for TypedValue {
fn from(p: PublicKey) -> Self {
TypedValue::PublicKey(p)
}
}
impl From<Set> for TypedValue {
fn from(s: Set) -> Self {
TypedValue::Set(s)
@ -159,6 +169,7 @@ impl fmt::Display for TypedValue {
TypedValue::Set(s) => write!(f, "set:{}", s.commitment()),
TypedValue::Array(a) => write!(f, "arr:{}", a.commitment()),
TypedValue::Raw(v) => write!(f, "{}", v),
TypedValue::PublicKey(p) => write!(f, "ecGFp5_pt:({},{})", p.x, p.u),
}
}
}
@ -173,6 +184,7 @@ impl From<&TypedValue> for RawValue {
TypedValue::Set(s) => RawValue::from(s.commitment()),
TypedValue::Array(a) => RawValue::from(a.commitment()),
TypedValue::Raw(v) => *v,
TypedValue::PublicKey(p) => RawValue::from(hash_fields(&p.as_fields())),
}
}
}