Skip to content

Commit

Permalink
2 compiling errors
Browse files Browse the repository at this point in the history
  • Loading branch information
emmorais committed Oct 24, 2024
1 parent 49ab6be commit 4488e65
Show file tree
Hide file tree
Showing 6 changed files with 226 additions and 40 deletions.
17 changes: 14 additions & 3 deletions src/presign/participant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ use crate::{
zkp::{
piaffg::{PiAffgInput, PiAffgProof, PiAffgSecret},
pienc::{PiEncInput, PiEncProof, PiEncSecret},
pilog::{CommonInput, PiLogProof, ProverSecret},
pilog::{CommonInput, PiLogProof, ProverSecret, SerdePoint},
Proof, ProofContext,
},
Identifier,
};
use generic_ec::curves::Secp256k1;
use libpaillier::unknown_order::BigNumber;
use merlin::Transcript;
use rand::{CryptoRng, RngCore};
Expand Down Expand Up @@ -1040,6 +1041,14 @@ impl PresignKeyShareAndInfo {

let g = CurvePoint::GENERATOR;
let Gamma = g.multiply_by_bignum(&sender_r1_priv.gamma)?;
// create SerdePoint from Gamma
//let serdeGamma = SerdePoint::<generic_ec::curves::Secp256k1> {
//point: generic_ec::curves::Secp256k1::point::from_bytes(Gamma.to_bytes()),
//point: <generic_ec_curves::rust_crypto::RustCryptoCurve<Secp256k1, ExpandMsgXmd<CoreWrapper<CtVariableCoreWrapper<Sha256VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, OidSha256>>>> as Example>::point::from_bytes(Gamma.to_bytes()),
//};
//let serdeGamma = SerdePoint::new(point_from_bytes(Gamma.to_bytes()));
let serdeGamma = SerdePoint::from_curve_point(Gamma);
let serdeg: SerdePoint<Secp256k1> = SerdePoint::from_curve_point(g);

// Generate the proofs.
let mut transcript = Transcript::new(b"PiAffgProof");
Expand Down Expand Up @@ -1081,7 +1090,7 @@ impl PresignKeyShareAndInfo {
let psi_prime = PiLogProof::prove(
CommonInput::new(
&sender_r1_priv.G,
&Gamma,
&serdeGamma,
receiver_aux_info.params().scheme(),
self.aux_info_public.pk(),
&g,
Expand Down Expand Up @@ -1166,6 +1175,8 @@ impl PresignKeyShareAndInfo {
}

let Delta = Gamma.multiply_by_bignum(&sender_r1_priv.k)?;
let serdeDelta = SerdePoint::from_curve_point(Delta);
let serdeGamma: SerdePoint<Secp256k1> = SerdePoint::from_curve_point(Gamma);

let delta_scalar = bn_to_scalar(&delta)?;
let chi_scalar = bn_to_scalar(&chi)?;
Expand All @@ -1176,7 +1187,7 @@ impl PresignKeyShareAndInfo {
let psi_double_prime = PiLogProof::prove(
CommonInput::new(
&sender_r1_priv.K,
&Delta,
&serdeDelta,
round_three_input.auxinfo_public.params().scheme(),
self.aux_info_public.pk(),
&Gamma,
Expand Down
5 changes: 3 additions & 2 deletions src/presign/round_three.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::{
},
utils::CurvePoint,
zkp::{
pilog::{CommonInput, PiLogProof},
pilog::{CommonInput, PiLogProof, SerdePoint},
Proof,
},
};
Expand Down Expand Up @@ -83,9 +83,10 @@ impl Public {
prover_r1_public_broadcast: &RoundOnePublicBroadcast,
) -> Result<()> {
let mut transcript = Transcript::new(b"PiLogProof");
let deltaSerde = SerdePoint::from_curve_point(self.Delta);
let psi_double_prime_input = CommonInput::new(
&prover_r1_public_broadcast.K,
&self.Delta,
&deltaSerde,
verifier_auxinfo_public.params().scheme(),
prover_auxinfo_public.pk(),
&self.Gamma,
Expand Down
5 changes: 3 additions & 2 deletions src/presign/round_two.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::{
utils::CurvePoint,
zkp::{
piaffg::{PiAffgInput, PiAffgProof},
pilog::{CommonInput, PiLogProof},
pilog::{CommonInput, PiLogProof, SerdePoint},
Proof,
},
};
Expand Down Expand Up @@ -107,9 +107,10 @@ impl Public {
.verify(psi_hat_input, context, &mut transcript)?;

// Verify the psi_prime proof
let Gamma = SerdePoint::from_curve_point(self.Gamma);
let psi_prime_input = CommonInput::new(
&prover_r1_public_broadcast.G,
&self.Gamma,
&Gamma,
verifier_auxinfo_public.params().scheme(),
prover_auxinfo_public.pk(),
&g,
Expand Down
11 changes: 11 additions & 0 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ impl From<CurvePoint> for EncodedPoint {
fn from(value: CurvePoint) -> EncodedPoint {
value.0.to_affine().into()
}

}

impl AsRef<CurvePoint> for CurvePoint {
Expand All @@ -49,6 +50,16 @@ impl AsRef<CurvePoint> for CurvePoint {
}

impl CurvePoint {
// new
pub fn new(value: k256::ProjectivePoint) -> Self {
Self(value)
}

// return the wrapped point
pub fn inner_value(&self) -> k256::ProjectivePoint {
self.0
}

pub fn x_affine(&self) -> FieldBytes {
self.0.to_affine().x()
}
Expand Down
2 changes: 1 addition & 1 deletion src/zkp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub(crate) mod pisch;
use crate::errors::Result;
use merlin::Transcript;
use rand::{CryptoRng, RngCore};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use serde::{de::DeserializeOwned, Serialize};

/// A trait for constructing arbitrary system context.
///
Expand Down
Loading

0 comments on commit 4488e65

Please sign in to comment.