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

for decaf377 0.9.0 #99

Merged
merged 2 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,5 @@
* fix: field modulus by @TalDerei in #92
* adjust anyhow scope and remove unused dependencies by @neithanmo in #96
* add power impl and expose `Fq::from_montgomery_limbs` by @redshiftzero in #98
* Add missing conversion trait implementations by @neithanmo in #97

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ website](https://protocol.penumbra.zone/main/crypto/decaf377.html).
## Features

* `std`: default, for use in `std` environments,
* `alloc`: default, for use in `alloc` environments,
* `arkworks`: default, uses Arkworks crates for elliptic curve operations,
* `u32_backend`: uses 32-bit finite field arithmetic (default is 64-bit),
* `r1cs`: enables rank-1 constraint system gadgets,
* `parallel`: enables the use of parallelism.

Expand Down
27 changes: 0 additions & 27 deletions src/min_curve/encoding.rs
Original file line number Diff line number Diff line change
@@ -1,31 +1,4 @@
use crate::EncodingError;

Check warning on line 1 in src/min_curve/encoding.rs

View workflow job for this annotation

GitHub Actions / build without alloc

unused import: `crate::EncodingError`

Check warning on line 1 in src/min_curve/encoding.rs

View workflow job for this annotation

GitHub Actions / no_std compatibility check

unused import: `crate::EncodingError`

Check warning on line 1 in src/min_curve/encoding.rs

View workflow job for this annotation

GitHub Actions / no_std compatibility check

unused import: `crate::EncodingError`

Check warning on line 1 in src/min_curve/encoding.rs

View workflow job for this annotation

GitHub Actions / no_std compatibility check

unused import: `crate::EncodingError`
use core::convert::TryFrom;

#[derive(Copy, Clone, Default, Eq, Ord, PartialOrd, PartialEq, Debug)]
pub struct Encoding(pub [u8; 32]);

impl TryFrom<&[u8]> for Encoding {
type Error = EncodingError;

fn try_from(bytes: &[u8]) -> Result<Self, Self::Error> {
if bytes.len() == 32 {
let mut arr = [0u8; 32];
arr.copy_from_slice(&bytes[0..32]);
Ok(Encoding(arr))
} else {
Err(EncodingError::InvalidSliceLength)
}
}
}

impl From<[u8; 32]> for Encoding {
fn from(bytes: [u8; 32]) -> Encoding {
Encoding(bytes)
}
}

impl From<Encoding> for [u8; 32] {
fn from(enc: Encoding) -> [u8; 32] {
enc.0
}
}
Loading