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

Update integer crates to pre-release v0.6 #120

Merged
merged 80 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
f86f435
Attempt 2
dvdplm May 21, 2024
7891be5
Second iteration on the traits, and Signed and Bounded types
dvdplm May 22, 2024
bae4dd9
Relax bounds and cleanup Bounded<T>
dvdplm May 22, 2024
ba3c7ab
Relax bounds and cleanup of Signed<T>
dvdplm May 22, 2024
5cb00fb
Moar cleanup of Signed<T>
dvdplm May 22, 2024
f797a59
Instantiate U512Mod and the other sizes
dvdplm May 27, 2024
2b86c3e
Import the UxxxMod types
dvdplm May 27, 2024
168d47c
Start sorting out PaillierParams
dvdplm May 27, 2024
40db0c1
Add a neg() method to Signed – unclear if this is the right thing to do
dvdplm May 27, 2024
66e062b
Start sorting out the Paillier keys
dvdplm May 27, 2024
d37500a
Implement pow_signed and pow_signed_vartime
dvdplm May 29, 2024
045f2b0
Implement Neg for Signed<T>
dvdplm May 29, 2024
d641efc
Remove the ConditionallyNegatable impl for Signed
dvdplm May 30, 2024
9805814
Add a new ToMod trait to provide the to_mod method
dvdplm May 30, 2024
8e65579
Low hanging fruit paillier/
dvdplm May 30, 2024
7e61d5a
More low-hanging fruit in cggmp21
dvdplm May 30, 2024
0711859
Implement pow_bounded as a free standing function
dvdplm May 30, 2024
c3b37a4
Impl pow_signed_wide as free standing fn
dvdplm May 31, 2024
c5327e6
Impl pow_signed_extra_wide
dvdplm May 31, 2024
26dd709
Impl pow_signed_vartime
dvdplm May 31, 2024
99f0c7a
Switch to pre-relase version of k256
dvdplm Jun 3, 2024
d40fef5
Rename from_xof to uint_from_xof
dvdplm Jun 3, 2024
94510ac
Add clones where needed
dvdplm Jun 3, 2024
1d1ecfa
Switch to HybridArray
dvdplm Jun 3, 2024
b285d3d
ECDSA signatures changed a bit in the latest
dvdplm Jun 3, 2024
3b30e3b
Add the clones. Sigh.
dvdplm Jun 3, 2024
58ae16a
Cleanup
dvdplm Jun 3, 2024
939c47b
Add note to self
dvdplm Jun 3, 2024
2af6086
Sort out serde bounds after wrapping in `Odd`
dvdplm Jun 3, 2024
8a666c2
Merge branch 'master' into dp-update-crypto-bigint-104
dvdplm Jun 3, 2024
c050473
Sort out const NonZero construction with to_nz()
dvdplm Jun 4, 2024
b251a3e
Handle change in bits_vartime retval
dvdplm Jun 4, 2024
5d4e67a
Revert making PublicKeyPaillier.modulus an `Odd`
dvdplm Jun 4, 2024
23a5e05
Fix test failure in SecretKeyPaillier.to_precomputed
dvdplm Jun 5, 2024
04771c2
PaillierParams::HalUint needs ToMod as well
dvdplm Jun 5, 2024
3090602
Silence some warnings
dvdplm Jun 5, 2024
10b2f8c
cleanup
dvdplm Jun 5, 2024
520e324
Update HasWide to accomodate the upstream changes when splitting Uint…
dvdplm Jun 5, 2024
98f574e
Remove unused dependency
dvdplm Jun 21, 2024
3867029
Some docs and new todos
dvdplm Jun 21, 2024
52310c2
Better wording
dvdplm Jun 21, 2024
8c06b64
Update dependencies
dvdplm Jul 29, 2024
c6e1850
Consolidate traits and remove the to_mod impl in Signed (not used)
dvdplm Jul 29, 2024
1f4d76e
Consolidate imports
dvdplm Jul 29, 2024
0dff552
Merge branch 'master' into dp-update-crypto-bigint-104
dvdplm Jul 30, 2024
bf05cea
Vendor HashingSerializer
dvdplm Jul 30, 2024
860473f
Silence a few warnings
dvdplm Jul 31, 2024
87b06a3
Move the `misc` module into `uint`
dvdplm Jul 31, 2024
532a0fd
Remove the `HasWide` requirement for `ExtraWideUint` and the matching…
dvdplm Jul 31, 2024
fd0024f
Remove dead code from the Chain trait
dvdplm Jul 31, 2024
2c0e9be
Remove vendored hashing_serializer and patch it with upstream fix
dvdplm Jul 31, 2024
1bbacb8
Removing vendored module
dvdplm Jul 31, 2024
445108d
Tests for `Signed::neg(self)` (and some docs)
dvdplm Aug 1, 2024
a126a72
Add a todo
dvdplm Aug 2, 2024
088cc64
Add CheckedSub impl for Signed (with tests)
dvdplm Aug 2, 2024
30844a5
Merge branch 'master' into dp-update-crypto-bigint-104
dvdplm Aug 5, 2024
05f4ab1
Clean up dev deps
dvdplm Aug 5, 2024
196ee9a
Resolve a todo: displaydoc is updated
dvdplm Aug 5, 2024
ba0714a
Resolved todo: displaydoc is updated
dvdplm Aug 5, 2024
259df78
Normalize asserts and make sure we panic if bounds are OoB
dvdplm Aug 6, 2024
2d39288
More tests for Signed
dvdplm Aug 6, 2024
65fc99e
Add tests for PartialOrd on Signed
dvdplm Aug 6, 2024
834bcf9
Add tests to Bounded to illustrate the behaviour
dvdplm Aug 6, 2024
37044c7
Cleanup stale TODOs
dvdplm Aug 7, 2024
312f9ba
Move uint_from_xof
dvdplm Aug 19, 2024
f4f71c1
Move `pow_*` to a new `uint::pow` module
dvdplm Aug 19, 2024
b02782a
Adding pow.rs file
dvdplm Aug 19, 2024
d6a40fc
Proper justifications for `expect`s
dvdplm Aug 19, 2024
144e4f8
Rename ToMod –> ToMontgomery
dvdplm Aug 20, 2024
dd1f41c
Bump a few versions
dvdplm Aug 22, 2024
3131879
Revert PartialEq impl to use the derive instead. Implies strict boun…
dvdplm Aug 22, 2024
32c99d9
Merge branch 'master' into dp-update-crypto-bigint-104
dvdplm Aug 27, 2024
35a4244
Use pre-release version of hashing-serializer
dvdplm Aug 28, 2024
62ec55b
Fix wasm build?
dvdplm Aug 29, 2024
02705b8
review feedback
dvdplm Sep 16, 2024
a5466de
Patch `ecdsa` version
dvdplm Sep 16, 2024
0d8f528
Tweak wording
dvdplm Sep 18, 2024
28da60b
Bump deps
dvdplm Sep 23, 2024
d3854bc
Missed a feature
dvdplm Sep 23, 2024
9087df3
Update bip32
dvdplm Sep 23, 2024
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
3 changes: 0 additions & 3 deletions rust-toolchain.toml

This file was deleted.

30 changes: 17 additions & 13 deletions synedrion/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,38 @@ readme = "README.md"
categories = ["cryptography", "no-std"]

[dependencies]
signature = { version = "2", default-features = false, features = ["alloc"] }
k256 = { version = "0.13.2", default-features = false, features = ["ecdsa", "arithmetic"] }
rand_core = { version = "0.6.4", default-features = false }
sha2 = { version = "0.10", default-features = false }
sha3 = { version = "0.10", default-features = false }
digest = { version = "0.10", default-features = false, features = ["alloc"]}
signature = { version = "2.3.0-pre.4", default-features = false, features = ["alloc"] }
k256 = {version = "0.14.0-pre.2", default-features = false, features = ["ecdsa", "arithmetic"]}
rand_core = { version = "0.6.4", default-features = false, features = ["getrandom"] }
sha2 = { version = "0.11.0-pre.4", default-features = false }
sha3 = { version = "0.11.0-pre.4", default-features = false }
digest = { version = "0.11.0-pre.9", default-features = false, features = ["alloc"]}
hex = { version = "0.4", default-features = false, features = ["alloc"] }
base64 = { version = "0.21", default-features = false, features = ["alloc"] }
hashing-serializer = { version = "0.1", default-features = false }
base64 = { version = "0.22.1", default-features = false, features = ["alloc"] }
hashing-serializer = { version = "0.2.0-pre.0", default-features = false }
secrecy = { version = "0.9.0-pre.0", default-features = false, features = ["serde"] }
zeroize = { version = "1.8", default-features = false, features = ["alloc", "zeroize_derive"] }
bip32 = { version = "0.5.2", default-features = false, features = ["alloc", "secp256k1"] }
bip32 = { version = "0.6.0-pre.0", default-features = false, features = ["alloc", "secp256k1", "k256"] }

