Skip to content

Conversation

@tarcieri
Copy link
Contributor

From the API guidelines, a function that does not require ownership should borrow its input:

https://rust-lang.github.io/api-guidelines/flexibility.html?highlight=clone#caller-decides-where-to-copy-and-place-data-c-caller-control

In general, I think there's an intermediate decoding step between PrimeField::Repr and the corresponding Self type which receives an impl thereof, rather than the Self type actually taking ownership of the Repr data.

Since field element types sometimes represent secrets, taking ownership of the data means the caller can't zeroize that data, and moving the data rather than borrowing it may introduce an additional copy.

From the API guidelines, a function that does not require ownership
should borrow its input:

https://rust-lang.github.io/api-guidelines/flexibility.html?highlight=clone#caller-decides-where-to-copy-and-place-data-c-caller-control

In general, I think there's an intermediate decoding step between
`PrimeField::Repr` and the corresponding `Self` type which receives an
impl thereof, rather than the `Self` type actually taking ownership of
the `Repr` data.

Since field element types sometimes represent secrets, taking ownership
of the data means the caller can't zeroize that data, and moving the
data rather than borrowing it may introduce an additional copy.
@daxpedda
Copy link

daxpedda commented May 29, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants