Skip to content

Commit

Permalink
Ring proof compat layer for Edwards form pks (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
davxy authored May 30, 2024
1 parent 22c7bf6 commit 9344064
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 169 deletions.
8 changes: 4 additions & 4 deletions src/ietf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ impl<S: IetfSuite> ark_serialize::Valid for Proof<S> {
}
}

pub trait IetfProver<S: IetfSuite> {
pub trait Prover<S: IetfSuite> {
/// Generate a proof for the given input/output and user additional data.
fn prove(&self, input: Input<S>, output: Output<S>, ad: impl AsRef<[u8]>) -> Proof<S>;
}

pub trait IetfVerifier<S: IetfSuite> {
pub trait Verifier<S: IetfSuite> {
/// Verify a proof for the given input/output and user additional data.
fn verify(
&self,
Expand All @@ -85,7 +85,7 @@ pub trait IetfVerifier<S: IetfSuite> {
) -> Result<(), Error>;
}

impl<S: IetfSuite> IetfProver<S> for Secret<S> {
impl<S: IetfSuite> Prover<S> for Secret<S> {
fn prove(&self, input: Input<S>, output: Output<S>, ad: impl AsRef<[u8]>) -> Proof<S> {
let k = S::nonce(&self.scalar, input);
let k_b = (S::Affine::generator() * k).into_affine();
Expand All @@ -101,7 +101,7 @@ impl<S: IetfSuite> IetfProver<S> for Secret<S> {
}
}

impl<S: IetfSuite> IetfVerifier<S> for Public<S> {
impl<S: IetfSuite> Verifier<S> for Public<S> {
fn verify(
&self,
input: Input<S>,
Expand Down
7 changes: 5 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,16 @@ pub mod prelude {
pub use ark_std;
}

pub type ScalarField<S> = <<S as Suite>::Affine as AffineRepr>::ScalarField;
pub type BaseField<S> = <<S as Suite>::Affine as AffineRepr>::BaseField;
pub type AffinePoint<S> = <S as Suite>::Affine;

pub type BaseField<S> = <AffinePoint<S> as AffineRepr>::BaseField;
pub type ScalarField<S> = <AffinePoint<S> as AffineRepr>::ScalarField;
pub type CurveConfig<S> = <AffinePoint<S> as AffineRepr>::Config;

pub type HashOutput<S> = digest::Output<<S as Suite>::Hasher>;

/// Verification error(s)
#[derive(Debug)]
pub enum Error {
VerificationFailure,
}
Expand Down
8 changes: 4 additions & 4 deletions src/pedersen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl<S: PedersenSuite> Proof<S> {
}
}

pub trait PedersenProver<S: PedersenSuite> {
pub trait Prover<S: PedersenSuite> {
/// Generate a proof for the given input/output and user additional data.
///
/// Returns the proof together with the associated blinding factor.
Expand All @@ -32,7 +32,7 @@ pub trait PedersenProver<S: PedersenSuite> {
) -> (Proof<S>, ScalarField<S>);
}

pub trait PedersenVerifier<S: PedersenSuite> {
pub trait Verifier<S: PedersenSuite> {
/// Verify a proof for the given input/output and user additional data.
fn verify(
input: Input<S>,
Expand All @@ -42,7 +42,7 @@ pub trait PedersenVerifier<S: PedersenSuite> {
) -> Result<(), Error>;
}

impl<S: PedersenSuite> PedersenProver<S> for Secret<S> {
impl<S: PedersenSuite> Prover<S> for Secret<S> {
fn prove(
&self,
input: Input<S>,
Expand Down Expand Up @@ -81,7 +81,7 @@ impl<S: PedersenSuite> PedersenProver<S> for Secret<S> {
}
}

impl<S: PedersenSuite> PedersenVerifier<S> for Public<S> {
impl<S: PedersenSuite> Verifier<S> for Public<S> {
fn verify(
input: Input<S>,
output: Output<S>,
Expand Down
Loading

0 comments on commit 9344064

Please sign in to comment.