mirror of
https://github.com/Qortal/pirate-librustzcash.git
synced 2025-07-30 20:11:23 +00:00
impl ConditionallySelectable for Field
This commit is contained in:
@@ -28,6 +28,7 @@ rand_core = "0.5.1"
|
||||
ripemd160 = { version = "0.8", optional = true }
|
||||
secp256k1 = { version = "=0.15.0", optional = true }
|
||||
sha2 = "0.8"
|
||||
subtle = "2.2.1"
|
||||
|
||||
[dev-dependencies]
|
||||
hex-literal = "0.2"
|
||||
|
@@ -6,6 +6,7 @@ use ff::{
|
||||
};
|
||||
use rand_core::RngCore;
|
||||
use std::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign};
|
||||
use subtle::{Choice, ConditionallySelectable};
|
||||
|
||||
use super::ToUniform;
|
||||
|
||||
@@ -269,6 +270,17 @@ impl From<Fs> for FsRepr {
|
||||
}
|
||||
}
|
||||
|
||||
impl ConditionallySelectable for Fs {
|
||||
fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self {
|
||||
Fs(FsRepr([
|
||||
u64::conditional_select(&(a.0).0[0], &(b.0).0[0], choice),
|
||||
u64::conditional_select(&(a.0).0[1], &(b.0).0[1], choice),
|
||||
u64::conditional_select(&(a.0).0[2], &(b.0).0[2], choice),
|
||||
u64::conditional_select(&(a.0).0[3], &(b.0).0[3], choice),
|
||||
]))
|
||||
}
|
||||
}
|
||||
|
||||
impl Neg for Fs {
|
||||
type Output = Self;
|
||||
|
||||
|
Reference in New Issue
Block a user