Fix trait ambiguity in SealedScalar trait impl

The FieldExt and SealedScalar traits have a method with the same name,
and the latter's is implemented for pallas::Scalar as a call to the
former's implementation. However, FieldExt was not in scope. In debug
mode, Rust was calling SealedScalar's method recursively, causing a
stack overflow. However in release mode, Rust was able to find the
FieldExt method fine (and does not appear to just be optimizing out the
code, as the result is valid). To ensure this does not occur, we now
explicitly use the FieldExt method implementation.
This commit is contained in:
Jack Grigg 2021-04-28 14:15:32 +12:00
parent 0627048eba
commit b91559345c
1 changed files with 1 additions and 1 deletions

View File

@ -49,7 +49,7 @@ impl super::Binding for Binding {}
impl private::SealedScalar for pallas::Scalar {
fn from_bytes_wide(bytes: &[u8; 64]) -> Self {
pallas::Scalar::from_bytes_wide(bytes)
<pallas::Scalar as pasta_curves::arithmetic::FieldExt>::from_bytes_wide(bytes)
}
fn from_raw(val: [u64; 4]) -> Self {
pallas::Scalar::from_raw(val)