Function
hash_to_field
(
party_1: ParticipantId,
party_2: ParticipantId,
r: &F,
hasher: &DefaultFieldHasher<D>,
)
Source from the content-addressed store, hash-verified
| 143 | } |
| 144 | |
| 145 | pub fn hash_to_field<F: PrimeField, D: Default + DynDigest + Clone>( |
| 146 | party_1: ParticipantId, |
| 147 | party_2: ParticipantId, |
| 148 | r: &F, |
| 149 | hasher: &DefaultFieldHasher<D>, |
| 150 | ) -> F { |
| 151 | let mut bytes = vec![]; |
| 152 | r.serialize_compressed(&mut bytes).unwrap(); |
| 153 | bytes.push((party_1 & 255) as u8); |
| 154 | bytes.push((party_1 >> 8) as u8); |
| 155 | bytes.push((party_2 & 255) as u8); |
| 156 | bytes.push((party_2 >> 8) as u8); |
| 157 | hasher.hash_to_field(&bytes, 1).pop().unwrap() |
| 158 | } |
| 159 | |
| 160 | #[cfg(test)] |
| 161 | pub mod tests { |
Tested by
no test coverage detected