use super::*;
impl<A: Aleo> Record<A, Plaintext<A>> {
pub fn to_commitment(
&self,
program_id: &ProgramID<A>,
record_name: &Identifier<A>,
record_view_key: &Field<A>,
) -> Field<A> {
let mut input = program_id.to_bits_le();
record_name.write_bits_le(&mut input);
self.write_bits_le(&mut input);
let input_v0 = input[..input.len() - 8].to_vec();
let digest = A::hash_bhp1024(&input_v0);
let mut input_v1 = digest.to_bits_le();
input_v1.extend_from_slice(&input[input.len() - 8..]);
let cm_nonce = A::hash_to_scalar_psd2(&[A::commitment_domain(), record_view_key.clone()]);
let commitment = A::commit_bhp512(&input_v1, &cm_nonce);
Ternary::ternary(&!self.is_hiding(), &digest, &commitment)
}
}
impl<A: Aleo> Record<A, Ciphertext<A>> {
pub fn to_commitment(
&self,
_program_id: &ProgramID<A>,
_record_name: &Identifier<A>,
_record_view_key: &Field<A>,
) -> Field<A> {
A::halt("Illegal operation: Record::to_commitment() cannot be invoked on the `Ciphertext` variant.")
}
}