# Note: `alloc` is needed for `crytpto-bigint`'s dependency `serdect` to be able
# to serialize Uints in human-readable formats.
crypto-bigint = { version = "0.5.3", default-features = false, features = ["serde", "alloc"] }
crypto-primes = { version = "0.5", default-features = false }
crypto-bigint = { version = "0.6.0-rc.3", features = ["serde", "alloc", "rand_core"] }
dvdplm marked this conversation as resolved.
Show resolved Hide resolved
crypto-primes = "0.6.0-pre.0"

serde = { version = "1", default-features = false, features = ["derive"] }
bincode = { version = "2.0.0-rc.3", default-features = false, features = ["serde", "alloc"] }
displaydoc = { version = "0.2", default-features = false}

# Note: needed for the `rand_core` feature of `crypto-bigint`.
[target.wasm32-unknown-unknown.dependencies]
getrandom = { version = "0.2", features = ["js"]}

[dev-dependencies]
tokio = { version = "1", features = ["rt", "sync", "time", "macros"] }
rand = "0.8"
rand_chacha = "0.3"
criterion = "0.5"
hex = "0.4"
k256 = { version = "0.13.2", default-features = false, features = ["ecdsa", "serde", "pem"] }
k256 = {version = "0.14.0-pre.2", default-features = false, features = ["ecdsa", "arithmetic", "pem", "serde"]}
impls = "1"

