From 8d51c8da18dc9c5a6ba640cd1b68821e882ba25e Mon Sep 17 00:00:00 2001 From: redshiftzero Date: Tue, 2 Apr 2024 14:28:46 -0400 Subject: [PATCH 1/3] make Fq::from_montgomery_limbs pub --- src/fields/fq/u32/wrapper.rs | 3 +++ src/fields/fq/u64/wrapper.rs | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/fields/fq/u32/wrapper.rs b/src/fields/fq/u32/wrapper.rs index 62e168f..aea3553 100644 --- a/src/fields/fq/u32/wrapper.rs +++ b/src/fields/fq/u32/wrapper.rs @@ -87,6 +87,9 @@ impl Fq { Self(fiat::FqMontgomeryDomainFieldElement(limbs)) } + /// Instantiate a constant field element from its montgomery limbs. + /// + /// This should only be used if you are familiar with the internals of the library. pub const fn from_montgomery_limbs(limbs: [u64; N_64]) -> Fq { Self(fiat::FqMontgomeryDomainFieldElement([ limbs[0] as u32, diff --git a/src/fields/fq/u64/wrapper.rs b/src/fields/fq/u64/wrapper.rs index 4155d74..d581aa7 100644 --- a/src/fields/fq/u64/wrapper.rs +++ b/src/fields/fq/u64/wrapper.rs @@ -70,7 +70,10 @@ impl Fq { bytes } - pub(crate) const fn from_montgomery_limbs(limbs: [u64; N]) -> Fq { + /// Instantiate a constant field element from its montgomery limbs. + /// + /// This should only be used if you are familiar with the internals of the library. + pub const fn from_montgomery_limbs(limbs: [u64; N]) -> Fq { Self(fiat::FqMontgomeryDomainFieldElement(limbs)) } From 66d3b73c65e479d308d3722abe03570574a66390 Mon Sep 17 00:00:00 2001 From: redshiftzero Date: Tue, 2 Apr 2024 14:40:05 -0400 Subject: [PATCH 2/3] impl Fq::power --- src/fields/fq.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/fields/fq.rs b/src/fields/fq.rs index 45d5a3c..cefccfa 100644 --- a/src/fields/fq.rs +++ b/src/fields/fq.rs @@ -125,6 +125,18 @@ impl Fq { }; Self::from_le_bytes_mod_order(&bytes) } + + /// Raise this element to a given power. + /// + /// Note: Arkworks provides another method for this, called `pow`. + pub fn power>(&self, exp: S) -> Self { + let mut res = Fq::from(1u64); + let exp_u64 = exp.as_ref(); + for _ in 0..exp_u64[0] { + res *= self; + } + res + } } #[cfg(test)] From 967a63fe919403a59bbd9993201b0d02559a315b Mon Sep 17 00:00:00 2001 From: redshiftzero Date: Wed, 3 Apr 2024 09:12:44 -0400 Subject: [PATCH 3/3] chore: bump to 0.9.0 --- CHANGELOG.md | 27 +++++++++++++++++++++++++++ Cargo.toml | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e75f768..d5dc5b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,3 +31,30 @@ # 0.7.0 * Fix: Add `no_std` compatibility. + +# 0.8.0 + +* Add fiat-generated finite field implementations by @hdevalence in #64 +* refactor(arkworks): feature-gated Arkworks compatibility by @TalDerei in #67 +* Implement Bls12377 using our own backend by @cronokirby in #71 +* ci: add job to test u32_backend by @redshiftzero in #72 +* Arkworks feature gating by @cronokirby in #73 +* Implement traits in a no_std context when possible by @cronokirby in #74 +* Implement the start of a minimal curve implementation by @cronokirby in #75 +* ci: add job building with no alloc feature by @redshiftzero in #76 +* arkworks independent projective arithmetic ops by @redshiftzero in #77 +* Make modular reduction work for large byte sizes by @cronokirby in #78 +* Implement FromStr for all the fields by @cronokirby in #79 +* Implement a checked conversion from bytes method in Fq by @cronokirby in #81 +* arkworks-independent sqrts, point encoding/decoding by @cronokirby in #80 +* ci: use larger runners by @conorsch in #83 +* ci: dedicated profile for release + debug_assert by @conorsch in #84 +* rearranging arkworks / non-arkworks ECC code by @redshiftzero in #82 + +# 0.9.0 + +* Make raw constructors of field elements private by @cronokirby in #90 +* Add missing methods as need for integrating the latest version of this crate by @cronokirby in #91 +* 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 diff --git a/Cargo.toml b/Cargo.toml index 743e6b9..1de07ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "decaf377" -version = "0.8.0" +version = "0.9.0" authors = [ "Henry de Valence ", "redshiftzero ",