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

build: bump k256 to 0.13.2 #76

Merged
merged 9 commits into from
Dec 9, 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
Merge branch 'main' into bump-k256
skaunov authored Dec 9, 2023
commit 3bd10743a3fabb5eada709e1d75f2c7977b46ddb
25 changes: 11 additions & 14 deletions rust-k256/src/lib.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@
// #![allow(incomplete_features)]

use k256::{
// ecdsa::{signature::Signer, Signature, SigningKey},
elliptic_curve::hash2curve::{ExpandMsgXmd, GroupDigest},
elliptic_curve::ops::ReduceNonZero,
elliptic_curve::sec1::ToEncodedPoint,
@@ -91,24 +90,22 @@ impl PlumeSignature<'_> {
// c = hash2(g, g^sk, hash[m, g^sk], hash[m, pk]^sk, gr, hash[m, pk]^r)
pub fn verify_signals(&self) -> bool {
// don't forget to check `c` is `Output<Sha256>` in the #API
let c = Output::<Sha256>::from_slice(self.c);
let c = panic::catch_unwind(|| {Output::<Sha256>::from_slice(self.c);});
if c.is_err() {return false;}

// TODO should we allow `c` input greater than BaseField::MODULUS?
let c_scalar = &Scalar::reduce_nonzero(U256::from_be_byte_array(c.to_owned()));
/* @skaunov would be glad to discuss with @Divide-By-0 excessive of the following check.
Though I should notice that it at least doesn't breaking anything. */
if c_scalar.is_zero().into() {
return false;
}
// TODO `reduce_nonzero` doesn't seems to be correct here. `NonZeroScalar` should be appropriate.
let c_scalar = &Scalar::reduce_nonzero(U256::from_be_byte_array(c.unwrap().to_owned()));

let r_point = ProjectivePoint::GENERATOR * self.s - self.pk * &c_scalar;

let r_point = ProjectivePoint::GENERATOR * self.s - self.pk * c_scalar;
let hashed_to_curve = hash_to_curve(self.message, self.pk);
let hashed_to_curve_r = hashed_to_curve * self.s - self.nullifier * c_scalar;
if hashed_to_curve.is_err() {
return false;
}
let hashed_to_curve = hashed_to_curve.unwrap();

// Check if the given hash matches
let result = |components: Vec<&ProjectivePoint>| -> bool {
&c_sha256_vec_signal(components) == c
};
let hashed_to_curve_r = hashed_to_curve * self.s - self.nullifier * &c_scalar;

if let Some(PlumeSignatureV1Fields {
r_point: sig_r_point,
You are viewing a condensed version of this merge commit. You can view the full changes here.