[features]
Expand Down
14 changes: 7 additions & 7 deletions synedrion/src/cggmp21/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub trait SchemeParams: Debug + Clone + Send + PartialEq + Eq + Send + Sync + 's
/// Converts a curve scalar to the associated integer type.
fn uint_from_scalar(value: &Scalar) -> <Self::Paillier as PaillierParams>::Uint {
let scalar_bytes = value.to_bytes();
let mut repr = <Self::Paillier as PaillierParams>::Uint::ZERO.to_be_bytes();
let mut repr = <Self::Paillier as PaillierParams>::Uint::zero().to_be_bytes();

let uint_len = repr.as_ref().len();
let scalar_len = scalar_bytes.len();
Expand All @@ -113,8 +113,8 @@ pub trait SchemeParams: Debug + Clone + Send + PartialEq + Eq + Send + Sync + 's

/// Converts a curve scalar to the associated integer type, wrapped in `Bounded`.
fn bounded_from_scalar(value: &Scalar) -> Bounded<<Self::Paillier as PaillierParams>::Uint> {
const ORDER_BITS: usize = ORDER.bits_vartime();
Bounded::new(Self::uint_from_scalar(value), ORDER_BITS as u32).unwrap()
const ORDER_BITS: u32 = ORDER.bits_vartime();
Bounded::new(Self::uint_from_scalar(value), ORDER_BITS).unwrap()
}

/// Converts a curve scalar to the associated integer type, wrapped in `Signed`.
Expand Down Expand Up @@ -187,9 +187,9 @@ impl SchemeParams for TestParams {
const EPS_BOUND: usize = 320;
type Paillier = PaillierTest;
const CURVE_ORDER: NonZero<<Self::Paillier as PaillierParams>::Uint> =
NonZero::<<Self::Paillier as PaillierParams>::Uint>::const_new(upcast_uint(ORDER)).0;
upcast_uint(ORDER).to_nz().expect("Correct by construction");
const CURVE_ORDER_WIDE: NonZero<<Self::Paillier as PaillierParams>::WideUint> =
NonZero::<<Self::Paillier as PaillierParams>::WideUint>::const_new(upcast_uint(ORDER)).0;
upcast_uint(ORDER).to_nz().expect("Correct by construction");
}

/// Production strength parameters.
Expand All @@ -203,7 +203,7 @@ impl SchemeParams for ProductionParams {
const EPS_BOUND: usize = Self::L_BOUND * 2;
type Paillier = PaillierProduction;
const CURVE_ORDER: NonZero<<Self::Paillier as PaillierParams>::Uint> =
NonZero::<<Self::Paillier as PaillierParams>::Uint>::const_new(upcast_uint(ORDER)).0;
upcast_uint(ORDER).to_nz().expect("Correct by construction");
const CURVE_ORDER_WIDE: NonZero<<Self::Paillier as PaillierParams>::WideUint> =
NonZero::<<Self::Paillier as PaillierParams>::WideUint>::const_new(upcast_uint(ORDER)).0;
upcast_uint(ORDER).to_nz().expect("Correct by construction");
}
4 changes: 2 additions & 2 deletions synedrion/src/cggmp21/protocols/aux_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::rounds::{
};
use crate::tools::bitvec::BitVec;
use crate::tools::hashing::{Chain, FofHasher, HashOutput};
use crate::uint::UintLike;
use crypto_bigint::BitOps;

/// Possible results of the AuxGen protocol.
#[derive(Debug, Clone, Copy)]
Expand Down Expand Up @@ -305,7 +305,7 @@ impl<P: SchemeParams, I: Debug + Clone + Ord + Serialize> Round<I> for Round2<P,

let paillier_pk = broadcast_msg.data.paillier_pk.to_precomputed();

if paillier_pk.modulus().bits_vartime() < 8 * P::SECURITY_PARAMETER {
if (paillier_pk.modulus().bits_vartime() as usize) < 8 * P::SECURITY_PARAMETER {
return Err(AuxGenError(AuxGenErrorEnum::Round2(
"Paillier modulus is too small".into(),
)));
Expand Down
13 changes: 8 additions & 5 deletions synedrion/src/cggmp21/protocols/key_refresh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use crate::rounds::{
};
use crate::tools::bitvec::BitVec;
use crate::tools::hashing::{Chain, FofHasher, HashOutput};
use crate::uint::UintLike;
use crypto_bigint::BitOps;

/// Possible results of the KeyRefresh protocol.
#[derive(Debug)]
Expand Down Expand Up @@ -59,10 +59,13 @@ enum KeyRefreshErrorEnum<P: SchemeParams> {
mu: Randomizer<P::Paillier>,
},
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(bound(serialize = "PrmProof<P>: Serialize"))]
#[serde(bound(deserialize = "PrmProof<P>: for<'x> Deserialize<'x>"))]
#[serde(bound(serialize = "
PrmProof<P>: Serialize,
"))]
#[serde(bound(deserialize = "
PrmProof<P>: for<'x> Deserialize<'x>,
"))]
pub struct PublicData1<P: SchemeParams> {
cap_x_to_send: Vec<Point>, // $X_i^j$ where $i$ is this party's index
cap_a_to_send: Vec<SchCommitment>, // $A_i^j$ where $i$ is this party's index
Expand Down Expand Up @@ -352,7 +355,7 @@ impl<P: SchemeParams, I: Debug + Clone + Ord + Serialize> Round<I> for Round2<P,

let paillier_pk = broadcast_msg.data.paillier_pk.to_precomputed();

if paillier_pk.modulus().bits_vartime() < 8 * P::SECURITY_PARAMETER {
if (paillier_pk.modulus().bits_vartime() as usize) < 8 * P::SECURITY_PARAMETER {
return Err(KeyRefreshError(KeyRefreshErrorEnum::Round2(
"Paillier modulus is too small".into(),
)));
Expand Down
2 changes: 1 addition & 1 deletion synedrion/src/cggmp21/sigma/fac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl<P: SchemeParams> FacProof<P> {
// Note that it has to be matched when we check the range of
// `z1` and `z2` during verification.
let sqrt_cap_n = Bounded::new(
<P::Paillier as PaillierParams>::Uint::ONE
<P::Paillier as PaillierParams>::Uint::one()
<< (<P::Paillier as PaillierParams>::PRIME_BITS - 2),
<P::Paillier as PaillierParams>::PRIME_BITS as u32,
)
Expand Down
29 changes: 16 additions & 13 deletions synedrion/src/cggmp21/sigma/mod_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ use serde::{Deserialize, Serialize};

use super::super::SchemeParams;
use crate::paillier::{PaillierParams, PublicKeyPaillierPrecomputed, SecretKeyPaillierPrecomputed};
use crate::tools::hashing::{Chain, Hashable, XofHasher};
use crate::uint::{RandomPrimeWithRng, Retrieve, UintLike, UintModLike};
use crate::tools::hashing::{uint_from_xof, Chain, Hashable, XofHasher};
use crate::uint::{RandomPrimeWithRng, Retrieve, ToMontgomery};
use crypto_bigint::{PowBoundedExp, Square};

const HASH_TAG: &[u8] = b"P_mod";

Expand Down Expand Up @@ -41,7 +42,7 @@ impl<P: SchemeParams> ModChallenge<P> {

let modulus = pk.modulus_nonzero();
let ys = (0..P::SECURITY_PARAMETER)
.map(|_| <P::Paillier as PaillierParams>::Uint::from_xof(&mut reader, &modulus))
.map(|_| uint_from_xof(&mut reader, &modulus))
.collect();
Self(ys)
}
Expand Down Expand Up @@ -100,8 +101,8 @@ impl<P: SchemeParams> ModProof<P> {
y_mod_q = -y_mod_q;
}
if *b {
y_mod_p = y_mod_p * omega_mod_p;
y_mod_q = y_mod_q * omega_mod_q;
y_mod_p *= omega_mod_p.clone();
y_mod_q *= omega_mod_q.clone();
}

if let Some((p, q)) = sk.sqrt(&(y_mod_p, y_mod_q)) {
Expand All @@ -116,8 +117,9 @@ impl<P: SchemeParams> ModProof<P> {
let y_4th_parts = sk.sqrt(&y_sqrt).unwrap();
let y_4th = sk.rns_join(&y_4th_parts);

let y = challenge.0[i].to_mod(pk.precomputed_modulus());
let z = y.pow_bounded(sk.inv_modulus());
let y = challenge.0[i].to_montgomery(pk.precomputed_modulus());
let sk_inv_modulus = sk.inv_modulus();
let z = y.pow_bounded_exp(sk_inv_modulus.as_ref(), sk_inv_modulus.bound());

ModProofElem {
x: y_4th,
Expand Down Expand Up @@ -159,21 +161,22 @@ impl<P: SchemeParams> ModProof<P> {
}

let precomputed = pk.precomputed_modulus();
let omega_mod = self.commitment.0.to_mod(precomputed);
let omega_mod = self.commitment.0.to_montgomery(precomputed);
for (elem, y) in self.proof.iter().zip(self.challenge.0.iter()) {
let z_m = elem.z.to_mod(precomputed);
let mut y_m = y.to_mod(precomputed);
if z_m.pow_bounded(&pk.modulus_bounded()) != y_m {
let z_m = elem.z.to_montgomery(precomputed);
let mut y_m = y.to_montgomery(precomputed);
let pk_modulus_bounded = pk.modulus_bounded();
if z_m.pow_bounded_exp(pk_modulus_bounded.as_ref(), pk_modulus_bounded.bound()) != y_m {
return false;
}

if elem.a {
y_m = -y_m;
}
if elem.b {
y_m = y_m * omega_mod;
y_m *= omega_mod;
}
let x = elem.x.to_mod(precomputed);
let x = elem.x.to_montgomery(precomputed);
let x_4 = x.square().square();
if y_m != x_4 {
return false;
Expand Down
9 changes: 5 additions & 4 deletions synedrion/src/cggmp21/sigma/prm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ use crate::paillier::{PaillierParams, RPParamsMod, RPSecret, SecretKeyPaillierPr
use crate::tools::hashing::{Chain, Hashable, XofHasher};
use crate::uint::{
subtle::{Choice, ConditionallySelectable},
Bounded, Retrieve, UintLike, UintModLike,
Bounded, Retrieve, ToMontgomery,
};
use crypto_bigint::PowBoundedExp;

const HASH_TAG: &[u8] = b"P_prm";

Expand Down Expand Up @@ -43,7 +44,7 @@ impl<P: SchemeParams> PrmCommitment<P> {
let commitment = secret
.0
.iter()
.map(|a| base.pow_bounded(a).retrieve())
.map(|a| base.pow_bounded_exp(a.as_ref(), a.bound()).retrieve())
.collect();
Self(commitment)
}
Expand Down Expand Up @@ -133,8 +134,8 @@ impl<P: SchemeParams> PrmProof<P> {
for i in 0..challenge.0.len() {
let z = self.proof[i];
let e = challenge.0[i];
let a = self.commitment.0[i].to_mod(precomputed);
let pwr = setup.base.pow_bounded(&z);
let a = self.commitment.0[i].to_montgomery(precomputed);
let pwr = setup.base.pow_bounded_exp(z.as_ref(), z.bound());
let test = if e { pwr == a * setup.power } else { pwr == a };
if !test {
return false;
Expand Down
21 changes: 11 additions & 10 deletions synedrion/src/curve/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ use core::ops::{Add, Mul, Neg, Sub};
use digest::Digest;
use k256::elliptic_curve::group::ff::PrimeField;
use k256::elliptic_curve::{
array::{typenum::marker_traits::Unsigned, Array},
bigint::U256, // Note that this type is different from typenum::U256
generic_array::typenum::marker_traits::Unsigned,
generic_array::GenericArray,
ops::Reduce,
point::AffineCoordinates,
sec1::{EncodedPoint, FromEncodedPoint, ModulusSize, ToEncodedPoint},
Expand Down Expand Up @@ -81,7 +80,7 @@ impl Scalar {
/// SEC1 specifies to subtract the secp256k1 modulus when the byte array
/// is larger than the modulus.
pub fn from_reduced_bytes(bytes: &[u8; 32]) -> Self {
let arr = GenericArray::<u8, FieldBytesSize<Secp256k1>>::from(*bytes);
let arr = Array::<u8, FieldBytesSize<Secp256k1>>::from(*bytes);
Self(<BackendScalar as Reduce<U256>>::reduce_bytes(&arr))
}

Expand All @@ -107,9 +106,8 @@ impl Scalar {
}

pub(crate) fn try_from_bytes(bytes: &[u8]) -> Result<Self, String> {
let arr =
GenericArray::<u8, FieldBytesSize<Secp256k1>>::from_exact_iter(bytes.iter().cloned())
.ok_or("Invalid length of a curve scalar")?;
let arr = Array::<u8, FieldBytesSize<Secp256k1>>::try_from_iter(bytes.iter().cloned())
.map_err(|e| format!("Invalid length of a curve scalar: {:?}", e))?;

BackendScalar::from_repr_vartime(arr)
.map(Self)
Expand Down Expand Up @@ -199,10 +197,13 @@ impl Point {
.ok_or_else(|| "Invalid curve point representation".into())
}

pub(crate) fn to_compressed_array(self) -> GenericArray<u8, CompressedPointSize> {
*GenericArray::<u8, CompressedPointSize>::from_slice(
self.0.to_affine().to_encoded_point(true).as_bytes(),
)
pub(crate) fn to_compressed_array(self) -> Array<u8, CompressedPointSize> {
self.0
.to_affine()
.to_encoded_point(true)
.as_bytes()
.try_into()
.expect("An AffinePoint is composed of elements of the correct size and their slice repr fits in the `CompressedPointSize`-sized array.")
}

pub(crate) fn to_backend(self) -> BackendPoint {
Expand Down
2 changes: 1 addition & 1 deletion synedrion/src/curve/ecdsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl RecoverableSignature {
// Normalize the `s` component.
// `BackendSignature`'s constructor does not require `s` to be normalized,
// but consequent usage of it may fail otherwise.
let signature = signature.normalize_s().unwrap_or(signature);
let signature = signature.normalize_s();

let message_bytes = message.to_bytes();
let recovery_id = RecoveryId::trial_recovery_from_prehash(
Expand Down
Loading
Loading